Forum

Author Topic: Proper workflow for depthmap replacement  (Read 2507 times)

sergio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Proper workflow for depthmap replacement
« on: July 01, 2021, 04:18:02 AM »
Hi,

In our application we want to use Metashape with depthmaps generated externally. So far our processing is the following:

1. We build our depthmaps in the "standard" way:

addPhotos>>matchPhotos>>alignCameras>>buildDepthMaps

2. Then we change the depthmaps using:
[pseudocody...]
Code: [Select]
for cam, our_depth_image in zip(cameras, our_depths):
   
    if cam in chunk.depth_maps.keys():
        ms_dm = chunk.depth_maps[cam]

        if replace_depth:

            byte_image = our_depth_image .tobytes()
            ms_image = ms_dm.image()
            ms_dm.setImage( ms_image.fromstring(
                byte_image,
                w, h,
                channels=ms_image.channels,
                datatype=ms_image.data_type))


    else:
        print(cam)
        print("Camera has notdepthmap")   

3. Finally, we build the model:

Code: [Select]
chunk.buildModel(surface_type=Metashape.Arbitrary, source_data=Metashape.DepthMapsData, interpolation=Metashape.EnabledInterpolation)
When the model is saved to .psz we see the depthmaps have been replaced correctly, however, the model does not have the expected results. I wonder if we are missing something in the process (e.g. depth scaling, or some other processing step that should be done in this kind of workflow)

Best,

Sergio