Package org.openni
Class OpenNI
java.lang.Object
org.openni.OpenNI
The OpenNI class is a static entry point to the library. It is used by every OpenNI 2.0
application to initialize the SDK and drivers to enable creation of valid device objects.
It also defines a listener class and events that enable for event driven notification of device
connection, device disconnection, and device configuration changes.
In addition, it gives access to SDK version information and provides a function that allows you
to wait for data to become available on any one of a list of streams (as opposed to waiting for
data on one specific stream with functions provided by the VideoStream class)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
The OpenNI.DeviceConnectedListener interface provides a means of registering for, and responding to when a device is connected.static interface
The OpenNI.DeviceDisconnectedListener interface provides a means of registering for, and responding to when a device is disconnected.static interface
The OpenNI::DeviceStateChangedListener interface provides a means of registering for, and responding to when a device's state is changed. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addDeviceConnectedListener
(OpenNI.DeviceConnectedListener deviceListener) Add new device connected observer to OpenNI observers liststatic void
addDeviceDisconnectedListener
(OpenNI.DeviceDisconnectedListener deviceListener) Add new device connected observer to OpenNI observers liststatic void
addDeviceStateChangedListener
(OpenNI.DeviceStateChangedListener deviceListener) Add new device connected observer to OpenNI observers liststatic List<DeviceInfo>
Fills up an array ofDeviceInfo
DeviceInfo objects with devices that are available.static String
Retrieves the calling thread's last extended error information.static Version
This function return current OpenNI versionstatic void
Initialize the library.static void
removeDeviceConnectedListener
(OpenNI.DeviceConnectedListener deviceListener) Remove device connected observer to OpenNI observers liststatic void
removeDeviceDisconnectedListener
(OpenNI.DeviceDisconnectedListener deviceListener) Remove device connected observer to OpenNI observers liststatic void
removeDeviceStateChangedListener
(OpenNI.DeviceStateChangedListener deviceListener) Remove device state changed observer from OpenNI observers liststatic void
shutdown()
Stop using the library.static int
waitForAnyStream
(List<VideoStream> streams, int timeout) Wait for a new frame from any of the streams provided.
-
Field Details
-
TIMEOUT_FOREVER
public static final int TIMEOUT_FOREVER- See Also:
-
-
Constructor Details
-
OpenNI
public OpenNI()
-
-
Method Details
-
initialize
public static void initialize()Initialize the library. This will load all available drivers, and see which devices are available It is forbidden to call any other method in OpenNI before calling initialize(). -
shutdown
public static void shutdown()Stop using the library. Unload all drivers, close all streams and devices. Once shutdown() was called, no other calls to OpenNI is allowed. -
getVersion
This function return current OpenNI version- Returns:
- the version of OpenNI
-
getExtendedError
Retrieves the calling thread's last extended error information. The last extended error information is maintained on a per-thread basis. Multiple threads do not overwrite each others last extended error information. The extended error information is cleared on every call to an OpenNI method, so you should call this method immediately after a call to an OpenNI method which have failed.- Returns:
- OpenNI error String
-
enumerateDevices
Fills up an array ofDeviceInfo
DeviceInfo objects with devices that are available.- Returns:
- deviceInfoList An array to be filled with devices.
-
waitForAnyStream
Wait for a new frame from any of the streams provided. The function blocks until any of the streams has a new frame available, or the timeout has passed.- Parameters:
streams
- An list of streams to wait for.timeout
- A timeout before returning if no stream has new data. Default value isTIMEOUT_FOREVER
.- Returns:
- index of stream which received frame. In case it stop on timeout, function return -1.
- Throws:
TimeoutException
-
addDeviceConnectedListener
Add new device connected observer to OpenNI observers list- Parameters:
deviceListener
- object which implements DeviceConnectedListener.
-
removeDeviceConnectedListener
Remove device connected observer to OpenNI observers list- Parameters:
deviceListener
- object which implements DeviceConnectedListener.
-
addDeviceDisconnectedListener
Add new device connected observer to OpenNI observers list- Parameters:
deviceListener
- object which implements DeviceDisconnectedListener.
-
removeDeviceDisconnectedListener
public static void removeDeviceDisconnectedListener(OpenNI.DeviceDisconnectedListener deviceListener) Remove device connected observer to OpenNI observers list- Parameters:
deviceListener
- object which implements DeviceDisconnectedListener.
-
addDeviceStateChangedListener
Add new device connected observer to OpenNI observers list- Parameters:
deviceListener
- object which implements DeviceConnectedListener.
-
removeDeviceStateChangedListener
public static void removeDeviceStateChangedListener(OpenNI.DeviceStateChangedListener deviceListener) Remove device state changed observer from OpenNI observers list- Parameters:
deviceListener
- object which implements DeviceConnectedListener.
-