# Extract Depth From Depth Image

Source: https://forum.modalai.com/topic/818/extract-depth-from-depth-image
Category: ESCs, Sensors and Accessories (https://forum.modalai.com/category/15/escs-sensors-and-accessories)
Tags: image-sensor
Posted: 2022-03-25 13:46:46 UTC by amiranda
Replies: 4 · Views: 1332

## amiranda · 2022-03-25 13:46:46 UTC

I have a pmd tof sensor and I am able to see its imagery using voxl-portal or rosrun image_view but how can I extract the depth of the points in mm? Is there an easy way to do that while I do some testing or do I have to write something up to subscribe and print the various points out? 

Is there a handy logging tool of somesort that could give me an array of depth points? 

Thanks

## Reply by Guest · 2022-03-25 15:26:37 UTC

Hi,

We have a feature in the works for our [voxl-logger](https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-tools/-/blob/dev/tools/voxl-logger.cpp) project that would allow it to log tof data to a file. In the meantime, you can use ```voxl-inspect-points``` to look at a subsample of the points, or copy and modify the [source](https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-tools/-/blob/master/tools/voxl-inspect-points.c) to process the data however you'd like.

## Reply by amiranda · 2022-03-25 15:56:33 UTC

Thanks @Alex-Gardner  , 

If I enter `voxl-inspect-points tof_pc -n` then is the z axis supposed to be depth in mm? Is there a scale that is supposed to be applied to get between float and distance? 

Also is something like the following the expected output? It just says Float XYZ. 
timestamp(ms)| # points | # bytes |  Format
     8104565 |    38528 |  462336 | Float XYZ
     8104628 |    38528 |  462336 | Float XYZ
     8104696 |    38528 |  462336 | Float XYZ
     8104758 |    38528 |  462336 | Float XYZ

I can start going through the source, I just want to make sure I understand everything so I can get the correct depth in distance extracted. 

Thanks for your help.

## Reply by Guest · 2022-03-25 17:00:49 UTC

Hey @amiranda,

For the tof points, each axis is measured in meters, no scaling is needed.

## Reply by amiranda · 2022-03-25 18:12:44 UTC

Okay, in the meantime, I ended up creating a subscriber for the tof_pc and I managed to extract the x,y and z points. Im assuming that the z point that I extracted from the voxl_mpa_to_ros is the same as the one used in voxl-inspect-points, so that z axis is also reported in meters correct? 

Thanks for you help so far.
