Package org.openni

# Class OpenNI

java.lang.Object
org.openni.OpenNI

public class OpenNI extends Object
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 Classes
Modifier and Type
Class
Description
`static interface`
`OpenNI.DeviceConnectedListener`
The OpenNI.DeviceConnectedListener interface provides a means of registering for, and responding to when a device is connected.
`static interface`
`OpenNI.DeviceDisconnectedListener`
The OpenNI.DeviceDisconnectedListener interface provides a means of registering for, and responding to when a device is disconnected.
`static interface`
`OpenNI.DeviceStateChangedListener`
The OpenNI::DeviceStateChangedListener interface provides a means of registering for, and responding to when a device's state is changed.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`TIMEOUT_FOREVER`

## Constructor Summary

Constructors
Constructor
Description
`OpenNI()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`addDeviceConnectedListener(OpenNI.DeviceConnectedListener deviceListener)`
Add new device connected observer to OpenNI observers list
`static void`
`addDeviceDisconnectedListener(OpenNI.DeviceDisconnectedListener deviceListener)`
Add new device connected observer to OpenNI observers list
`static void`
`addDeviceStateChangedListener(OpenNI.DeviceStateChangedListener deviceListener)`
Add new device connected observer to OpenNI observers list
`static List<DeviceInfo>`
`enumerateDevices()`
Fills up an array of `DeviceInfo` DeviceInfo objects with devices that are available.
`static String`
`getExtendedError()`
Retrieves the calling thread's last extended error information.
`static Version`
`getVersion()`
This function return current OpenNI version
`static void`
`initialize()`
Initialize the library.
`static void`
`removeDeviceConnectedListener(OpenNI.DeviceConnectedListener deviceListener)`
Remove device connected observer to OpenNI observers list
`static void`
`removeDeviceDisconnectedListener(OpenNI.DeviceDisconnectedListener deviceListener)`
Remove device connected observer to OpenNI observers list
`static void`
`removeDeviceStateChangedListener(OpenNI.DeviceStateChangedListener deviceListener)`
Remove device state changed observer from OpenNI observers list
`static 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### TIMEOUT_FOREVER

public static final int TIMEOUT_FOREVER

See Also:
  - Constant Field Values

## 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

public static Version getVersion()
This function return current OpenNI version

Returns:
  the version of OpenNI

### getExtendedError

public static String 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

public static List<DeviceInfo> enumerateDevices()
Fills up an array of `DeviceInfo` DeviceInfo objects with devices that are available.

Returns:
  deviceInfoList An array to be filled with devices.

### waitForAnyStream

public static int waitForAnyStream(List<VideoStream> streams, int timeout) throws TimeoutException
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 is `TIMEOUT_FOREVER`.
Returns:
  index of stream which received frame. In case it stop on timeout, function return -1.
Throws:
  `TimeoutException`

### addDeviceConnectedListener

public static void addDeviceConnectedListener(OpenNI.DeviceConnectedListener deviceListener)
Add new device connected observer to OpenNI observers list

Parameters:
  `deviceListener` - object which implements DeviceConnectedListener.

### removeDeviceConnectedListener

public static void removeDeviceConnectedListener(OpenNI.DeviceConnectedListener deviceListener)
Remove device connected observer to OpenNI observers list

Parameters:
  `deviceListener` - object which implements DeviceConnectedListener.

### addDeviceDisconnectedListener

public static void addDeviceDisconnectedListener(OpenNI.DeviceDisconnectedListener deviceListener)
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

public static void addDeviceStateChangedListener(OpenNI.DeviceStateChangedListener deviceListener)
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.