Reputation: 1
I just installed the openNi libraries and make my kinect work on my computer. My problem is that I'm just a nov programming in c++.
I copied the code for hand tracking from this page:
http://openni.org/Documentation/ProgrammerGuide.html
and paste it in my VisualStudio11 beta project.
It stays saying me that the variable xn is no defined... but i don't know what xn is.
If you could please tell me how to define de variable xn in the code, or what I have to do in order to make the code works.
ACTUALIZATION: this is the code, is in the page I mentioned above
#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();
}
Upvotes: 0
Views: 1589
Reputation: 1567
I see you have not included any header files, so to resolve this issue you just need to include the following two header files, which will include all the required headers as well.
#include <XnOpenNI.h>
#include <XnVNite.h>
Using these headers alone will not solve the problem, as you require the xn:: namespace.
This issue can be resolved by either using the xn::
marker before each declaration
or
The easiest way to resolve this is to include the following line in your code, after the header declaration.
using namespace xn;
Upvotes: 0
Reputation: 78418
xn
is a namespace.
It looks like you need to include at least one header file.
Try adding the following to the top of your file:
#include <XnCppWrapper.h>
There may be other undefined xn::
classes. If so, use the documentation to identify the classes, and check which header file needs to be #include
d.
Upvotes: 1