Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kinect SDK Gesture::get_Name
#include <iostream>
#include <Kinect.VisualGestureBuilder.h>
#define SAFE_RELEASE(x) if( x != NULL ) { x->Release(); x = NULL; }
#define SAFE_RELEASE_ARRAY(s, a) for (UINT32 e = 0; e < s; e++) SAFE_RELEASE(a[e])
int main()
{
HRESULT result = S_OK;
/**
* Read the sample database provided with the Kinect for Windows v2 SDK.
* This database contains four gestures: Steer_Left, Steer_Right, SteerProgress, SteerStraight.
*/
IVisualGestureBuilderDatabase* database;
result = CreateVisualGestureBuilderDatabaseInstanceFromFile(TEXT("C:\\Program Files\\Microsoft SDKs\\Kinect\\v2.0_1409\\Tools\\KinectStudio\\databases\\SampleDatabase.gbd"), &database);
if (result != S_OK) {
std::cout << "Failed to create database\n";
return 1;
}
/**
* Next, read out the number of available gestures.
* This should be four, for our example database.
*/
UINT32 num_gestures;
result = database->get_AvailableGesturesCount(&num_gestures);
if (result != S_OK) {
std::cout << "Failed to get available gesture count\n";
SAFE_RELEASE(database);
return 1;
}
/**
* New up an array of IGesture pointers large enough to contain the contents of the database.
* We then copy in the contents.
*/
IGesture **gestures = new IGesture*[num_gestures];
result = database->get_AvailableGestures(num_gestures, gestures);
if (result != S_OK) {
std::cout << "Failed to get available gestures\n";
SAFE_RELEASE(database);
SAFE_RELEASE_ARRAY(num_gestures, gestures);
return 1;
}
/**
* And, lastly, for each gesture, try to read the name.
* IGesture::get_Name expects bufferSize to be >= MAX_PATH -- at least 260.
* That is, the maximum length of a file path, plus the drive letter, a colon, backslash and null terminator.
*/
const UINT32 gesture_name_length = MAX_PATH;
for (UINT32 i = 0; i < num_gestures; i++) {
wchar_t gesture_name[gesture_name_length];
result = gestures[i]->get_Name(gesture_name_length, gesture_name);
if (result != S_OK) {
std::cout << "Failed to read gesture name\n";
SAFE_RELEASE(database);
SAFE_RELEASE_ARRAY(num_gestures, gestures);
return 1;
}
std::wcout << TEXT("Gesture ") << i << TEXT(": ") << gesture_name << TEXT("\n");
}
return S_OK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment