@plangton : The first Kinect had this kind of conversions in it’s C++ library. Either thought no one would use it or this version of the Kinect SDK doesn’t come with it. Either way, I believe you can find some formula that by having the camera FOV and the position of something at the plane distance, you could project it’s position as if it was nearer the camera, thus finding the XYZ cm.
I have not searched, but I have an idea that may work. If you test it, let me know. Here goes:
Having the camera position and the pixel position you can find the angle of that pixel in relation to the camera as it’s a percentage of the FOV angle. Than project something at the distance of that pixel depth value from the camera at the calculated angle. That will be your final cm position.
Like: pX = 100, pY = 100. Depth value (D) = 100cm. Depth texture size = 512x424. Camera FOV = 84°.
If we consider the front of the camera to be the 0°, we must know how far off the center pX and pY are to get it’s angles. I’ll center pX and pY as if the texture center was 0,0 to make things neater.
pX = pX - 512/2 = -156;
pY = pY - 424/2 = -112;
Percentage of pX and pY from the center:
pctX = pX / (512/2) = -0.609;
pctY = pY / (424/2) = -0.528;
Percentage in degrees of the camera’s FOV:
degX = pctX * (84°/2) = -25.578°;
degY = pctY * ((424/512)*84°/2) = -18.364°;
Having those angles, we can find the position of that pixel in centimeters projecting a point from the camera at D and those angles. I’ll make it in Unreal coords.
cmX = D * cos(-degY);
cmY = D * cos(degX) * sin(-degY);
cmZ = D * sin(degX) * sin(-degY);
I’m not sure if on the last part you really need to use -degY. But I think so because on the texture Y grows down and in the world Z grows up.
Also, I’m assuming your camera is at 0,0,0 pointing straight at X. If not, you’ll have to add your camera’s world position to the final result and rotate the vector accordingly. In that case it’ll probably be easier to use these coords as relative to the camera in a camera’s child actor.
This is an approach method, of course. I remember on the first Kinect SDK that these coord conversion methods accounted for the difference in position of the Kinect sensors etc. It was a much more advanced calculation.