This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Plugins::Kinect Class

Header: #include <plugins/UnigineKinect.h>

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.

Notice
Kinect SDK 2.0+ must be installed on your computer.

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:

Source code (UnigineScript)
#ifdef HAS_KINECT
	// engine.kinect functions
#endif

The Unigine Kinect plugin works in the foolowing way: when engine.kinect.isBodyTracked(body) returns 0, engine.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:

Source code (UnigineScript)
vec3 wrist;

int update() {
    if(engine.kinect.isBodyTracked(0)) {
        wrist = engine.kinect.getBonePosition(0,KINECT_BONE_WRIST_LEFT);
    }
    engine.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

Members


int getBodyLeanState ( int body ) #

Returns a value indicating whether the body with the given number was tracked as lean or not.

Arguments

Return value

One of the KINECT_TRACKING_STATE_* constants specifying the tracking state. If the KINECT_STREAM_BODY is not specified on sensor initialization, KINECT_TRACKING_STATE_NOT_TRACKED will be returned.

quat getBoneOrientation ( int body, int bone ) #

Returns orientation of the given bone of the given body relative to the parent bone.

Arguments

Return value

Bone orientation relative to the parent bone. If the KINECT_STREAM_BODY is not specified on sensor initialization, zero quat will be returned.

vec3 getBonePosition ( int body, int bone ) #

Returns position of the given bone of the given body relative to the sensor.

Arguments

Return value

Bone position relative to the sensor. If the KINECT_STREAM_BODY is not specified on sensor initialization, zero vector will be returned.

int getBoneState ( int body, int bone ) #

Returns the current tracking state of the given bone of the given body.

Arguments

Return value

One of the KINECT_TRACKING_STATE_* constants specifying the tracking state. If the KINECT_STREAM_BODY is not specified on sensor initialization, KINECT_TRACKING_STATE_NOT_TRACKED will be returned.

Image getColorBuffer ( ) #

Returns an image representing the current color buffer in the RGBA8 format.
Notice
The image in the color buffer is deleted each frame. However, the data isn't sent to the buffer each frame, so the function may return NULL.

Return value

An image representing the current color buffer. If the KINECT_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.
Notice
The image in the depth buffer is deleted each frame. However, the data isn't sent to the buffer each frame, so the function may return NULL.

Return value

An image representing the current depth buffer. If the KINECT_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

Return value

Face bounds in the format (Left,Top,Right,Bottom). If the KINECT_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

Return value

Face bounds in the format (Left,Top,Right,Bottom). If the KINECT_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

Return value

Face orientation. If the KINECT_STREAM_BODY is not specified on sensor initialization, zero quat will be returned.

vec3 getFacePointInColorSpace ( int face, int point ) #

Returns coordinates of the given point on the given face relative to the size of the color buffer.
Notice
Only X and Y components of the returned vector are used, Z component should be ignored.

Arguments

Return value

Face point coordinates. If the KINECT_STREAM_BODY is not specified on sensor initialization, zero vector will be returned.

vec3 getFacePointInInfraredSpace ( int face, int point ) #

Returns coordinates of the given point on the given face relative to the size of the infrared buffer.
Notice
Only X and Y components of the returned vector are used, Z component should be ignored.

Arguments

Return value

Face point coordinates. If the KINECT_STREAM_BODY is not specified on sensor initialization, zero vector will be returned.

int getFaceProperty ( int face, int property ) #

Returns a value indicating how accurate the property of the given face was tracked.

Arguments

Return value

One of the KINECT_FACE_DETECTION_RESULT_* constants. If The KINECT_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.
Notice
The image in the infrared buffer is deleted each frame. However, the data isn't sent to the buffer each frame, so the function may return NULL.

Return value

An image representing the current infrared buffer. If the KINECT_STREAM_INFRARED is not specified on sensor initialization, NULL will be returned.

int getLeftHandConfidence ( int body ) #

Returns the confidence level for the tracked left hand of the given body.

Arguments

Return value

One of the KINECT_TRACKING_CONFIDENCE_*. If The KINECT_STREAM_BODY is not specified on sensor initialization, KINECT_TRACKING_CONFIDENCE_LOW will be returned.

int getLeftHandState ( int body ) #

Returns the current state of the left hand of the given body.

Arguments

Return value

One of the KINECT_HAND_STATE_*. If The KINECT_STREAM_BODY is not specified on sensor initialization, KINECT_HAND_STATE_UNKNOWN will be returned.

int getRightHandConfidence ( int body ) #

Returns the confidence level for the tracked right hand of the given body.

Arguments

Return value

One of the KINECT_TRACKING_CONFIDENCE_*. If The KINECT_STREAM_BODY is not specified on sensor initialization, KINECT_TRACKING_CONFIDENCE_LOW will be returned.

int getRightHandState ( int body ) #

Returns the current state of the right hand of the given body.

Arguments

Return value

One of the KINECT_HAND_STATE_*. If The KINECT_STREAM_BODY is not specified on sensor initialization, KINECT_HAND_STATE_UNKNOWN will be returned.

int init ( int flags ) #

Kinect2 sensor initialization. The KINECT_STREAM_* constants specify which data streams should be initialized.

Arguments

  • int flags - A bit mask represented by one of or combination of the KINECT_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:

Source code (UnigineScript)
engine.kinect.init(KINECT_STREAM_COLOR | KINECT_STREAM_DEPTH);

int isBodyTracked ( int body ) #

Returns a value indicating if the body with the given number was tracked by the sensor.

Arguments

Return value

1 if the body was tracked; otherwise, 0. If the KINECT_STREAM_BODY is not specified on sensor initialization, 0 will be returned.

int isFaceTracked ( int face ) #

Returns a value indicating whether the face with the given number was tracked or not.

Arguments

Return value

1 if the given face is tracked; otherwise, 0. If the KINECT_STREAM_BODY is not specified on sensor initialization, 0 will be returned.

void shutdown ( ) #

Kinect2 sensor shutdown.
Last update: 2019-12-25
Build: ()