Skip to content

Commit c2e2920

Browse files
mark.sandlereddiecohen
mark.sandler
authored andcommitted
Merge branch 'develop' of ssh://git/localhome/GIT/Software/OpenNI2 into develop
1 parent 1ce092d commit c2e2920

15 files changed

+172
-26
lines changed

Config/OpenNI2/Drivers/PSLink.ini

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
;---------------- PSLink Driver Default Configuration -------------------
2+
3+
[Device]
4+
; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines)
5+
;UsbInterface=2
6+
7+
[Depth]
8+
; Allows dumping all frames to files. 0 - Off (default), 1 - On
9+
;DumpData=1
10+
11+
; Allow flipping the frame horizontally. 0 - Off, 1 - On (default)
12+
;Mirror=0
13+
14+
; Compression of the data passed from device to host. 0 - None, 2 - 16z, 6 - 11-bit packed, 7 - 12-bit packed. Default is set by the firmware
15+
;Compression=2
16+
17+
[Depth.VideoMode]
18+
; Pixel Format. 100 - Depth 1 mm, 101 - Depth 100 um, 102 - Shifts 9.2, 103 - Shifts 9.3
19+
;PixelFormat=100
20+
; Requested X resolution
21+
;XResolution=320
22+
; Requested Y resolution
23+
;YResolution=240
24+
; Requested FPS
25+
;FPS=30
26+
27+
[IR]
28+
; Allows dumping all frames to files. 0 - Off (default), 1 - On
29+
;DumpData=1
30+
31+
; Allow flipping the frame horizontally. 0 - Off, 1 - On (default)
32+
;Mirror=0
33+
34+
; Compression of the data passed from device to host. 0 - None, 5 - 10-bit packed. Default is set by the firmware
35+
;Compression=5
36+
37+
[IR.VideoMode]
38+
; Pixel Format. 200 - RGB888, 202 - Grayscale 8-bit, 203 - Grayscale 16-bit
39+
;PixelFormat=200
40+
; Requested X resolution
41+
;XResolution=320
42+
; Requested Y resolution
43+
;YResolution=240
44+
; Requested FPS
45+
;FPS=30

Packaging/Harvest.py

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def copyRedistFiles(self, targetDir):
9292
self.copySharedObject(binDriversDir, 'PS1080', targetDriversDir)
9393
self.copySharedObject(binDriversDir, 'PSLink', targetDriversDir)
9494
shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PS1080.ini'), targetDriversDir)
95+
shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PSLink.ini'), targetDriversDir)
9596
if self.osName == 'Windows':
9697
self.copySharedObject(binDriversDir, 'Kinect', targetDriversDir)
9798

Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
//---------------------------------------------------------------------------
2929
#define XN_MASK_LINK_STREAM "LinkDepthStream"
3030

31-
LinkOniDepthStream::LinkOniDepthStream(xn::PrimeClient* pSensor, LinkOniDevice* pDevice) :
32-
LinkOniMapStream(pSensor, ONI_SENSOR_DEPTH, pDevice)
31+
LinkOniDepthStream::LinkOniDepthStream(const char* configFile, xn::PrimeClient* pSensor, LinkOniDevice* pDevice) :
32+
LinkOniMapStream(configFile, "Depth", pSensor, ONI_SENSOR_DEPTH, pDevice)
3333
{
3434
}
3535

Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LinkOniDepthStream :
3333
public LinkOniMapStream
3434
{
3535
public:
36-
LinkOniDepthStream(xn::PrimeClient* pSensor, LinkOniDevice* pDevice);
36+
LinkOniDepthStream(const char* configFile, xn::PrimeClient* pSensor, LinkOniDevice* pDevice);
3737
virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize);
3838
virtual OniBool isPropertySupported(int propertyId);
3939
virtual void notifyAllProperties();

Source/Drivers/PSLink/DriverImpl/LinkOniDevice.cpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
// LinkOniDevice class
3333
//---------------------------------------------------------------------------
3434
#define XN_MASK_LINK_DEVICE "LinkDevice"
35+
#define CONFIG_DEVICE_SECTION "Device"
3536

36-
LinkOniDevice::LinkOniDevice(const XnChar* uri, oni::driver::DriverServices& driverServices, LinkOniDriver* pDriver) :
37-
m_pSensor(NULL), m_driverServices(driverServices), m_pDriver(pDriver)
37+
LinkOniDevice::LinkOniDevice(const char* configFile, const XnChar* uri, oni::driver::DriverServices& driverServices, LinkOniDriver* pDriver) :
38+
m_configFile(configFile), m_pSensor(NULL), m_driverServices(driverServices), m_pDriver(pDriver)
3839
{
3940
xnOSMemCopy(&m_info, LinkDeviceEnumeration::GetDeviceInfo(uri), sizeof(m_info));
4041
}
@@ -285,6 +286,17 @@ XnStatus LinkOniDevice::Init(const char* mode)
285286

