C# Class AForge.Video.Kinect.Kinect

The class provides access to Microsoft's Xbox Kinect controller.

The class allows to manipulate Kinec device by changing its LED color, setting motor's tilt value and accessing its camera. See KinectVideoCamera and KinectDepthCamera classes, which provide access to actual video.

In order to run correctly the class requires freenect.dll library to be put into solution's output folder. This can be found within the AForge.NET framework's distribution in Externals folder.

Sample usage:

// get Kinect device Kinect kinectDevice = Kinect.GetDevice( 0 ); // change LED color kinectDevice.LedColor = LedColorOption.Yellow; // set motor tilt angle to -10 degrees kinectDevice.SetMotorTilt( -10 ); // get video camera KinectVideoCamera videoCamera = kinectDevice.GetVideoCamera( ); // see example for video camera also
Inheritance: IDisposable
Show file Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Private Properties

Property Type Description
AddFailureHandler void
CheckDevice void
Dispose void
IsDeviceFailed bool
Kinect System
KinectStatusThread void
Kinect_OnError void
StartStatusThread void
StopStatusThread void

Public Methods

Method Description
Dispose ( ) : void

Dispose device freeing all associated unmanaged resources.

GetAccelerometerValues ( double &x, double &y, double &z ) : void

Get accelerometer values for 3 axes.

Units of all 3 values are m/s2. The g value used for calculations is taken as 9.80665 m/s2.

GetDepthCamera ( ) : KinectDepthCamera

Get Kinect's depth camera.

The method simply creates instance of the KinectDepthCamera class by calling its appropriate constructor. Use KinectDepthCamera.Start method to start the video then.

GetDevice ( int deviceID ) : Kinect

Get initialized instance of the Kinect device.

GetVideoCamera ( ) : KinectVideoCamera

Get Kinect's video camera.

The method simply creates instance of the KinectVideoCamera class by calling its appropriate constructor. Use KinectVideoCamera.Start method to start the video then.

SetLedColor ( LedColorOption ledColor ) : void

Set color of Kinect's LED.

SetMotorTilt ( int angle ) : void

Set motor's tilt value.

Private Methods

Method Description
AddFailureHandler ( int deviceID, DeviceFailureHandler handler ) : void
CheckDevice ( ) : void
Dispose ( bool disposing ) : void
IsDeviceFailed ( int deviceID ) : bool
Kinect ( IntPtr rawDevice, int deviceID ) : System
KinectStatusThread ( ) : void
Kinect_OnError ( IntPtr device ) : void
StartStatusThread ( ) : void
StopStatusThread ( ) : void

Method Details

Dispose() public method

Dispose device freeing all associated unmanaged resources.
public Dispose ( ) : void
return void

GetAccelerometerValues() public method

Get accelerometer values for 3 axes.

Units of all 3 values are m/s2. The g value used for calculations is taken as 9.80665 m/s2.

public GetAccelerometerValues ( double &x, double &y, double &z ) : void
x double X axis value on the accelerometer.
y double Y axis value on the accelerometer.
z double Z axis value on the accelerometer.
return void

GetDepthCamera() public method

Get Kinect's depth camera.

The method simply creates instance of the KinectDepthCamera class by calling its appropriate constructor. Use KinectDepthCamera.Start method to start the video then.

public GetDepthCamera ( ) : KinectDepthCamera
return KinectDepthCamera

GetDevice() public static method

Get initialized instance of the Kinect device.
There is no Kinect device with specified ID connected to the system. Failed connecting to the Kinect device specified ID.
public static GetDevice ( int deviceID ) : Kinect
deviceID int ID of the Kinect device to get instance of, [0, ),
return Kinect

GetVideoCamera() public method

Get Kinect's video camera.

The method simply creates instance of the KinectVideoCamera class by calling its appropriate constructor. Use KinectVideoCamera.Start method to start the video then.

public GetVideoCamera ( ) : KinectVideoCamera
return KinectVideoCamera

SetLedColor() public method

Set color of Kinect's LED.
Some error occurred with the device. Check error message.
public SetLedColor ( LedColorOption ledColor ) : void
ledColor LedColorOption LED color to set.
return void

SetMotorTilt() public method

Set motor's tilt value.
Motor tilt has to be in the [-31, 31] range. Some error occurred with the device. Check error message.
public SetMotorTilt ( int angle ) : void
angle int Tilt value to set, [-31, 30] degrees.
return void