我剛剛安裝了openNi庫,並使我的kinect工作在我的電腦上。 我的問題是,我只是一個在C++中的nov編程。問題開始使用openNi
我複製了專人跟蹤代碼從這個頁面:
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: %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();
}
我們展示您的代碼 – Flot2011