-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjknect.cpp
More file actions
executable file
·69 lines (60 loc) · 2.71 KB
/
jknect.cpp
File metadata and controls
executable file
·69 lines (60 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "jknect.h"
SimpleKinect::SimpleKinect(const std::string xmldir): nRetVal(XN_STATUS_OK), fn(NULL)
{
//Import Configuration file:
if (fileExists(xmldir.c_str()))
fn = xmldir.c_str();
else
throw std::exception("No config file found.");
nRetVal = g_Context.InitFromXmlFile(fn, g_scriptNode, &errors);
if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
{
XnChar strError[1024];
errors.ToString(strError, 1024);
throw std::exception(strError);
}
else if (nRetVal != XN_STATUS_OK)
{
throw std::exception(xnGetStatusString(nRetVal));
}
}
SimpleKSkeleton::SimpleKSkeleton(const std::string xmldir): SimpleKinect(xmldir)
{
g_strPose[0] = XnChar("");
g_bNeedPose = false;
//Activate Depth and skeleton tracking
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
//checkrc("No depth");
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
if (nRetVal != XN_STATUS_OK)
{
nRetVal = g_UserGenerator.Create(g_Context);
//checkrc("Find user generator");
}
XnCallbackHandle hUserCallbacks, hCalibrationStart, hCalibrationComplete, hPoseDetected;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON)){
printf("Supplied user generator doesn't support skeleton\n");
//FIXMEreturn 1;
}
nRetVal = g_UserGenerator.RegisterUserCallbacks(&SimpleKSkeleton::User_NewUser, &SimpleKSkeleton::User_LostUser, NULL, hUserCallbacks);
//CHECK_RC(nRetVal, "Register to user callbacks");
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationStart(UserCalibration_CalibrationStart, NULL, hCalibrationStart);
//CHECK_RC(nRetVal, "Register to calibration start");
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationComplete(UserCalibration_CalibrationComplete, NULL, hCalibrationComplete);
//CHECK_RC(nRetVal, "Register to calibration complete");
if (g_UserGenerator.GetSkeletonCap().NeedPoseForCalibration())
{
g_bNeedPose = TRUE;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION))
{
printf("Pose required, but not supported\n");
//FIXMEreturn 1;
}
nRetVal = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseDetected(UserPose_PoseDetected, NULL, hPoseDetected);
//CHECK_RC(nRetVal, "Register to Pose Detected");
g_UserGenerator.GetSkeletonCap().GetCalibrationPose(g_strPose);
}
g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
nRetVal = g_Context.StartGeneratingAll();
//CHECK_RC(nRetVal, "StartGenerating");
}