none
Align Skeleton Information with RGB Image RRS feed

  • Question

  • Hi .

    I am actually new on the development using Visual Studio and Kinect Sdk and I have a few questions.

    I've manage to run the Kinect SkeletalViewer sample and I would like to draw the skeleton over the RGB image.
    I thought that should be fairly easy but I got a bit lost with the SDK.

    I know when the skeleton information is ready the function ' Nui_DrawSkeleton( &SkeletonFrame.SkeletonData[i], GetDlgItem( m_hWnd, IDC_SKELETALVIEW ), i ); ' is called. And this is the function that actually will handle the Skeleton Drawing.

    I know that part that is actually drawing the skeleton structure is :

      for (i = 0; i < NUI_SKELETON_POSITION_COUNT; i++)
        {
            NuiTransformSkeletonToDepthImage( pSkel->SkeletonPositions[i], &m_Points[i].x, &m_Points[i].y, &depth );
    	m_Points[i].x = (m_Points[i].x * width) / 320;
            m_Points[i].y = (m_Points[i].y * height) / 240;
    
        }
    
    
    
        SelectObject(m_SkeletonDC,m_Pen[WhichSkeletonColor%m_PensTotal]);
        
        Nui_DrawSkeletonSegment(pSkel,4,NUI_SKELETON_POSITION_HIP_CENTER, NUI_SKELETON_POSITION_SPINE, NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_HEAD);
        Nui_DrawSkeletonSegment(pSkel,5,NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_SHOULDER_LEFT, NUI_SKELETON_POSITION_ELBOW_LEFT, NUI_SKELETON_POSITION_WRIST_LEFT, NUI_SKELETON_POSITION_HAND_LEFT);
        Nui_DrawSkeletonSegment(pSkel,5,NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_SHOULDER_RIGHT, NUI_SKELETON_POSITION_ELBOW_RIGHT, NUI_SKELETON_POSITION_WRIST_RIGHT, NUI_SKELETON_POSITION_HAND_RIGHT);
        Nui_DrawSkeletonSegment(pSkel,5,NUI_SKELETON_POSITION_HIP_CENTER, NUI_SKELETON_POSITION_HIP_LEFT, NUI_SKELETON_POSITION_KNEE_LEFT, NUI_SKELETON_POSITION_ANKLE_LEFT, NUI_SKELETON_POSITION_FOOT_LEFT);
        Nui_DrawSkeletonSegment(pSkel,5,NUI_SKELETON_POSITION_HIP_CENTER, NUI_SKELETON_POSITION_HIP_RIGHT, NUI_SKELETON_POSITION_KNEE_RIGHT, NUI_SKELETON_POSITION_ANKLE_RIGHT, NUI_SKELETON_POSITION_FOOT_RIGHT);
        
    Now how to what is the correct usage for NuiImageGetColorPixelCoordinatesFromDepthPixel ?
    And what is the appropiate way to use this to draw the skeleton over the Color image ?
    I've created another global vector of type POINT which is m_Points_image , and I am using it to store the the results.
    Is it correct ?
     for (i = 0; i < NUI_SKELETON_POSITION_COUNT; i++)
        {
            NuiTransformSkeletonToDepthImage( pSkel->SkeletonPositions[i], &m_Points[i].x, &m_Points[i].y, &depth );
            NuiImageGetColorPixelCoordinatesFromDepthPixel( NUI_IMAGE_RESOLUTION_640x480, NULL, m_Points[i].x, m_Points[i].y, depth<<3, &m_Points_image[i].x,  &m_Points_image[i].y);
            m_Points[i].x = (m_Points[i].x * width) / 320;
            m_Points[i].y = (m_Points[i].y * height) / 240;
    
        }
    Now how Can I use this information to inprint the skeleton over the RGB Color image?



    Wednesday, February 22, 2012 2:44 PM

All replies

  • let me answer you.(I use c++.)

    NuiSensor->NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution(
    NUI_IMAGE_RESOLUTION_640x480,//1
    NUI_IMAGE_RESOLUTION_640x480,//2
    640*480,//3
    (unsigned short *)LockedRect.pBits,//4
    480*640*2,//5
    colorCoordinates//6
    );

    1 and 2 is the resolution and I use the most used resolution 640*480.

    3 is the number of depth values and 5 is twice of 3.(I am not clear why)

    4 is the depth image frame

    6 is the new coordinates after alignment. 

    And after use this function, you will use 6 to calibrate the coordinates. And the way of calibration,see the microsoft sample,depthwithcolor-d3d.

    • Edited by yaoshunyu Wednesday, August 15, 2012 12:13 PM
    Wednesday, August 15, 2012 11:54 AM