O'Reilly logo

OpenNI Cookbook by Soroush Falahati

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listening to the device connect and disconnect events

We learned how to get a list of connected devices from OpenNI, but here we want to use one of the new features of OpenNI 2. OpenNI 2 lets us introduce two methods that we want to be executed when there is any new device connected or disconnected. Using this ability we want to define two methods and introduce them to OpenNI as a callback for these two events (connect and disconnect). Our methods will only print a line to the console to show the user what happened, but you can use this feature to wait until the user connects a device or warn the user when a device is disconnected; or you can at least update the list of connected devices without using a timer to refresh it.

Getting ready

Create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required