#include"Windows.h"#include"NuiApi.h"#includ"> #include"Windows.h"#include"NuiApi.h"#includ" />
欢迎来到天天文库
浏览记录
ID:33365314
大小:45.05 KB
页数:3页
时间:2019-02-25
《kinect中骨骼数据的采集》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、//skeleton_data_SDK.cpp:定义控制台应用程序的入口点。//#include"stdafx.h"#include#include"Windows.h"#include"NuiApi.h"#include"cv.h"#include"highgui.h"usingnamespacestd;voidNui_DrawSkeleton(NUI_SKELETON_DATA*pSkel,intwhichone,IplImage*SkeletonImage)//画出骨骼,第二个参数未使用,想跟踪多人的童鞋可以考虑使用{floatfx,fy;CvPointSk
2、eletonPoint[NUI_SKELETON_POSITION_COUNT];for(inti=0;iSkeletonPositions[i],&fx,&fy);SkeletonPoint[i].x=(int)(fx*320+0.5f);SkeletonPoint[i].y=(int)(fy*240+0.5f);}for(inti=0;i3、{if(pSkel->eSkeletonPositionTrackingState[i]!=NUI_SKELETON_POSITION_NOT_TRACKED)//跟踪点一用有三种状态:1没有被跟踪到,2跟踪到,3根据跟踪到的估计到{cvCircle(SkeletonImage,SkeletonPoint[i],3,cvScalar(0,255,255),-1,8,0);}}return;}intmain(intargc,char*argv[]){IplImage*skeletonImage=NULL;skeletonImage=cvCreateImage(cvSize(320,244、0),8,3);//初始化NUIHRESULThr=NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON);if(hr!=S_OK){cout<<"NuiInitializefailed"<5、ndl;NuiShutdown();returnhr;}while(1){if(WaitForSingleObject(h1,INFINITE)==0){NUI_SKELETON_FRAMESkeletonFrame;//骨骼帧的定义boolbFoundSkeleton=false;if(SUCCEEDED(NuiSkeletonGetNextFrame(0,&SkeletonFrame)))//Getthenextframeofskeletondata.直接从kinect中提取骨骼帧{for(inti=0;i6、rame.SkeletonData[i].eTrackingState==NUI_SKELETON_TRACKED)//最多跟踪六个人,检查每个“人”(有可能是空,不是人)是否跟踪到了{bFoundSkeleton=true;}}}if(!bFoundSkeleton){continue;}//smoothouttheskeletondataNuiTransformSmooth(&SkeletonFrame,NULL);//平滑骨骼帧,消除抖动//draweachskeletoncoloraccordingtotheslotwithintheyarefound.cvZero(skel7、etonImage);for(inti=0;i
3、{if(pSkel->eSkeletonPositionTrackingState[i]!=NUI_SKELETON_POSITION_NOT_TRACKED)//跟踪点一用有三种状态:1没有被跟踪到,2跟踪到,3根据跟踪到的估计到{cvCircle(SkeletonImage,SkeletonPoint[i],3,cvScalar(0,255,255),-1,8,0);}}return;}intmain(intargc,char*argv[]){IplImage*skeletonImage=NULL;skeletonImage=cvCreateImage(cvSize(320,24
4、0),8,3);//初始化NUIHRESULThr=NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON);if(hr!=S_OK){cout<<"NuiInitializefailed"<5、ndl;NuiShutdown();returnhr;}while(1){if(WaitForSingleObject(h1,INFINITE)==0){NUI_SKELETON_FRAMESkeletonFrame;//骨骼帧的定义boolbFoundSkeleton=false;if(SUCCEEDED(NuiSkeletonGetNextFrame(0,&SkeletonFrame)))//Getthenextframeofskeletondata.直接从kinect中提取骨骼帧{for(inti=0;i6、rame.SkeletonData[i].eTrackingState==NUI_SKELETON_TRACKED)//最多跟踪六个人,检查每个“人”(有可能是空,不是人)是否跟踪到了{bFoundSkeleton=true;}}}if(!bFoundSkeleton){continue;}//smoothouttheskeletondataNuiTransformSmooth(&SkeletonFrame,NULL);//平滑骨骼帧,消除抖动//draweachskeletoncoloraccordingtotheslotwithintheyarefound.cvZero(skel7、etonImage);for(inti=0;i
5、ndl;NuiShutdown();returnhr;}while(1){if(WaitForSingleObject(h1,INFINITE)==0){NUI_SKELETON_FRAMESkeletonFrame;//骨骼帧的定义boolbFoundSkeleton=false;if(SUCCEEDED(NuiSkeletonGetNextFrame(0,&SkeletonFrame)))//Getthenextframeofskeletondata.直接从kinect中提取骨骼帧{for(inti=0;i6、rame.SkeletonData[i].eTrackingState==NUI_SKELETON_TRACKED)//最多跟踪六个人,检查每个“人”(有可能是空,不是人)是否跟踪到了{bFoundSkeleton=true;}}}if(!bFoundSkeleton){continue;}//smoothouttheskeletondataNuiTransformSmooth(&SkeletonFrame,NULL);//平滑骨骼帧,消除抖动//draweachskeletoncoloraccordingtotheslotwithintheyarefound.cvZero(skel7、etonImage);for(inti=0;i
6、rame.SkeletonData[i].eTrackingState==NUI_SKELETON_TRACKED)//最多跟踪六个人,检查每个“人”(有可能是空,不是人)是否跟踪到了{bFoundSkeleton=true;}}}if(!bFoundSkeleton){continue;}//smoothouttheskeletondataNuiTransformSmooth(&SkeletonFrame,NULL);//平滑骨骼帧,消除抖动//draweachskeletoncoloraccordingtotheslotwithintheyarefound.cvZero(skel
7、etonImage);for(inti=0;i
此文档下载收益归作者所有