tomoto/OpenNI2 — pull request #2 by tomoto (2013-08-19 00:23:49+00:00)
Title: Extended property support for Kinect Driver

This is a patch continuing #32 to add extended properties to Kinect Driver. Thanks again to KHeresy who created #22 which I used as a reference.

* Supported properties
* 3D sensing properties: Near Mode, IR Emitter On/Off
* Non- 3D sensing properties: Camera Elevation, Accelerometer, Audio Array ID
* API header KinectProperties.h is added. This is a sibling of other private property headers
such as PrimeSense.h, PS1080.h, etc.
(Suffix "Properties" is included in the file name for more clarity.)
* The first 4 hex digits of these properties are 0x045e, taken from Microsoft's USB vendor ID.
* NiViewer's toggleCloseRange now supports Kinect using these properties.
* IR emitter on/off is added ('t' key) to NiViewer for both PS1080 and Kinect.
* Design notes
* I struggled if I should reuse the properties of the same meanings in PS1080.h
(i.e. XN_STREAM_PROPERTY_CLOSE_RANGE and XN_MODULE_PROPERTY_EMITTER_STATE).
The confusion was, although PS1080.h seemed to be private for PS1080 Driver,
it was included and used in Kinect Driver also (e.g. XN_STREAM_PROPERTY_CONST_SHIFT).
I eventually decided not to reuse them assuming PS1080.h was actually supposed to be
private, and its use in Kinect Driver was a "hidden hack" to make NiTE work.
If my reading was wrong, please let me know. I will be more than happy to fix.
* Or, do we want to "promote" these properties (i.e. CLOSE_RANGE and EMITTER_STATE)
as a member of ONI properties? It may not be a bad idea.
* Passing a bool type value to setProperty for an OniBool type property may fail
because bool and OniBool are actually different in size (1 byte vs. 4 bytes).
You can workaround this issue by explicitly specifying the data type like
setProperty(). For the same reason, you cannot get an OniBool type
property into a bool type variable.
(This is confusing and hope we can improve this in the future.)
* Fixed a bug in XnDeviceModule.cpp that caused a crash when reading
XN_MODULE_PROPERTY_EMITTER_STATE from a PS1080 device, which I found
while enhancing NiViewer.