When closing an OpenNI Device using openni::Device::close(), the function deviceClose() in DeviceDriver.cp removes the device from the devices list. If you attempt to reopen the device using openni::Device::open() without reiniting OpenNI entirely, the call will erroneously fail because it says the device doesn't exist.
For situations where OpenNI is not a singleton, this is problematic becasue if you cannot reopen the device without calling the global function openni::OpenNI::shutdown() followed by openni::OpenNI::initialize() to rebuild the list of available devices.
Starting at line 307 of DeviceDriver.cpp is the following code
devices.erase(iter);
deleteDevice(id);
Since the actual device is deinstantiated by when deleteDevice(id) is called, you should simply set the the OpenNI driver pointer to NULL, and then go ahead and delete the device
iter->second = NULL;
deleteDevice(id);
This ensures that the entry for the device remains in the table and it will be found by a subsequent call to openni::Device::open()
When closing an OpenNI Device using openni::Device::close(), the function deviceClose() in DeviceDriver.cp removes the device from the devices list. If you attempt to reopen the device using openni::Device::open() without reiniting OpenNI entirely, the call will erroneously fail because it says the device doesn't exist.
For situations where OpenNI is not a singleton, this is problematic becasue if you cannot reopen the device without calling the global function openni::OpenNI::shutdown() followed by openni::OpenNI::initialize() to rebuild the list of available devices.
Starting at line 307 of DeviceDriver.cpp is the following code
Since the actual device is deinstantiated by when deleteDevice(id) is called, you should simply set the the OpenNI driver pointer to NULL, and then go ahead and delete the device
This ensures that the entry for the device remains in the table and it will be found by a subsequent call to openni::Device::open()