Kinect for Windows V2和V1對比開發___骨骼資料擷取

來源:互聯網
上載者:User

標籤:kinect

1,       開啟骨骼幀的方式

對於V1,

方法NuiSkeletonTrackingEnable實現            m_hNextSkeletonEvent = CreateEvent(NULL, TRUE, FALSE, NULL );            hr =m_PNuiSensor->NuiSkeletonTrackingEnable(                       m_hNextSkeletonEvent,            NUI_SKELETON_TRACKING_FLAG_ENABLE_IN_NEAR_RANGE//|                       );            if( FAILED( hr ) )                  {                       cout<<"Couldnot open skeleton stream video"<<endl;                       return hr;                  }


對於V2

// Initialize the Kinect andget coordinate mapper and the body reader        IBodyFrameSource* pBodyFrameSource = NULL;         hr = m_pKinectSensor->Open();         if (SUCCEEDED(hr))        {            hr = m_pKinectSensor->get_CoordinateMapper(&m_pCoordinateMapper);        }方法get_CoordinateMapper得到座標映射        if (SUCCEEDED(hr))        {            hr =m_pKinectSensor->get_BodyFrameSource(&pBodyFrameSource);        }方法get_BodyFrameSource得到骨骼幀源        if (SUCCEEDED(hr))        {            hr =pBodyFrameSource->OpenReader(&m_pBodyFrameReader);        }方法get_BodyFrameSource開啟骨骼幀讀取器        SafeRelease(pBodyFrameSource);    }


2,更新骨骼幀方式

對於V1,方法NuiSkeletonGetNextFrame實現

NUI_SKELETON_FRAMESkeletonFrame;//骨骼幀的定義             bool bFoundSkeleton = false;              if(SUCCEEDED(NuiSkeletonGetNextFrame( 0, &SkeletonFrame )) )//Get the next frameof skeleton data.直接從kinect中提取骨骼幀


對於V2,

竟然木有發現如何更新的哎,再慢慢看吧。。。

3,畫骨架方式:

對於V1,主要用opencv輔助來畫,用到cvLine方法

例如左上肢的實現為:

   

//左上肢      if((pointSet[NUI_SKELETON_POSITION_SHOULDER_CENTER].x!=0 ||pointSet[NUI_SKELETON_POSITION_SHOULDER_CENTER].y!=0) &&         (pointSet[NUI_SKELETON_POSITION_SHOULDER_LEFT].x!=0 ||pointSet[NUI_SKELETON_POSITION_SHOULDER_LEFT].y!=0))          cvLine(SkeletonImage, pointSet[NUI_SKELETON_POSITION_SHOULDER_CENTER],pointSet[NUI_SKELETON_POSITION_SHOULDER_LEFT], color, 2);      if((pointSet[NUI_SKELETON_POSITION_SHOULDER_LEFT].x!=0 ||pointSet[NUI_SKELETON_POSITION_SHOULDER_LEFT].y!=0) &&          (pointSet[NUI_SKELETON_POSITION_ELBOW_LEFT].x!=0|| pointSet[NUI_SKELETON_POSITION_ELBOW_LEFT].y!=0))          cvLine(SkeletonImage,pointSet[NUI_SKELETON_POSITION_SHOULDER_LEFT],pointSet[NUI_SKELETON_POSITION_ELBOW_LEFT], color, 2);      if((pointSet[NUI_SKELETON_POSITION_ELBOW_LEFT].x!=0 ||pointSet[NUI_SKELETON_POSITION_ELBOW_LEFT].y!=0) &&         (pointSet[NUI_SKELETON_POSITION_WRIST_LEFT].x!=0 ||pointSet[NUI_SKELETON_POSITION_WRIST_LEFT].y!=0))          cvLine(SkeletonImage,pointSet[NUI_SKELETON_POSITION_ELBOW_LEFT],pointSet[NUI_SKELETON_POSITION_WRIST_LEFT], color, 2);      if((pointSet[NUI_SKELETON_POSITION_WRIST_LEFT].x!=0 ||pointSet[NUI_SKELETON_POSITION_WRIST_LEFT].y!=0) &&         (pointSet[NUI_SKELETON_POSITION_HAND_LEFT].x!=0 ||pointSet[NUI_SKELETON_POSITION_HAND_LEFT].y!=0))          cvLine(SkeletonImage,pointSet[NUI_SKELETON_POSITION_WRIST_LEFT],pointSet[NUI_SKELETON_POSITION_HAND_LEFT], color, 2);  


對於V2,主要藉助Direct2D微軟的圖形映像API,具體詳細可以查閱資料。。當然也可以轉換為用opencv來畫。

Kinect for Windows V2和V1對比開發___骨骼資料擷取

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.