aihot  2017-04-28 00:04:00  OpenCV |   查看评论   
  •     NuiImageStreamGetNextFrame(colorStreamHandle, 0, &colorFrame);   
  •     INuiFrameTexture *pTexture = colorFrame->pFrameTexture;     
  •    
  •     NUI_LOCKED_RECT LockedRect;   
  •     pTexture->LockRect(0, &LockedRect, NULL, 0);     
  •    
  •     if( LockedRect.Pitch != 0 )   
  •     {   
  •         for (int i=0; i<colorImage.rows; i++)   
  •         {  
  •             uchar *ptr = colorImage.ptr<uchar>(i);  //第i行的指针                    
  •             //每个字节代表一个颜色信息,直接使用uchar  
  •             uchar *pBuffer = (uchar*)(LockedRect.pBits) + i * LockedRect.Pitch;  
  •             for (int j=0; j<colorImage.cols; j++)   
  •             {   
  •                 ptr[3*j] = pBuffer[4*j];  //内部数据是4个字节,0-1-2是BGR,第4个现在未使用   
  •                 ptr[3*j+1] = pBuffer[4*j+1];   
  •                 ptr[3*j+2] = pBuffer[4*j+2];   
  •             }   
  •         }   
  •     }   
  •     else   
  •     {   
  •         cout<<"捕捉色彩图像出现错误"<<endl;   
  •     }  
  •   
  •     pTexture->UnlockRect(0);   
  •     NuiImageStreamReleaseFrame(colorStreamHandle, colorFrame );  
  • }   
  •    
  • void getDepthImage(HANDLE &depthEvent, HANDLE &depthStreamHandle, Mat &depthImage)   
  • {   
  •     const NUI_IMAGE_FRAME *depthFrame = NULL;   
  •    
  •     NuiImageStreamGetNextFrame(depthStreamHandle, 0, &depthFrame);   
  •     INuiFrameTexture *pTexture = depthFrame->pFrameTexture;     
  •    
  •     NUI_LOCKED_RECT LockedRect;   
  •     pTexture->LockRect(0, &LockedRect, NULL, 0);     
  •    
  •     RGBQUAD q;   
  •   
  •     if( LockedRect.Pitch != 0 )   
  •     {   
  •         for (int i=0; i<depthImage.rows; i++)   
  •         {   
  •             uchar *ptr = depthImage.ptr<uchar>(i);   
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自Kinect开发学习笔记之彩色、深度、骨骼和用户抠图结合

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]