286287
m_pSensor = pPrimeClient;
287288

289+
XnInt32 value32;
290+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, CONFIG_DEVICE_SECTION, "UsbInterface", &value32))
291+
{
292+
retVal = setProperty(PS_PROPERTY_USB_INTERFACE, &value32, sizeof(value32));
293+
if (retVal != XN_STATUS_OK)
294+
{
295+
XN_DELETE(pPrimeClient);
296+
return retVal;
297+
}
298+
}
299+
288300
if (!leanInit)
289301
{
290302
retVal = FillSupportedVideoModes();
@@ -330,11 +342,11 @@ oni::driver::StreamBase* LinkOniDevice::createStream(OniSensorType sensorType)
330342

331343
if (sensorType == ONI_SENSOR_DEPTH)
332344
{
333-
pStream = XN_NEW(LinkOniDepthStream, m_pSensor, this);
345+
pStream = XN_NEW(LinkOniDepthStream, m_configFile, m_pSensor, this);
334346
}
335347
else if (sensorType == ONI_SENSOR_IR)
336348
{
337-
pStream = XN_NEW(LinkOniIRStream, m_pSensor, this);
349+
pStream = XN_NEW(LinkOniIRStream, m_configFile, m_pSensor, this);
338350
}
339351
//else if (sensorType == ONI_SENSOR_COLOR)
340352
//{

Source/Drivers/PSLink/DriverImpl/LinkOniDevice.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LinkOniDevice :
4343
public oni::driver::DeviceBase
4444
{
4545
public:
46-
LinkOniDevice(const char* uri, oni::driver::DriverServices& driverServices, LinkOniDriver* pDriver);
46+
LinkOniDevice(const char* configFile, const char* uri, oni::driver::DriverServices& driverServices, LinkOniDriver* pDriver);
4747
virtual ~LinkOniDevice();
4848

4949
XnStatus Init(const char* mode);
@@ -85,6 +85,7 @@ class LinkOniDevice :
8585
XnStatus readSupportedModesFromStream(XnFwStreamInfo &info, xnl::Array<XnFwStreamVideoMode> &aSupportedModes);
8686
XnStatus FillSupportedVideoModes();
8787

88+
const char* m_configFile;
8889
OniDeviceInfo m_info;
8990
// the device we wrap
9091
xn::PS1200Device* m_pSensor;

Source/Drivers/PSLink/DriverImpl/LinkOniDriver.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ OniStatus LinkOniDriver::initialize(oni::driver::DeviceConnectedCallback deviceC
7373
return ONI_STATUS_ERROR;
7474
}
7575

76+
resolveConfigFilePath();
77+
7678
return ONI_STATUS_OK;
7779
}
7880

@@ -112,7 +114,7 @@ oni::driver::DeviceBase* LinkOniDriver::deviceOpen(const char* uri, const char*
112114
return NULL;
113115
}
114116

115-
pDevice = XN_NEW(LinkOniDevice, uri, getServices(), this);
117+
pDevice = XN_NEW(LinkOniDevice, m_configFilePath, uri, getServices(), this);
116118
XnStatus nRetVal = pDevice->Init(mode);
117119
if (nRetVal != XN_STATUS_OK)
118120
{
@@ -286,3 +288,17 @@ void XN_CALLBACK_TYPE LinkOniDriver::OnDeviceDisconnected(const OniDeviceInfo& d
286288
pThis->deviceDisconnected(&deviceInfo);
287289
}
288290

291+
void LinkOniDriver::resolveConfigFilePath()
292+
{
293+
XnChar strModulePath[XN_FILE_MAX_PATH];
294+
295+
if (xnOSGetModulePathForProcAddress(reinterpret_cast<void*>(&LinkOniDriver::OnDeviceConnected), strModulePath) != XN_STATUS_OK ||
296+
xnOSGetDirName(strModulePath, m_configFilePath, sizeof(m_configFilePath)) != XN_STATUS_OK)
297+
{
298+
// Something wrong happened. Use the current directory as the fall-back.
299+
xnOSStrCopy(m_configFilePath, ".", sizeof(m_configFilePath));
300+
}
301+
302+
xnOSAppendFilePath(m_configFilePath, "PSLink.ini", sizeof(m_configFilePath));
303+
}
304+

Source/Drivers/PSLink/DriverImpl/LinkOniDriver.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class LinkOniDriver :
3838
{
3939
public:
4040
LinkOniDriver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices), m_writer(pDriverServices), m_connectedEventHandle(NULL), m_disconnectedEventHandle(NULL)
41-
{}
41+
{
42+
m_configFilePath[0] = '\0';
43+
}
4244

4345
virtual OniStatus initialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie);
4446
virtual void shutdown();
@@ -78,9 +80,12 @@ class LinkOniDriver :
7880
LinkOniDevice* pDevice;
7981
} FrameSyncGroup;
8082

