TOF Depth Image Encoding changed from 32FC1 to mono8
-
I have a TOF sensor.
A little while ago, to see the depth image, I would
rostopic echo /tof/depth. When I did that, the ROS message would be of the typesensor_imgs/Imageand its encoding would be32FC1.Today, with the latest code, I need to use
rostopic echo /mpa/tof_depthto get the depth image. When I do that, the ROS message is still of the typesensor_imgs/Imagebut its encoding ismono8.Historically, if I wanted to process the depth image in ROS, I would setup a subscriber and use code like that shown below to ingest the data as a depth image. I could then access individual pixels to get the depth (in meters).
I'm now sure how to process a depth image of encoding
mono8. It seems like it would have too few bits to represent the resolution of depths possible.Is the
mono8encoding intentional (with the conversion to the latest mpa_to_ros)? Or is it a bug?If it's intentional, can you help me understand how to process this new data encoding and extract the distances of individual pixels (similar to the code posted below)?
# get the depth image dep_frame = np.fromstring(tof_depth.data, dtype=np.single) dep_frame = dep_frame.reshape(172, 224) # Get closest value in bounding box object_depth_map = dep_frame[top:bottom,left:right] object_depth_map[object_depth_map == 0] = 9999.00 object_depth = np.min(object_depth_map) -
MPA_to_ROS was recently updated to a new architecture, the depth image that we publish was meant to be more of a debug tool where the z value of the pointcloud is scaled from 0-255 for 0-1 meter distance, but it looks like the old mpa to ros instead published the z value of the sensor, which is floating point. To get the same old value that you were looking at, you should access the pointcloud tof message and look at the z value.
-
For anyone who runs into this same issue, I changed my subscriber to listen to
/map/tof_pc(which has thePointCloud2type). My code (to extract the z value) is this:# get the depth image dep_frame = np.fromstring(data.data, dtype=np.single) # get numpy array dep_frame = dep_frame.reshape(172, 224, 3)[:,:,2]