Mercurial > hg > Game > Kinect
diff 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 |
line wrap: on
line diff
--- a/main.cc Mon Jan 31 03:49:24 2011 +0900 +++ b/main.cc Tue Feb 01 03:01:22 2011 +0900 @@ -22,6 +22,7 @@ } SessionState NIState::gSessionState = NOT_IN_SESSION; +XnBool NIState::gBDrawDepthMap = true; void NIState::XN_CALLBACK_TYPE sessionStarting(const XnPoint3D &ptPosition, void *userCxt) { printf("Session start: (%f, %f, %f)\n)", ptPosition.X, ptPosition.Y, ptPosition.Z); gSessionState = IN_SESSION; @@ -34,6 +35,12 @@ XnFloat fProgress, void *userCxt) { //printf("Focus progress: %s @(%f, %f, %f): %f\n)", strFocus, ptPosition.X, ptPosition.Y, ptPosition.Z, fProgress); } +void NIState::XN_CALLBACK_TYPE noHands(void *UserCxt) { + if (gSessionState != NOT_IN_SESSION) { + printf("Quick refocus\n"); + gSessionState = QUICK_REFOCUS; + } +} int main(int argc, char *argv[]) { xn::Context gContext; @@ -52,7 +59,24 @@ XnVSessionManager *gPSessionManager = new XnVSessionManager(); rc = gPSessionManager->Initialize(&gContext, "Click,Wave", "RaiseHand"); checkRC(rc, "SessionManager::Initialize"); + gPSessionManager->RegisterSession(NULL, NIState::sessionStarting, NIState::sessionEnding, NIState::focusProgress); + + XnVPointDrawer *gPDrawer = new XnVPointDrawer(20, gDepthGenerator); + XnVFlowRouter *gPFlowRouter = new XnVFlowRouter; + gPFlowRouter->SetActive(gPDrawer); + + gPSessionManager->AddListener(gPFlowRouter); + + gPDrawer->RegisterNoPoints(NULL, NIState::noHands); + gPDrawer->setDepthMap(NIState::gBDrawDepthMap); + rc = gContext.StartGeneratingAll(); + checkRC(rc, "StartGenerating"); + + while (true) { + usleep(100); + } + return 0; }