83+
void resolveConfigFilePath();
84+
8185
LinkOpenNILogWriter m_writer;
8286
XnCallbackHandle m_connectedEventHandle;
8387
XnCallbackHandle m_disconnectedEventHandle;
88+
char m_configFilePath[XN_FILE_MAX_PATH];
8489
};
8590

8691
#endif // __LINK_ONI_DRIVER_H__

Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
// LinkOniIRStream class
2828
//---------------------------------------------------------------------------
2929

30-
LinkOniIRStream::LinkOniIRStream(xn::PrimeClient* pSensor, LinkOniDevice* pDevice) :
31-
LinkOniMapStream(pSensor, ONI_SENSOR_IR, pDevice)
30+
LinkOniIRStream::LinkOniIRStream(const char* configFile, xn::PrimeClient* pSensor, LinkOniDevice* pDevice) :
31+
LinkOniMapStream(configFile, "IR", pSensor, ONI_SENSOR_IR, pDevice)
3232
{
3333
}
3434

Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LinkOniIRStream :
3333
public LinkOniMapStream
3434
{
3535
public:
36-
LinkOniIRStream(xn::PrimeClient* pSensor, LinkOniDevice* pDevice);
36+
LinkOniIRStream(const char* configFile, xn::PrimeClient* pSensor, LinkOniDevice* pDevice);
3737
};
3838

3939
#endif // __LINK_ONI_IR_STREAM_H__

Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.cpp

+42-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
// LinkOniMapStream class
3030
//---------------------------------------------------------------------------
3131

32-
LinkOniMapStream::LinkOniMapStream(xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice) :
33-
LinkOniStream(pSensor, sensorType, pDevice),
32+
LinkOniMapStream::LinkOniMapStream(const char* configFile, const char* configSection, xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice) :
33+
LinkOniStream(configFile, configSection, pSensor, sensorType, pDevice),
3434
m_nSupportedModesCount(0),
3535
m_aSupportedModes(NULL)
3636
{
@@ -55,7 +55,46 @@ XnStatus LinkOniMapStream::Init()
5555
nRetVal = FillSupportedVideoModes();
5656
XN_IS_STATUS_OK(nRetVal);
5757

58-
nRetVal = SetMirror(TRUE);
58+
// read video mode
59+
XnChar section[255];
60+
sprintf(section, "%s.VideoMode", m_configSection);
61+
OniVideoMode videoMode;
62+
GetVideoMode(&videoMode);
63+
64+
XnInt32 temp32;
65+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "XResolution", &temp32))
66+
{
67+
videoMode.resolutionX = (int)temp32;
68+
}
69+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "YResolution", &temp32))
70+
{
71+
videoMode.resolutionY = (int)temp32;
72+
}
73+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "FPS", &temp32))
74+
{
75+
videoMode.fps = (int)temp32;
76+
}
77+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "PixelFormat", &temp32))
78+
{
79+
videoMode.pixelFormat = (OniPixelFormat)temp32;
80+
}
81+
82+
nRetVal = SetVideoMode(&videoMode);
83+
XN_IS_STATUS_OK(nRetVal);
84+
85+
nRetVal = setIntPropertyFromINI("LinkPixelFormat", LINK_PROP_PIXEL_FORMAT);
86+
XN_IS_STATUS_OK(nRetVal);
87+
88+
nRetVal = setIntPropertyFromINI("Compression", LINK_PROP_COMPRESSION);
89+
XN_IS_STATUS_OK(nRetVal);
90+
91+
OniBool bMirror = TRUE;
92+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "Mirror", &temp32))
93+
{
94+
bMirror = (temp32 == 1);
95+
}
96+
97+
nRetVal = SetMirror(bMirror);
5998
XN_IS_STATUS_OK(nRetVal);
6099

