Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse
Brand Logo

ModalAI Forum

  1. ModalAI Support Forum
  2. Ask your questions right here!
  3. TOF Depth Image Encoding changed from 32FC1 to mono8

TOF Depth Image Encoding changed from 32FC1 to mono8

Scheduled Pinned Locked Moved Ask your questions right here!
3 Posts 2 Posters 664 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jaredjohansen
    Regular
    wrote on last edited by
    #1

    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 type sensor_imgs/Image and its encoding would be 32FC1.

    Today, with the latest code, I need to use rostopic echo /mpa/tof_depth to get the depth image. When I do that, the ROS message is still of the type sensor_imgs/Image but its encoding is mono8.

    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 mono8 encoding 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)
    
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jaredjohansen
        Regular
        wrote on last edited by
        #3

        For anyone who runs into this same issue, I changed my subscriber to listen to /map/tof_pc (which has the PointCloud2 type). 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]
        
        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        ModalAI
        Categories Recent Tags ModalAI.com Docs
        © 2026 ModalAI® · Accelerating autonomy for smaller, smarter, safer drones · Powered by NodeBB
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups