Forum

Author Topic: Depth Maps Values and How can i get the real distance from the sensor per pixel  (Read 4981 times)

marinosvlachos

  • Newbie
  • *
  • Posts: 13
    • View Profile
Hello i was wandering what are the values that each pixel of a depth images represent? i noticed that the range of those is from 0-255. Do these values represent the disparity? And if they do how can i manipulate those values to transform them into the distance of the object from the sensor in meters for example? Is there any option in Metashape to export directly the depth maps with the sensor to object distances for every pixel?

Thanks in advance

marinosvlachos

  • Newbie
  • *
  • Posts: 13
    • View Profile
Alexey any feedback regarding that?
Thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Hello marinosvlachos,

Do you mean the depth images that are exported via Export Depth command?
Best regards,
Alexey Pasumansky,
Agisoft LLC

marinosvlachos

  • Newbie
  • *
  • Posts: 13
    • View Profile
Hello Alexey and thank you for the reply

Exactly yes the depth images from the command Export Depth.

Thank you in advance

marinosvlachos

  • Newbie
  • *
  • Posts: 13
    • View Profile
To be more specific. The values of the Depth map that is exported are greyscale values[0-255] is there any way to directly export the depth maps with the real depth values (in meters) or to transform the greyscale values to meters directly from Metashape? And if not is there any suggestion how this can be achieved?

I really need to obtain this information for a project i am working on.

Thanks in advance
« Last Edit: July 26, 2019, 11:28:43 AM by marinosvlachos »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Hello marinosvlachos,

The grayscale depth exported via GUI is scaled between min and max distance values for the current camera to 0-255 range.

If you wish to export the depth in actual scale (in floating point format instead of false colors or grayscale representation), you can use Python scripting (see attached script).
The script requires the source depth maps to be present in the project.

In case you would like to generate the depth in a similar way as GUI option does (based on the available mesh), then the following function should be used:
Code: [Select]
chunk.model.renderDepth(camera.transform, camera.sensor.calibration)It also returns the floating point value that should be multiplied by chunk.transform.matrix.scale for absolute scale value.
Best regards,
Alexey Pasumansky,
Agisoft LLC

marinosvlachos

  • Newbie
  • *
  • Posts: 13
    • View Profile
Hello Alexey and thank you for the script. Unfortunately numpy is not recognized and as i see is essential for the script to run. I am using version 1.5.0 so i suppose is not compatible. Any suggestions?

Thanks in advance
Marinos

« Last Edit: July 26, 2019, 07:39:49 PM by marinosvlachos »

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Marinos,

you just have to  install numpy (from cmd prompt in Windows) following this recipe https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package

then script should run OK!
Best Regards,
Paul Pelletier,
Surveyor