求大神解答!!!! 急 急 急!!!!!!
kinect吧
全部回复
仅看楼主
level 4
编译成功 运行有个这错误 这是为什么呢 百思不得其解 求大神帮忙(我还是菜鸟)I
2013年09月15日 11点09分 1
level 4
点击调试程序后 出现这个错误
2013年09月15日 11点09分 3
level 4
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <XnCppWrapper.h>
#include <XnModuleCppInterface.h>
#include "cv.h" #include "highgui.h"
using namespace std;
using namespace cv;
xn::UserGenerator userGenerator;
xn::DepthGenerator depthGenerator;
xn::ImageGenerator imageGenerator;
//a line will be drawn between start point and corresponding end point
int startSkelPoints[14]={1,2,9,6,12,17,6,7,12,13,17,18,21,22};
int endSkelPoints[14]={2,3,7,3,3,21,7,9,13,15,18,20,22,24};
// callback function of user generator: new user
void XN_CALLBACK_TYPE NewUser( xn::UserGenerator& generator, XnUserID user,void* pCookie )
{ cout << "New user identified: " << user << endl;
//userGenerator.GetSkeletonCap().LoadCalibrationDataFromFile( user, "UserCalibration.txt" );
generator.GetPoseDetectionCap().StartPoseDetection("Psi", user); }
// callback function of user generator: lost user
void XN_CALLBACK_TYPE LostUser( xn::UserGenerator& generator, XnUserID user,void* pCookie )
{ cout << "User " << user << " lost" << endl; }
// callback function of skeleton: calibration start
void XN_CALLBACK_TYPE CalibrationStart( xn::SkeletonCapability& skeleton,XnUserID user,void* pCookie )
{ cout << "Calibration start for user " << user << endl; }
// callback function of skeleton: calibration end
void XN_CALLBACK_TYPE CalibrationEnd( xn::SkeletonCapability& skeleton,XnUserID user,XnCalibrationStatus calibrationError,void* pCookie )
{ cout << "Calibration complete for user " << user << ", ";
if( calibrationError==XN_CALIBRATION_STATUS_OK ) {
cout << "Success" << endl;
skeleton.StartTracking( user );
//userGenerator.GetSkeletonCap().SaveCalibrationDataToFile(user, "UserCalibration.txt" ); }
else
{ cout << "Failure" << endl;
//For the current version of OpenNI, only Psi pose is available
((xn::UserGenerator*)pCookie)->GetPoseDetectionCap().StartPoseDetection( "Psi", user ); } }
// callback function of pose detection: pose start
void XN_CALLBACK_TYPE PoseDetected( xn::PoseDetectionCapability& poseDetection,const XnChar* strPose,XnUserID user,void* pCookie)
{ cout << "Pose " << strPose << " detected for user " << user << endl; ((xn::UserGenerator*)pCookie)->GetSkeletonCap().RequestCalibration( user, FALSE );
poseDetection.StopPoseDetection( user ); }
void clearImg(IplImage* inputimg)
{ CvFont font;
cvInitFont( &font, CV_FONT_VECTOR0,1, 1, 0, 3, 5);
memset(inputimg->imageData,255,640*480*3); }
int main( int argc, char** argv )
{ char key=0; int imgPosX=0; int imgPosY=0;
// initial context
xn::Context context;
context.Init();
context.SetGlobalMirror(true);
xn::ImageMetaData imageMD;
IplImage* cameraImg=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3);
cvNamedWindow("Camera",1);
// map output mode
XnMapOutputMode mapMode;
mapMode.nXRes = 640;
mapMode.nYRes = 480;
mapMode.nFPS = 30;
// create generator
depthGenerator.Create( context );
depthGenerator.SetMapOutputMode( mapMode );
imageGenerator.Create( context );
userGenerator.Create( context );
//【2】
// Register callback functions of user generator
XnCallbackHandle userCBHandle;
userGenerator.RegisterUserCallbacks( NewUser, LostUser, NULL, userCBHandle ); //【3】
// Register callback functions of skeleton capability
xn::SkeletonCapability skeletonCap = userGenerator.GetSkeletonCap();
skeletonCap.SetSkeletonProfile( XN_SKEL_PROFILE_ALL );
XnCallbackHandle calibCBHandle;
skeletonCap.RegisterToCalibrationStart( CalibrationStart,&userGenerator, calibCBHandle );
skeletonCap.RegisterToCalibrationComplete( CalibrationEnd,&userGenerator, calibCBHandle );
//【4】
// Register callback functions of Pose Detection capability
XnCallbackHandle poseCBHandle;
userGenerator.GetPoseDetectionCap().RegisterToPoseDetected( PoseDetected,&userGenerator, poseCBHandle );
// start generate data
context.StartGeneratingAll();
while( key!=27 )
{ context.WaitAndUpdateAll();
imageGenerator.GetMetaData(imageMD);
memcpy(cameraImg->imageData,imageMD.Data(),640*480*3);
cvCvtColor(cameraImg,cameraImg,CV_RGB2BGR);
// get users
XnUInt16 userCounts = userGenerator.GetNumberOfUsers();
if( userCounts > 0 )
{ XnUserID* userID = new XnUserID[userCounts];
userGenerator.GetUsers( userID, userCounts );
for( int i = 0; i < userCounts; ++i )
{
//【5】
// if is tracking skeleton
if( skeletonCap.IsTracking( userID[i] ) )
{
XnPoint3D skelPointsIn[24],skelPointsOut[24];
XnSkeletonJointTransformation mJointTran;
for(int iter=0;iter<24;iter++)
{
//XnSkeletonJoint from 1 to 24 skeletonCap.GetSkeletonJoint( userID[i],XnSkeletonJoint(iter+1), mJointTran ); skelPointsIn[iter]=mJointTran.position.position;
}
depthGenerator.ConvertRealWorldToProjective(24,skelPointsIn,skelPointsOut); //【6】
for(int d=0;d<14;d++)
{
CvPoint startpoint = cvPoint(skelPointsOut[startSkelPoints[d]-1].X,skelPointsOut[startSkelPoints[d]-1].Y);
CvPoint endpoint = cvPoint(skelPointsOut[endSkelPoints[d]-1].X,skelPointsOut[endSkelPoints[d]-1].Y);
cvCircle(cameraImg,startpoint,3,CV_RGB(0,0,255),12);
cvCircle(cameraImg,endpoint,3,CV_RGB(0,0,255),12); }
}
}
delete [] userID;
}
cvShowImage("Camera",cameraImg);
key=cvWaitKey(20);
}
// stop and shutdown
cvDestroyWindow("Camera");
cvReleaseImage(&cameraImg);
context.StopGeneratingAll();
context.Shutdown();
return 0;
}
这是我的程序 ,我想我的程序没错
I
2013年09月15日 11点09分 4
level 4
我的系统是win7 64位的
2013年09月15日 11点09分 5
1