If you define USE_FACE constant before including NtKinect.h, the functions and variables of NtKinect for Face and HDFace Recogninition become effective.
In HDFace Recognition, the position of the recognized face part may be slightly misaligned in a state where individual's face model is not created. In this state, even if parts of the face are cut out based on the information of HDFace, correnct partial images of RGB image can not be obtained.
On the other hand, in "normal Face recognition that is not HDFace", you can only get the position of left eye, right eye, nose, left edge of mouse, and right edge of mouse, but it seems that you can get quite accurate data. Therefore, it comes up with an idea to correct the data of HDFace Recognition with normal Face Recognition.
In this article, we explain how to correct the HDFace data with normal Face Recognition data.
We show the program that generates a image doubled with eyes vertically and horizontally, namely quadrupled by area. When cutting out the eye image, the eye size of HDFace data is used as it is, but eye position is corrected with the data obtained by Face recognition.
[Notice] In order to use "Face Recognition" data and "HDFace Recognition" data together, it is necessary to confirm that it is data on the same person with
faceTrackingId[i] == hdfaceTrackingId[j].
In Kinect for Windows SDK 2.0, face recognition is defined as follows.
Quoted from Kinect.Face.h of Kinect for Windows SDK 2.0 |
---|
enum _FacePointType { FacePointType_None= -1, FacePointType_EyeLeft= 0, FacePointType_EyeRight= 1, FacePointType_Nose= 2, FacePointType_MouthCornerLeft= 3, FacePointType_MouthCornerRight= 4, FacePointType_Count= ( FacePointType_MouthCornerRight + 1 ) }; enum _FaceProperty { FaceProperty_Happy= 0, FaceProperty_Engaged= 1, FaceProperty_WearingGlasses= 2, FaceProperty_LeftEyeClosed= 3, FaceProperty_RightEyeClosed= 4, FaceProperty_MouthOpen= 5, FaceProperty_MouthMoved= 6, FaceProperty_LookingAway= 7, FaceProperty_Count= ( FaceProperty_LookingAway + 1 ) }; |
Quoted from Kinect.h of Kinect for Windows SDK 2.0 |
---|
enum _DetectionResult { DetectionResult_Unknown= 0, DetectionResult_No= 1, DetectionResult_Maybe= 2, DetectionResult_Yes= 3 }; |
Quoted from Kinect.h of Kinect for Windows SDK 2.0 |
---|
typedef struct _PointF { float X; float Y; } PointF; |
After calling setSkeleton() function to recognize skeleton, call setFace() function to recognize face.
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 ]. |
Detailed face information (HDFace) can be recognized.
After calling setSkeleton() funtion to recognize skeleton, call setHDFace() function to recognize HDFace.
type of return value | function name | descriptions | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
void | setHDFace() | version1.4 or later. After calling setSkeleton() function, this function can be called to recognize the detailed face information (HDFace). Values are set to the following member variables.
|
||||||||||||
pair<string,string> | hdfaceStatusToString(pair<int,int>) | version1.4 or later. hdfaceStatus[index ] is the collection status of data required to create a face model. When it is passed to this function, the pair of state string is returned. |
||||||||||||
bool | setHDFaceModelFlag(bool flag=false) | version1.8 or later. This function set the internal flag to generate individual's face model at a time when data for creating a face model is sufficiently collected. The default value is false, and individual's face model will not be generated. If you call the setHDFace() function multiple times after calling this function with argument "true", individual face models will be generated at an appropriate timing. Individual's face model is expected to increase the precision of detailed face (HDFace) recognition. Since the program may become unstable, this function is treated experimentally. |
type | variable name | descriptions | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
vector<vector<CameraSpacePoint>> | hdfaceVertices | version1.4 or later. Position of face parts in CameraSpace coordinate system. A vector<CameraSpacePoint> holds the position of 1347 points on one human's face. To handle multiple people, the type of this variable is vector<vector<CameraSpacePoint>> . |
||||||||||||||||||||||||||||||||
vector<UINT64> | hdfaceTrackingId | version1.4 or after. vector of trackingId. hdfaceTrackingId[index ] corresponds to hdfaceVertices[index ]. |
||||||||||||||||||||||||||||||||
vector<pair<int,int>> | hdfaceStatus | version1.4 or later. state of face recognition. The state of HDFace recognition for one person is a pair of FaceModelBuilderCollectionStatus and FaceModelBuilderCaptureStatus, and is expressed as pair<int,int> . To handle multiple people, the type of this variable is vector<pair<int,int>> . FaceModelBuilderCollectionStatusThe value is OR of the next states.
FaceModelBuilderCaptureStatusThe value is one of the following.
|
This project is set as follows.
The blue letter patrt is related to the contents of this time, please read and understand well. The green letter part is related to the display of the "work" window, it can be deleted after execution is confirmed.
main.cpp |
|
Two windows are displayed. One of them named "work" shows the recognition state, and the other named "result" shows the image with enlarged eyes.
The "work" windows shows the following information.
The RGB image in the blue rectanglar area of "work" window is cut out, magnified twice in the vertical and horizontal directions (the area is enlarged by a factor of 4), and paseted to the original. In the "result" window, the result image is displayed. Before pasting the image of the enlarged eyes, if you reduce the alpha value of the peripheral area and blend images so as to reflect it, you can get a natural synthetic image. However, in forder to make the explanation easy to understand, such a processing is omitted in the above program.
work window (part) | result window (part) |
---|
Since the above zip file may not include the latest "NtKinect.h", Download the latest version from here and replace old one with it.