61100
return (XN_STATUS_OK);

Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LinkOniMapStream :
3333
public LinkOniStream
3434
{
3535
public:
36-
LinkOniMapStream(xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice);
36+
LinkOniMapStream(const char* configFile, const char* configSection, xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice);
3737
virtual ~LinkOniMapStream();
3838

3939
virtual XnStatus Init();

Source/Drivers/PSLink/DriverImpl/LinkOniStream.cpp

+24-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
//---------------------------------------------------------------------------
2929
#define XN_MASK_LINK_STREAM "LinkStream"
3030

31-
LinkOniStream::LinkOniStream(xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice) :
31+
LinkOniStream::LinkOniStream(const char* configFile, const char* configSection, xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice) :
32+
m_configFile(configFile),
33+
m_configSection(configSection),
3234
m_sensorType(sensorType),
3335
m_pSensor(pSensor),
3436
m_pDevice(pDevice),
@@ -46,7 +48,7 @@ XnStatus LinkOniStream::Init()
4648
{
4749
XnStatus nRetVal = XN_STATUS_OK;
4850
XnLinkStreamType linkStreamType;
49-
switch(m_sensorType)
51+
switch (m_sensorType)
5052
{
5153
case ONI_SENSOR_DEPTH:
5254
linkStreamType = XN_LINK_STREAM_TYPE_SHIFTS; break;
@@ -67,6 +69,9 @@ XnStatus LinkOniStream::Init()
6769
m_pInputStream->GetNewFrameEvent().Register(OnNewStreamDataEventHandler, this, m_hNewDataCallback);
6870
XN_IS_STATUS_OK(nRetVal);
6971

72+
nRetVal = setIntPropertyFromINI("DumpData", PS_PROPERTY_DUMP_DATA);
73+
XN_IS_STATUS_OK(nRetVal);
74+
7075
return (XN_STATUS_OK);
7176
}
7277

@@ -137,15 +142,12 @@ OniStatus LinkOniStream::setProperty(int propertyId, const void* data, int dataS
137142
{
138143
case PS_PROPERTY_DUMP_DATA:
139144
{
140-
if (dataSize != sizeof(bool))
141-
{
142-
xnLogWarning(XN_MASK_LINK_STREAM, "Property 'PS_PROPERTY_DUMP_DATA' requires bool data. Got data of size %d", dataSize);
143-
return ONI_STATUS_BAD_PARAMETER;
144-
}
145+
int val;
146+
GET_PROP_VALUE_INT(val, data, dataSize);
145147

146148
XnChar strDumpName[XN_FILE_MAX_PATH] = "";
147149
xnLinkGetStreamDumpName(m_streamId, strDumpName, sizeof(strDumpName));
148-
xnDumpSetMaskState(strDumpName, *(bool*)data);
150+
xnDumpSetMaskState(strDumpName, val == 1);
149151
}
150152
break;
151153
default:
@@ -168,3 +170,17 @@ void XN_CALLBACK_TYPE LinkOniStream::OnNewStreamDataEventHandler(const xn::NewFr
168170
pThis->raiseNewFrame(args.pFrame);
169171
}
170172
}
173+
174+
XnStatus LinkOniStream::setIntPropertyFromINI(const char* key, int propertyId)
175+
{
176+
XnInt32 value;
177+
if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, m_configSection, key, &value))
178+
{
179+
if (ONI_STATUS_OK != setProperty(propertyId, &value, sizeof(value)))
180+
{
181+
return XN_STATUS_ERROR;
182+
}
183+
}
184+
185+
return XN_STATUS_OK;
186+
}

Source/Drivers/PSLink/DriverImpl/LinkOniStream.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class LinkOniStream :
4141
public oni::driver::StreamBase
4242
{
4343
public:
44-
LinkOniStream(xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice);
44+
LinkOniStream(const char* configFile, const char* configSection, xn::PrimeClient* pSensor, OniSensorType sensorType, LinkOniDevice* pDevice);
4545
~LinkOniStream();
4646

4747
virtual XnStatus Init();
@@ -61,6 +61,10 @@ class LinkOniStream :
6161
xn::LinkFrameInputStream* GetDeviceStream() { return m_pInputStream; }
6262

6363
protected:
64+
XnStatus setIntPropertyFromINI(const char* key, int propertyId);
65+
66+
const char* m_configFile;
67+
const char* m_configSection;
6468
OniSensorType m_sensorType;
6569
xn::PrimeClient* m_pSensor;
6670
LinkOniDevice* m_pDevice;

Source/Drivers/PSLink/PrimeClientDefs.h

+7
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@
3030
if (dstSize == 8) *(XnDouble*)pDst = (XnDouble)(value); \
3131
else if(dstSize == 4) *(XnFloat*) pDst = (XnFloat) (value);
3232

33+
#define GET_PROP_VALUE_INT(dest, data, dataSize) \
34+
if (dataSize == 8) dest = (int)*(int64_t*)data; \
35+
else if (dataSize == 4) dest = (int)*(int32_t*)data; \
36+
else if (dataSize == 2) dest = (int)*(int16_t*)data; \
37+
else if (dataSize == 1) dest = (int)*(int8_t*)data; \
38+
else return ONI_STATUS_BAD_PARAMETER;
39+
3340
#endif // __PRIMECLIENTDEFS_H__

0 commit comments

Comments
 (0)