I'm trying to process depth maps for a subset of the images in my project. The following code identifies the positions of each image without a depth map successfully. However, when I run buildDepthMaps, processing finishes instantly ("Finished processing in 0 sec (exit code 1)") when reuse depth maps is set to false, or alternatively reprocesses from scratch when reuse depth maps is set to true.
Is there a way to reprocess depth maps for only those photos that do not have depth maps, or am I setting a value incorrectly in my script?
import Metashape
chunk = Metashape.app.document.chunk
# Get a list of the integer positions of each camera without a depth map
# Get all photo paths
allPhotos = []
for camera in chunk.cameras:
allPhotos.append(camera.photo.path)
# Get photo paths without depth maps
photosWithDepthMaps = []
for key in chunk.depth_maps.keys():
photosWithDepthMaps.append(key.photo.path)
# Get the integer positions of all photos
# not in the list of photo depth maps
photosWithoutDepthMaps = []
i = -1
for photo in allPhotos:
i += 1
if photo in photosWithDepthMaps: continue
photosWithoutDepthMaps.append(i)
# Process those photos
chunk.buildDepthMaps(
downscale = 2,
filter_mode = Metashape.FilterMode.MildFiltering,
cameras = photosWithoutDepthMaps,
reuse_depth = False)