开始使用 openNi 的问题
Problems to start using openNi
我刚刚安装了openNi库,让我的kinect在我的电脑上工作。我的问题是我只是一个 c++ 的 nov 编程。
我从此页面复制了手部跟踪的代码:
http://openni.org/Documentation/ProgrammerGuide.html
并将其粘贴到我的 VisualStudio11 测试版项目中。
它一直说我变量 xn 没有定义......但我不知道XN是什么。
如果你能告诉我如何在代码中定义 de 变量 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: %sn", 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: %dn", 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
哪个头文件。
我看到您没有包含任何头文件,因此要解决此问题,您只需要包含以下两个头文件,其中还将包含所有必需的头文件。
#include <XnOpenNI.h>
#include <XnVNite.h>
单独使用这些标头并不能解决问题,因为您需要 xn:: 命名空间。
可以通过在每个声明之前使用 xn::
标记来解决此问题
或
解决此问题的最简单方法是在代码中标头声明之后包含以下行。
using namespace xn;
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 一个关于在C++中重载布尔运算符的问题
- 首要问题的答案让值班员搞错了
- setlocale的C++土耳其字符串问题
- 如何重构类层次结构以避免菱形问题
- 基于boost的程序的静态链接——zlib问题
- 开始使用 openNi 的问题
- 微软Kinect - openNI手生成器问题