Mercurial > hg > Game > Kinect
comparison main.cc @ 2:3b5465899da9
add KinectTrack.cc
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 01 Feb 2011 03:01:22 +0900 |
parents | 2afd5c6cc8d2 |
children | 7e112b536f0a |
comparison
equal
deleted
inserted
replaced
1:2afd5c6cc8d2 | 2:3b5465899da9 |
---|---|
20 printf("%s\n", strError); | 20 printf("%s\n", strError); |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 SessionState NIState::gSessionState = NOT_IN_SESSION; | 24 SessionState NIState::gSessionState = NOT_IN_SESSION; |
25 XnBool NIState::gBDrawDepthMap = true; | |
25 void NIState::XN_CALLBACK_TYPE sessionStarting(const XnPoint3D &ptPosition, void *userCxt) { | 26 void NIState::XN_CALLBACK_TYPE sessionStarting(const XnPoint3D &ptPosition, void *userCxt) { |
26 printf("Session start: (%f, %f, %f)\n)", ptPosition.X, ptPosition.Y, ptPosition.Z); | 27 printf("Session start: (%f, %f, %f)\n)", ptPosition.X, ptPosition.Y, ptPosition.Z); |
27 gSessionState = IN_SESSION; | 28 gSessionState = IN_SESSION; |
28 } | 29 } |
29 void NIState::XN_CALLBACK_TYPE sessionEnding(void *userCxt) { | 30 void NIState::XN_CALLBACK_TYPE sessionEnding(void *userCxt) { |
31 gSessionState = NOT_IN_SESSION; | 32 gSessionState = NOT_IN_SESSION; |
32 } | 33 } |
33 void NIState::XN_CALLBACK_TYPE focusProgress(const XnChar *strFocus, const XnPoint3D &ptPosition, | 34 void NIState::XN_CALLBACK_TYPE focusProgress(const XnChar *strFocus, const XnPoint3D &ptPosition, |
34 XnFloat fProgress, void *userCxt) { | 35 XnFloat fProgress, void *userCxt) { |
35 //printf("Focus progress: %s @(%f, %f, %f): %f\n)", strFocus, ptPosition.X, ptPosition.Y, ptPosition.Z, fProgress); | 36 //printf("Focus progress: %s @(%f, %f, %f): %f\n)", strFocus, ptPosition.X, ptPosition.Y, ptPosition.Z, fProgress); |
37 } | |
38 void NIState::XN_CALLBACK_TYPE noHands(void *UserCxt) { | |
39 if (gSessionState != NOT_IN_SESSION) { | |
40 printf("Quick refocus\n"); | |
41 gSessionState = QUICK_REFOCUS; | |
42 } | |
36 } | 43 } |
37 | 44 |
38 int main(int argc, char *argv[]) { | 45 int main(int argc, char *argv[]) { |
39 xn::Context gContext; | 46 xn::Context gContext; |
40 xn::EnumerationErrors errors; | 47 xn::EnumerationErrors errors; |
50 rc = gContext.FindExistingNode(XN_NODE_TYPE_HANDS, gHandsGenerator); | 57 rc = gContext.FindExistingNode(XN_NODE_TYPE_HANDS, gHandsGenerator); |
51 checkRC(rc, "Find hands generator"); | 58 checkRC(rc, "Find hands generator"); |
52 XnVSessionManager *gPSessionManager = new XnVSessionManager(); | 59 XnVSessionManager *gPSessionManager = new XnVSessionManager(); |
53 rc = gPSessionManager->Initialize(&gContext, "Click,Wave", "RaiseHand"); | 60 rc = gPSessionManager->Initialize(&gContext, "Click,Wave", "RaiseHand"); |
54 checkRC(rc, "SessionManager::Initialize"); | 61 checkRC(rc, "SessionManager::Initialize"); |
62 | |
55 gPSessionManager->RegisterSession(NULL, NIState::sessionStarting, NIState::sessionEnding, NIState::focusProgress); | 63 gPSessionManager->RegisterSession(NULL, NIState::sessionStarting, NIState::sessionEnding, NIState::focusProgress); |
64 | |
65 XnVPointDrawer *gPDrawer = new XnVPointDrawer(20, gDepthGenerator); | |
66 XnVFlowRouter *gPFlowRouter = new XnVFlowRouter; | |
67 gPFlowRouter->SetActive(gPDrawer); | |
68 | |
69 gPSessionManager->AddListener(gPFlowRouter); | |
70 | |
71 gPDrawer->RegisterNoPoints(NULL, NIState::noHands); | |
72 gPDrawer->setDepthMap(NIState::gBDrawDepthMap); | |
56 | 73 |
74 rc = gContext.StartGeneratingAll(); | |
75 checkRC(rc, "StartGenerating"); | |
76 | |
77 while (true) { | |
78 usleep(100); | |
79 } | |
80 | |
57 return 0; | 81 return 0; |
58 } | 82 } |