When calling setSkeleton() function, you can know the position of each skeleton. When calling setAudio(true) function after setSkeleton(), you can identify the speaker by using the voice direction and the skeleton position.
The skeletonTrackingId fo the skeleton identified as a speaker is held in the "audioTrackingId" member variable. If the speaker is unknown, it will be negative. If the audiotTrackingId is equal to the skeletonTrackingId[index ], you can see that the skeleton[index ] is speaking.
type of return value | function name | descriptions | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
void | setSkeleton() | Recognize skeleton and set the data to the following member variables.
|
type | variable name | descriptions |
---|---|---|
vector<vector<Joint>> | skeleton | Vector of skeleton information. The set of a human joints is vector<Joint> , and this is the skeleton information. In order to handle multiple people, it is a vector of skeleton information, that is, vector<vector<Joint>> . The coordinates of the joint are positions in the CameraSpace coordinate system.
skelton[index ][jointType ].JointType == jointType holds, you can directly access the information of a specified joint of a specified skeleton. |
vector<int> | skeletonId | A vector of bodyIndex corresponding to the skeletons. The bodyIndex of skeleton[index ] is held at skeletonId[index ]. |
vector<UINT64> | skeletonTrackingId | A vector of trackingId corresponding to the skeletons. The trackingId fo skeleton[index ] is held at skeletonTrackingId[index ]. |
type of return value | function name | descriptions |
---|---|---|
void | setAudio(bool flag = false) |
Acquire audio and save it in a file during recording
|
void | drawAudioDirection(cv::Mat& image ) | Draw the direction of audio beam on image. |
bool | isOpenedAudio() | Returns whether or not recording is in progress. |
void | openAudio(string path ) | Open path as a recording file |
void | closeAudio() | Close the recording file. |
type | variable name | descriptions |
---|---|---|
float | beamAngle | Direction of audio (angle to the left and right) |
float | beamAngleConfidence | Confidence value of beamAngle (0.0 ... 1.0) |
UINT64 | audioTackingId | Speaker's skeletonTrackingId |
WaveFile.h should already have been added to the project.
Define USE_AUDIO constant before including NtKinect.h.
When calling setAudio(true) function after setSkeleton(), audio data is acquired by the array microphone and the direction is calculated, and the "skeletonTrackingId" of the skeleton whose direction matches is set to "audioTrackingId" variable.
main.cpp |
|
Joints are drawn in red rectangles, but the spkeaker's joints are drawn in green rectangles.
It is only for confirmation that the audio direction is displayed in another window, and the code of this part may be omitted.
Since the above zip file may not include the latest "NtKinect.h", Download the latest version from here and replace old one with it.