A problem on using INuiCoordinateMapper RRS feed

  • Question

  •      I need to process the data offline, so I record the color image, depth image, and the coordinateMapper(which  regarded as the parameters of Kinect). Here is the code.

    INuiCoordinateMapper *m_NuiCoordinateMapper; HRESULT hr = m_pNuiSensor->NuiGetCoordinateMapper(&m_NuiCoordinateMapper); ULONG DataByteCount = 0; void *ppData ;

    std::ofstream oParameters(strParametersFilename); if (S_OK == m_NuiCoordinateMapper->GetColorToDepthRelationalParameters(&DataByteCount,&ppData)) { bool rst = Platform::writeUlong(oParameters,DataByteCount); rst = Platform::writeBytes(oParameters,ppData,(int)DataByteCount); return true; }

    so i saved the parameters, then i read the parameter file

            INuiCoordinateMapper *m_CoordinateMapper;
    	BYTE *pBuffer = new BYTE[maxParameter];
    	void *pData = (void *)pBuffer;
    	ULONG dataByteCount = 0;
    	HRESULT hr = NuiCreateCoordinateMapperFromParameters(dataByteCount,pData,&m_CoordinateMapper);
    	delete[] pBuffer;

    to now, i can get the m_CoordinateMapper; Next is the problem.

    NUI_DEPTH_IMAGE_PIXEL *m_pDepthPixels = new NUI_DEPTH_IMAGE_PIXEL[m_depthWidth*m_depthHeight];
    Vector4 *m_pSkeletonPoints = new Vector4[m_depthHeight*m_depthWidth];
    	for (int i = 0; i < m_depthHeight; i++)
    		ushort *ptr = m_depthImg.ptr<ushort>(i);
    		for (int j = 0; j < m_depthWidth; j++)
    			tmpDepth = m_pDepthPixels+i*m_depthWidth+j;
    			tmpDepth->depth = ptr[j]>>3;
    			tmpDepth->playerIndex = 0;
    	}//set the depth pixels

    the problem is the elements of m_pSkeletonPoints are all (1,0,0,0); Anybody can tell me why? 

    Thursday, May 22, 2014 9:33 AM

All replies

  • Are you getting color images or depth images? from the code you provided you need to MapDepthFrameToSkeletonFrame.

    Carmine Sirignano - MSFT

    Thursday, May 29, 2014 5:46 PM

    Thanks, Carmine. I have got color images and depth images.  

    And I got the target in the color images, and I want its position.  So I tried MapColorFrameToSkeletonFrame, here is this problem.

    I have tried MapDepthFrameToSkeletonFrame, It works. But I wonder there may be some problem just because i haven't map the color image with the depth image.  I don't know how to solve it . 

    And i found an interesting thing: the targets ,which have the same depth in reality ,are calculated different depth using MapDepthFrameToSkeletonFrame, it seems like the calculated position are not cartesian coordinate system.  I don't konw why.

    Look forward to your help.

    Tuesday, June 3, 2014 2:41 AM