Forum

Author Topic: Extract aligned depth maps  (Read 1108 times)

eason

  • Newbie
  • *
  • Posts: 3
    • View Profile
Extract aligned depth maps
« on: February 17, 2025, 07:21:47 PM »
Hello,

I am extracting depth maps using the chunk.depth_maps[camera].image(0) API. I noticed that the output depth maps have the same resolution as the RGB images but are not aligned. It appears that the depth maps are cropped and then resized. However, when displayed in the software, the depth maps are aligned with the RGB images but have a smaller range.

Is there a way to obtain depth maps that are perfectly aligned with the RGB images without cropping or resizing, as they appear in the software?

Any guidance would be greatly appreciated.

Paulo

  • Hero Member
  • *****
  • Posts: 1492
    • View Profile
Re: Extract aligned depth maps
« Reply #1 on: February 17, 2025, 09:24:46 PM »
He eason,

the exported depth maps are using an undistorted camera. So for RGB images  to align you must undistort them according to camera calibration. Only in case where you generate the depth maps in highest quality will they have same resolution as rgb image.

So for given depth map dm = chunk.depth_maps[chunk.cameras[0]], you should use chunk.cameras[0].calibration to undistort the corresponding camera image, chunk.cameras[0].photo.image() ...

Hope this is helpful
« Last Edit: February 17, 2025, 09:31:31 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

eason

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Extract aligned depth maps
« Reply #2 on: February 18, 2025, 12:11:00 AM »
Hi Paul,

Thanks for your suggestions. I tried using camera.photo.image(), camera.calibration, and the undistort function to obtain undistorted RGB images. However, the extracted images contain black masks, which are quite different from depth maps.

Code: [Select]
RGB = camera.photo.image()
calibration = camera.calibration
undist = RGB.undistort(calibration, True, True)

Do you have any further suggestions for resolving this issue?

Paulo

  • Hero Member
  • *****
  • Posts: 1492
    • View Profile
Re: Extract aligned depth maps
« Reply #3 on: February 18, 2025, 02:25:55 AM »
Hi,

I would try
Code: [Select]
undist = RGB.undistort(calibration, False, True)
as the second argument False means not to center principal point and thus avoid black margin in case cx,cy is important...

As you can see in attachment, on left I show depth map for image RGB_0188 and on right I superimpose the RGB undistorted with depth map and they fit nicely...

Best Regards,
Paul Pelletier,
Surveyor

eason

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Extract aligned depth maps
« Reply #4 on: February 19, 2025, 12:27:38 AM »
Thanks for sharing! It works perfectly!