In NtKinect version or earlier, the position of the face parts could only be acquired as coordinates in the ColorSpace. However, in version1.3 or later, it can be acquired as coordinates in the DepthSpace.
type of return value | function name | descriptions | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
void | setFace() | version1.2 or earlier. After calling setSkeleton(), this function can be called to recognize human face. Values are set to the next member variables.
|
|||||||||||||||
void | setFace(bool isColorSpace = true) | version1.3 or later. After calling setSkeleton(), this function can be called to recognize human face. Values are set to the next member variables.
|
type | variable name | descriptions |
---|---|---|
vector<vector<PointF>> | facePoint | Face part positions. The position of one person's "left eye, right eye, nose, left end of mouth, right end of mouse" is represented with vector<PointF> . To handle multiple people's data, the type is vector<vector<PointF>> . (version1.2 or earlier) coordinates in ColorSpace. (version1.3 or after) coordinates in ColorSpace or DepthSpace. |
vector<cv::Rect> | faceRect | Vector of BoundingBox of face. (version 1.2 or earlier) coordinates in ColorSpace. (version1.3 or after) coordinates in ColorSpace or DepthSpace. |
vector<cv::Vec3f> | faceDirection | Vector of face direction (pitch, yaw, roll). |
vector<vector<DetectionResult>> | faceProperty | Face States. The state of one person's "happy, engaged, wearing glases, left eye closed, right eye closed, mouth open, mouth moved, looking away" is the vector<DetectionResult> . To handle multiple people, the data type is vector<vector<DetectionResult>> . |
vector<UINT64> | faceTrackingId |
version 1.4 or later. Vector of trackingId. The trackingId corresponding to face information faceRect[index ] is faceTrackingId[index ]. |
Since the position and resolution of each sensor is different, the data is obtained as a value expressed in the coordinate system of each sensor. When using data obtained from different sensors at the same time, it is necessary to convert the coordinates to match.
Kinect V2 has 3 coordinate systems, ColorSpace, DepthSpace, and CameraSpace. There are 3 data types ColorSpacePoint, DepthSpacePoint, and CameraSpacePoint representing coordinates in each coordinate system.
Quoted from Kinect.h of Kinect for Windows SDK 2.0 |
---|
typedef struct _ColorSpacePoint { float X; float Y; } ColorSpacePoint; typedef struct _DepthSpacePoint { float X; float Y; } DepthSpacePoint; typedef struct _CameraSpacePoint { float X; float Y; float Z; } CameraSpacePoint; |
For the RGB image, Depth image, and skeleton information, the coordinate system is different. The coordinate system of the RGB image is ColorSpace, that of the Depth image is DepthSpace, and that of the skeleton information is CameraSpace.
Coordinate system | type of coordinates | Captured Data |
---|---|---|
ColorSpace | ColorSpacePoint | RGB image |
DepthSpace | DepthSpacePoint | depth image, bodyIndex image, infrared image |
CameraSpace | CameraSpacePoint | skeleton information |
CameraSpace coordinate system representing skeleton position |
---|
The CameraSpace is a 3-dimensional coordinate system with the following features.
(2016/11/12 figure changed, and description added). |
"Coordinate system conversion function" held by ICoordinateMapper class of Kinect V2 is as follows.
type of return value | function name | descriptions |
---|---|---|
HRESULT | MapCameraPointToColorSpace( CameraSpacePoint sp , ColorSpacePoint *cp ) |
Convert the coordinates sp in the CameraSpace to the coordinates cp in the ColorSpace. Return value is S_OK or error code. |
HRESULT | MapCameraPointToDepthSpace( CameraSpacePoint sp , DelpthSpacePoint *dp ) |
Convert the coordinates sp in the CameraSpace to the coordinates dp in DepthSpace. Return value is S_OK or error code. |
HRESULT | MapDepthPointToColorSpace( DepthSpacePoint dp , UINT16 depth , ColorSpacePoint *cp ) |
Convert the coordinates dp in DepthSpace and distance depth to the coordinates cp in ColorSpace. Return value is S_OK or error code. |
HRESULT | MapDepthPointToCameraSpace( DepthSpacePoint dp , UINT16 depth , CameraSpacePoint *sp ) |
Convert the coordinates dp in DepthSpace and distance depth to the coordinates sp in CameraSpace. Return value is S_OK or error code. |
An instance of ICoordinateMapper class used for mapping coordinate systems in Kinect V2 is held in NtKinect's member variable "coordinateMapper".
type | variable name | descriptions |
---|---|---|
CComPtr<ICoordinateMapper> | coordinateMapper | An instance of ICoordinateMapper used for mapping coordinate systems. |
This project is set as follows.
Get the Depth image.
Since the value of each pixel of the Depth image is represented by CV_16UC1 (one unsigned int of 16 bitwidth), it is converted to an image that can be written in RGB color. Each pixel is converted to CV_8UC1 (one unsigned int of 8 bitwidth) once to become the maximum luminance (= 255) at 4500 mm distance, and converted to CV_8UC3 (three unsigned int of 8 bitwidth, BGR format).
The positions of the face parts are drawn above the Depth image.
main.cpp |
|
The positions of the face parts recognized are drawn as yellow rectangles above the Depth image.
In this example, each person's face orientation and states are displayed at the top of the screen.
At the upper left corner of the window, face orientation (pitch, yaw, roll) and recognized face properties are displayed.
Since the above zip file may not include the latest "NtKinect.h", Download the latest version from here and replace old one with it.