Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 开始使用openNi时遇到的问题_C++_Kinect_Openni - Fatal编程技术网

C++ 开始使用openNi时遇到的问题

C++ 开始使用openNi时遇到的问题,c++,kinect,openni,C++,Kinect,Openni,我刚刚安装了openNi库,并使我的kinect在我的计算机上工作。 我的问题是我只是C++中的一个NOV编程。 我从本页复制了手动跟踪代码: 并将其粘贴到我的VisualStudio11测试版项目中 它一直在告诉我变量xn没有定义。。。但我不知道xn是什么 如果您能告诉我如何在代码中定义de variable xn,或者我必须做什么才能使代码正常工作 实施: 这是代码,在我上面提到的页面中 #define GESTURE_TO_USE "Click" xn::GestureGenerato

我刚刚安装了openNi库,并使我的kinect在我的计算机上工作。 我的问题是我只是C++中的一个NOV编程。 我从本页复制了手动跟踪代码:

并将其粘贴到我的VisualStudio11测试版项目中

它一直在告诉我变量xn没有定义。。。但我不知道xn是什么

如果您能告诉我如何在代码中定义de variable 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();
}

xn
是一个名称空间

看起来您至少需要包含一个头文件

尝试将以下内容添加到文件顶部:

#include <XnCppWrapper.h>
#包括

可能还有其他未定义的
xn::
类。如果是这样,请使用来标识类,并检查哪些头文件需要
#include
d.

我看到您没有包含任何头文件,因此要解决此问题,您只需要包含以下两个头文件,其中也将包含所有必需的头文件

#include <XnOpenNI.h>
#include <XnVNite.h>
是的,我相信#包括“XnCppWrapper.h”并使用名称空间xn;应该足够了。用户1367593您应该接受答案或至少给出一些反馈。
using namespace xn;