Openni coordinate conversion not correct?


I recently bought a Structure Sensor, and I have started writing some software for it in C++/Qt/openni2/windows. I noticed that when I set the pixel format of the depth stream to PIXEL_FORMAT_DEPTH_100_UM, the values in the depth image are 10 times larger than when I set it to PIXEL_FORMAT_DEPTH_1_MM. This is as expected. However, when I use the following code:

        for (int y = 0; y < DepthFrame.getHeight(); y++)
            for (int x = 0; x < DepthFrame.getWidth(); x++)
                uint16_t CurrentPixel = pDepthPixelData[(y * DepthFrame.getWidth()) + x];
                if (CurrentPixel != 0)
                    openni::CoordinateConverter::convertDepthToWorld(m_DepthStream, x, y, CurrentPixel, &OutX, &OutY, &OutZ);

Then the OutX, OutY and OutZ value will also be 10 times larger than before. This means that when I use PIXEL_FORMAT_DEPTH_100_UM, I have to divide all of the resulting values by 10 (also the X and Y values!), in order to get the correct result in mm. Is this a bug in the openni::CoordinateConverter::convertDepthToWorld method? As far as I can see from the API reference, the returned values should always be in mm. The convertDepthToWorld method can read the pixel format from the depth stream, so it should be able to give the same result independently of pixel format.

Thanks in advance!

The 100um mode should manipulate the zFactor in the native libraries used for the calculations. Although it correctly modifies how the x and y value are calculated in millimeters, it leaves the z value unaltered.

cf. this file, which is derived from the native code used in the CoordinateConverter: