Forum

Author Topic: dense_cloud.renderDepth in meters?  (Read 3182 times)

aaronfhd

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
dense_cloud.renderDepth in meters?
« on: June 22, 2021, 07:56:40 PM »
I am Trying to Figure out how Agisoft determines that distance in the 32bit tiff it exports.

I have a Tree known distance in Agisoft from camera which is 160 meters away. But in the 32bit image in Band 1 the pixel value is 58.

How can I get those matching am I missing something. Thanks.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15145
    • View Profile
Re: dense_cloud.renderDepth in meters?
« Reply #1 on: June 22, 2021, 09:03:44 PM »
Hello aaronfhd,

Please check the example in the similar thread, which describes, how the depth data can be scaled to the real world dimensions (for faster script work numpy module is required):
https://www.agisoft.com/forum/index.php?topic=11171.msg50351#msg50351
Best regards,
Alexey Pasumansky,
Agisoft LLC

aaronfhd

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: dense_cloud.renderDepth in meters?
« Reply #2 on: June 23, 2021, 05:30:00 PM »
Here is the code that I have. Where would I multiply it

def render_depth():
    print("Script started...")

    chunk = Metashape.app.document.chunk
    #if not chunk.model:
        #raise Exception("No model!")

    for camera in get_cameras(chunk):
        render = chunk.dense_cloud.renderDepth(camera.transform, camera.sensor.calibration,point_size=4, resolution=1, cull_points=False, add_alpha=False)
        photo_dir = os.path.dirname(camera.photo.path) + "/workspace/depth/"
        photo_filename = os.path.basename(camera.photo.path)
        render_filename = os.path.splitext(photo_filename)[0] + "_render.tif"

        render.save(os.path.join(photo_dir, render_filename))

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15145
    • View Profile
Re: dense_cloud.renderDepth in meters?
« Reply #3 on: June 23, 2021, 05:54:21 PM »
Hello aaronfhd,

Please try the following modification:

Code: [Select]
chunk = Metashape.app.document.chunk
if chunk.transform:
    scale = chunk.transform.scale
else:
   scale = 1

for camera in get_cameras(chunk):
   if not camera.transform:
       continue
   render = chunk.dense_cloud.renderDepth(camera.transform, camera.sensor.calibration,point_size=4, resolution=1, cull_points=False, add_alpha=False)
   render = scale * render
#...
Best regards,
Alexey Pasumansky,
Agisoft LLC