I have transformed the pfm image to the depth image. but I want to get the actual distance to the obstacle. I want to ask how to do it?
If you are using the DepthPlanner image, the depth value at each pixel is the depth of the object in the camera frame. For every pixel (u,v) in the DepthPlanner image, the true point (x, y, z) in the world in the camera frame of reference can be calculated as
x = (u - cx) * d / fx
y = (v - cy) * d / fy
z = d
where
d is the value at the pixel (u,v) in the DepthPlanner image,
(cx, cy) is the principal point,
fx, fy are the focal lengths.
For the values (cx, cy, fx, fy) refer to your settings.json file.
cx = width / 2
cy = height / 2
fx = cx / (tan(FOV / 2))
fy = fx
@tejaswid thanks for the reply. i will try this
Another option would be to use depth_image_proc over ROS.
I've added instructions here here.
But yeah, if you don't want the ros dependency, it's basically camera unprojection / what @tejaswid wrote
Most helpful comment
If you are using the DepthPlanner image, the depth value at each pixel is the depth of the object in the camera frame. For every pixel (u,v) in the DepthPlanner image, the true point (x, y, z) in the world in the camera frame of reference can be calculated as
x = (u - cx) * d / fx
y = (v - cy) * d / fy
z = d
where
d is the value at the pixel (u,v) in the DepthPlanner image,
(cx, cy) is the principal point,
fx, fy are the focal lengths.
For the values (cx, cy, fx, fy) refer to your settings.json file.
cx = width / 2
cy = height / 2
fx = cx / (tan(FOV / 2))
fy = fx