none
Explanation of MapDepthFrameToColorSpace() negative values RRS feed

  • Question

  • Hello,

    I'm approaching Kinect 2 SDK for the first time, and I'm having trouble understanding ICoordinateMapper::MapDepthFrameToColorSpace() method results. If I understood correctly, the fourth parameter, colorSpacePoints, should be filled by the method with ColorSpacePoint values. After calling the said method, each element of colorSpacePoints should contain a ColorSpacePoint corresponding to the X and Y coordinates of the color space corresponding to the given depth image pixel.

    Shouldn't colorSpacePoints values be integer and, most of all, greater or equal than zero? Debugging my application (and also a sample application) I can see that some ColorSpacePoint X or Y values in colorSpacePoints are negative. Why? Could someone explain me what colorSpacePoints is supposed to contain after calling MapDepthFrameToColorSpace() please?

    Thank you very much in advance for your help! :)

    Wednesday, July 29, 2015 5:18 PM

Answers

  • After calling MapDepthFrameToColorSpace(), colorSpacePoints contains 512x424 ColorSpacePoint values, one for each pixel in the depth image. Each ColorSpacePoint shows where the corresponding depth pixel would be in the color image. I gather that much was clear.

    Now, why are there negative values in there? Because of the different FOVs and aspect ratios, the two cameras don't see exactly the same thing. More specifically, on the very left and very right borders of the color image, there is an area that the depth camera can't see (about 6% on each side). Likewise, on the very top and very bottom of the depth image are areas that the color camera can't see.

    And that's where the negative values come from: the first few rows of the depth image are mapped to values outside (above) the color image, resulting in negative Y values. Likewise, the last few rows are mapped to Y values greater than 1080, also outside the color image.

    Btw. when using the inverse method (MapColorFrameToDepthSpace()), the left-most and right most columns are mapped to invalid values, since they are outside the depth image.

    I hope that helps. :-)

    • Marked as answer by K1kk0z90 Thursday, July 30, 2015 8:08 AM
    Thursday, July 30, 2015 7:31 AM

All replies

  • After calling MapDepthFrameToColorSpace(), colorSpacePoints contains 512x424 ColorSpacePoint values, one for each pixel in the depth image. Each ColorSpacePoint shows where the corresponding depth pixel would be in the color image. I gather that much was clear.

    Now, why are there negative values in there? Because of the different FOVs and aspect ratios, the two cameras don't see exactly the same thing. More specifically, on the very left and very right borders of the color image, there is an area that the depth camera can't see (about 6% on each side). Likewise, on the very top and very bottom of the depth image are areas that the color camera can't see.

    And that's where the negative values come from: the first few rows of the depth image are mapped to values outside (above) the color image, resulting in negative Y values. Likewise, the last few rows are mapped to Y values greater than 1080, also outside the color image.

    Btw. when using the inverse method (MapColorFrameToDepthSpace()), the left-most and right most columns are mapped to invalid values, since they are outside the depth image.

    I hope that helps. :-)

    • Marked as answer by K1kk0z90 Thursday, July 30, 2015 8:08 AM
    Thursday, July 30, 2015 7:31 AM
  • Thank you very much!

    Just one more clarification: why are they float values and not integers? Pixels positions shouldn't be integers? Thank you again! :)

    Thursday, July 30, 2015 8:11 AM
  • They are float values because there is no perfect match between depth pixels and color pixels. So instead you get the exact mapping, which lies somewhere between the actual color pixels. Then you can decide yourself what you want to do with it. I usually just round to the nearest int.
    Thursday, July 30, 2015 10:20 AM