Device Callbacks -- Not working with Structure sensor?


We are implementing a Unity3D Mac/PC app that uses the Structure sensor via a C# wrapper around the core OpenNI2 oni…. functions. I would like the user to be able to plug and unplug their sensor from the computer and respond appropriately. I have passed callbacks to the oniRegisterDeviceCallbacks () function, but they are not getting called when a device is plugged in or unplugged.

The deviceConnected callback is being called one time at the very beginning during the call to oniInitialize, but after that it never gets called again. The deviceDisconnected and deviceStateChanged are never being called.

To verify that I was not doing something wrong calling the low level oni… functions, I have also tried the OpenNI DeviceConnectedListener, DeviceDisconnectedListener and DeviceStateChangedListener classes inside of a modified version of the SimpleRead sample application. The same behavior occurs. The device connected callback gets called once during initialization, and the other callbacks never get called.

Does the Structure driver not support these callbacks?

(Using OpenNI2 v2.2).


An update:

I have been testing the Kinect2 driver on Windows, that is in a side branch of the Occipital OpenNI2 GitHub project. It allows a Kinect v2 to be used with OpenNI2, although it is fragile at this point.

When hooked up to a Kinect v2 the deviceConnected and deviceStateChanged callbacks get called during initialization of the library. But nothing fires after that. Disconnecting the Kinect 2, or reconnecting it does not fire any of the callbacks.

My conclusion is that the callbacks are useless at this point.

To detect a device being disconnected, or a new one connected, it is necessary to get the number of attached devices and respond appropriately when the number changes.