簡単なコンソール サンプルです。
サンプルの説明:Nuitrack コンソール サンプル
#include <nuitrack/Nuitrack.h>
#include <iomanip>
#include <iostream>
using namespace tdv::nuitrack;
void showHelpInfo()
{
std::cout << "Usage: nuitrack_console_sample [path/to/nuitrack.config]" << std::endl;
}
void onHandUpdate(HandTrackerData::Ptr handData)
{
if (!handData)
{
std::cout << "No hand data" << std::endl;
return;
}
auto userHands = handData->getUsersHands();
if (userHands.empty())
{
return;
}
auto rightHand = userHands[0].rightHand;
if (!rightHand)
{
std::cout << "Right hand of the first user is not found" << std::endl;
return;
}
std::cout << std::fixed << std::setprecision(3);
std::cout << "Right hand position:"
"x = " << rightHand->xReal << ", "
"y = " << rightHand->yReal << ", "
"z = " << rightHand->zReal << std::endl;
}
int main(int argc, char* argv[])
{
showHelpInfo();
std::string configPath = "";
if (argc > 1)
configPath = argv[1];
try
{
}
{
std::cerr <<
"Can not initialize Nuitrack (ExceptionType:" << e.
type() <<
")" << std::endl;
return EXIT_FAILURE;
}
handTracker->connectOnUpdate(onHandUpdate);
try
{
}
{
std::cerr <<
"Can not start Nuitrack (ExceptionType:" << e.
type() <<
")" << std::endl;
return EXIT_FAILURE;
}
int errorCode = EXIT_SUCCESS;
while (true)
{
try
{
}
{
std::cerr <<
"LicenseNotAcquired exception (ExceptionType:" << e.
type() <<
")" << std::endl;
errorCode = EXIT_FAILURE;
break;
}
{
std::cerr <<
"Nuitrack update failed (ExceptionType:" << e.
type() <<
")" << std::endl;
errorCode = EXIT_FAILURE;
}
}
try
{
}
{
std::cerr <<
"Nuitrack release failed (ExceptionType:" << e.
type() <<
")" << std::endl;
errorCode = EXIT_FAILURE;
}
return errorCode;
}