방금 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();
}
코드 – Flot2011