2012-05-01 2 views
0

방금 ​​openNi 라이브러리를 설치하고 내 컴퓨터에서 내 kinect를 작동 시켰습니다. 제 문제는 제가 C++로 프로그래밍하는 것입니다.openNi를 사용하기 시작할 때의 문제점

http://openni.org/Documentation/ProgrammerGuide.html

을 내 VisualStudio11 베타 프로젝트에 붙여 넣습니다

나는이 페이지에서 손 추적을위한 코드를 복사.

변수 xn이 정의되어 있지 않다는 것을 말하고 있지만 ... xn이 무엇인지는 알 수 없습니다.

코드에서 변수 xn을 정의하는 방법 또는 코드를 작성하기 위해 수행해야하는 작업을 알려주십시오.

실현

: 이, 코드입니다 내가

#define GESTURE_TO_USE "Click" 

xn::GestureGenerator g_GestureGenerator; 
xn::HandsGenerator g_HandsGenerator; 

void XN_CALLBACK_TYPE 
Gesture_Recognized(xn::GestureGenerator& generator, 
        const XnChar* strGesture, 
        const XnPoint3D* pIDPosition, 
        const XnPoint3D* pEndPosition, void* pCookie) 
{ 
    printf("Gesture recognized: %s\n", strGesture); 
    g_GestureGenerator.RemoveGesture(strGesture); 
    g_HandsGenerator.StartTracking(*pEndPosition); 
} 
void XN_CALLBACK_TYPE 
Gesture_Process(xn::GestureGenerator& generator, 
       const XnChar* strGesture, 
       const XnPoint3D* pPosition, 
       XnFloat fProgress, 
       void* pCookie) 
{} 

void XN_CALLBACK_TYPE 
Hand_Create(xn::HandsGenerator& generator, 
      XnUserID nId, const XnPoint3D* pPosition, 
      XnFloat fTime, void* pCookie) 
{ 
    printf("New Hand: %d @ (%f,%f,%f)\n", nId, 
     pPosition->X, pPosition->Y, pPosition->Z); 
} 
void XN_CALLBACK_TYPE 
Hand_Update(xn::HandsGenerator& generator, 
      XnUserID nId, const XnPoint3D* pPosition, 
      XnFloat fTime, void* pCookie) 
{ 
} 
void XN_CALLBACK_TYPE 
Hand_Destroy(xn::HandsGenerator& generator, 
      XnUserID nId, XnFloat fTime, 
      void* pCookie) 
{ 
    printf("Lost Hand: %d\n", nId); 
    g_GestureGenerator.AddGesture(GESTURE_TO_USE, NULL); 
} 

void main() 
{ 

    XnStatus nRetVal = XN_STATUS_OK; 

    Context context; 
    nRetVal = context.Init(); 
    // TODO: check error code 

    // Create the gesture and hands generators 
    nRetVal = g_GestureGenerator.Create(context); 
    nRetVal = g_HandsGenerator.Create(context); 
    // TODO: check error code 

    // Register to callbacks 
    XnCallbackHandle h1, h2; 
    g_GestureGenerator.RegisterGestureCallbacks(Gesture_Recognized, 
               Gesture_Process, 
               NULL, h1); 
    g_HandsGenerator.RegisterHandCallbacks(Hand_Create, Hand_Update, 
             Hand_Destroy, NULL, h2); 

    // Start generating 
    nRetVal = context.StartGeneratingAll(); 
    // TODO: check error code 

    nRetVal = g_GestureGenerator.AddGesture(GESTURE_TO_USE); 

    while (TRUE) 
    { 
    // Update to next frame 
    nRetVal = context.WaitAndUpdateAll(); 
    // TODO: check error code 
    } 

    // Clean up 
    context.Shutdown(); 
} 
+0

코드 – Flot2011

답변

1

xn 위에서 언급 한 페이지에서 네임 스페이스입니다.

적어도 하나의 헤더 파일을 포함해야하는 것처럼 보입니다. 추가 귀하의 파일의 상단에 다음과 같은

시도 :

#include <XnCppWrapper.h> 

다른 정의되지 않은 xn:: 클래스가있을 수 있습니다. 그렇다면 documentation을 사용하여 클래스를 식별하고 어떤 헤더 파일이 #include 일 필요가 있는지 확인하십시오.

+0

예, #include "XnCppWrapper.h"및 네임 스페이스 xn을 사용합니다. 충분해야합니다. user1367593 답변을 수락하거나 최소한 피드백을 주어야합니다. – StinkyCat

0

헤더 파일을 포함하지 않았으므로이 문제를 해결하려면 필요한 머리글을 모두 포함하는 다음 두 헤더 파일을 포함하면됩니다.

#include <XnOpenNI.h> 
#include <XnVNite.h> 

이러한 헤더만으로는 xn :: namespace가 필요하므로 문제가 해결되지 않습니다.

이 문제

중 하나가이 헤더 선언 후 코드에서 다음 줄을 포함하는 것입니다 해결하기 위해 각 선언

또는

전에 가장 쉬운 방법을 xn:: 마커를 사용하여 해결할 수 있습니다.

using namespace xn; 
관련 문제