Unigine.Plugins.Kinect Class
This set of functions is available when the Kinect2 plugin is loaded. This plugin is used for receiving already detected data from a Kinect2 sensor.
If the plugin is loaded together with the engine, the HAS_KINECT definition is set. This definition can be used, for example, to avoid errors if the plugin is not loaded: the code in which the plugin functions are executed can be wrapped around as follows:
#ifdef HAS_KINECT
// kinect functions
#endif
The Unigine Kinect plugin works in the following way: when Kinect.IsBodyTracked(body) returns 0, Kinect.GetBonePosition(body, bone) will return vec3_zero. Kinect has its own framerate, so the body tracking information is not available each engine frame. Wrist tracking can be achieved via:
vec3 wrist;
int Update() {
if(Kinect.IsBodyTracked(0)) {
wrist = Kinect.GetBonePosition(0,KINECT.WRIST_LEFT);
}
Visualizer.RenderSphere(0.05f,translate(wrist),vec4_one);
return 1;
}
See Also#
- Article on Kinect2 Plugin
- A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/plugins/ folder:
- kinect_00
- kinect_01
- kinect_02
Kinect Class
Enums
FACE_PROPERTY#
FACE_POINT#
Name | Description |
---|---|
EYE_LEFT = 0 | The left eye. |
EYE_RIGHT = 1 | The right eye. |
NOSE = 2 | The nose. |
MOUTH_CORNER_LEFT = 3 | The left corner of the mouse. |
MOUTH_CORNER_RIGHT = 4 | The right corner of the mouse. |
FACE_DETECTION_RESULT#
BONE#
HAND_STATE#
TRACKING_CONFIDENCE#
TRACKING_STATE#
NUM#
STREAM#
Name | Description |
---|---|
COLOR = 1 | A color stream. If this constant isn't specified on sensor initialization, there will be no access to the color stream. |
INFRARED = 2 | An infrared stream. If this constant isn't specified on sensor initialization, there will be no access to the infrared stream. |
DEPTH = 8 | A depth stream. If this constant isn't specified on sensor initialization, there will be no access to the depth stream. |
BODY = 32 | A body. If this constant isn't specified on sensor initialization, bodies won't be tracked. |
ALL = 43 | The COLOR, INFRARED, DEPTH, BODY constants combined by using logical OR. |
Members
Kinect.TRACKING_STATE GetBodyLeanState ( int body ) #
Returns a value indicating whether the body with the given number was tracked as lean or not.Arguments
- int body - Body index in range [0;NUM_BODIES - 1 ].
Return value
One of the TRACKING_STATE_* constants specifying the tracking state. If the STREAM_BODY is not specified on sensor initialization, TRACKING_STATE_NOT_TRACKED will be returned.quat GetBoneOrientation ( int body, Kinect.BONE bone ) #
Returns orientation of the given bone of the given body relative to the parent bone.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
- Kinect.BONE bone - Bone number in range [0;NUM_BONES - 1 ].
Return value
Bone orientation relative to the parent bone. If the STREAM_BODY is not specified on sensor initialization, zero quat will be returned.vec3 GetBonePosition ( int body, Kinect.BONE bone ) #
Returns position of the given bone of the given body relative to the sensor.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
- Kinect.BONE bone - Bone number in range [0;NUM_BONES - 1 ].
Return value
Bone position relative to the sensor. If the STREAM_BODY is not specified on sensor initialization, zero vector will be returned.Kinect.TRACKING_STATE GetBoneState ( int body, Kinect.BONE bone ) #
Returns the current tracking state of the given bone of the given body.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
- Kinect.BONE bone - Bone number in range [0;NUM_BONES - 1 ].
Return value
One of the TRACKING_STATE_* constants specifying the tracking state. If the STREAM_BODY is not specified on sensor initialization, TRACKING_STATE_NOT_TRACKED will be returned.Image GetColorBuffer ( ) #
Returns an image representing the current color buffer in the RGBA8 format.Return value
An image representing the current color buffer. If the STREAM_COLOR is not specified on sensor initialization, NULL will be returned.Image GetDepthBuffer ( ) #
Returns an image representing the current depth buffer in the R16 format.Return value
An image representing the current depth buffer. If the STREAM_DEPTH is not specified on sensor initialization, NULL will be returned.ivec4 GetFaceBoundsInColorSpace ( int face ) #
Returns bounds of the given face relative to the size of the color buffer.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].
Return value
Face bounds in the format (Left,Top,Right,Bottom). If the STREAM_BODY is not specified on sensor initialization, zero vector will be returned.ivec4 GetFaceBoundsInInfraredSpace ( int face ) #
Returns bounds of the given face relative to the size of the infrared buffer.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].
Return value
Face bounds in the format (Left,Top,Right,Bottom). If the STREAM_BODY is not specified on sensor initialization, zero vector will be returned.quat GetFaceOrientation ( int face ) #
Returns orientation of the given face relative to the sensor.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].
Return value
Face orientation. If the STREAM_BODY is not specified on sensor initialization, zero quat will be returned.vec3 GetFacePointInColorSpace ( int face, Kinect.FACE_POINT point ) #
Returns coordinates of the given point on the given face relative to the size of the color buffer.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].
- Kinect.FACE_POINT point - Face point number in range [0;NUM_FACE_POINTS - 1 ].
Return value
Face point coordinates. If the STREAM_BODY is not specified on sensor initialization, zero vector will be returned.vec3 GetFacePointInInfraredSpace ( int face, Kinect.FACE_POINT point ) #
Returns coordinates of the given point on the given face relative to the size of the infrared buffer.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].
- Kinect.FACE_POINT point - Face point number in range [0;NUM_FACE_POINTS - 1 ].
Return value
Face point coordinates. If the STREAM_BODY is not specified on sensor initialization, zero vector will be returned.Kinect.FACE_DETECTION_RESULT GetFaceProperty ( int face, Kinect.FACE_PROPERTY property ) #
Returns a value indicating how accurate the property of the given face was tracked.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].
- Kinect.FACE_PROPERTY property - Face property number in range [0;NUM_FACE_PROPERTIES - 1 ].
Return value
One of the KINECT_FACE_DETECTION_RESULT_* constants. If The STREAM_BODY is not specified on sensor initialization, KINECT_FACE_DETECTION_RESULT_UNKNOWN will be returned.Image GetInfraredBuffer ( ) #
Returns an image representing the current infrared buffer in the R16 format.Return value
An image representing the current infrared buffer. If the STREAM_INFRARED is not specified on sensor initialization, NULL will be returned.Kinect.TRACKING_CONFIDENCE GetLeftHandConfidence ( int body ) #
Returns the confidence level for the tracked left hand of the given body.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
Return value
One of the TRACKING_CONFIDENCE_*. If The STREAM_BODY is not specified on sensor initialization, TRACKING_CONFIDENCE_LOW will be returned.Kinect.HAND_STATE GetLeftHandState ( int body ) #
Returns the current state of the left hand of the given body.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
Return value
One of the HAND_STATE_*. If The STREAM_BODY is not specified on sensor initialization, HAND_STATE_UNKNOWN will be returned.Kinect.TRACKING_CONFIDENCE GetRightHandConfidence ( int body ) #
Returns the confidence level for the tracked right hand of the given body.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
Return value
One of the TRACKING_CONFIDENCE_*. If The STREAM_BODY is not specified on sensor initialization, TRACKING_CONFIDENCE_LOW will be returned.Kinect.HAND_STATE GetRightHandState ( int body ) #
Returns the current state of the right hand of the given body.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
Return value
One of the HAND_STATE_*. If The STREAM_BODY is not specified on sensor initialization, HAND_STATE_UNKNOWN will be returned.int Init ( uint stream_flags ) #
Kinect2 sensor initialization. The STREAM_* constants specify which data streams should be initialized.Arguments
- uint stream_flags - A bit mask represented by one of or combination of the STREAM_* constants.
Return value
1 if the sensor was initialized successfully; otherwise, 0.Examples
For example, there will be access to the color and depth buffers if you initialize the sensor as follows:
engine.kinect.init(KINECT_STREAM_COLOR | KINECT_STREAM_DEPTH);
bool isBodyTracked ( int body ) #
Returns a value indicating if the body with the given number was tracked by the sensor.Arguments
- int body - Body number in range [0;NUM_BODIES - 1 ].
Return value
true if the body was tracked; otherwise, false. If the STREAM_BODY is not specified on sensor initialization, fals will be returned.bool isFaceTracked ( int face ) #
Returns a value indicating whether the face with the given number was tracked or not.Arguments
- int face - Face number in range [0;NUM_BODIES - 1 ].