2
« on: July 05, 2019, 02:03:00 AM »
I'm trying to create a script that refines data in an existing .psx file. After loading the file, I try to run chunk.buildDepthMaps and receive "Error: Null point cloud" even though a sparse point cloud exists in the .psx.
Any ideas?
#SFB Get reference to the currently active DOM
doc = Metashape.Document()
#AIW Attemtps to open an existing project.
# - A new project is created if an existing project is not available.
# - This must be done immediatly after getting reference to active DOM.
# - .psx format will not save correctly otherwise.
try:
doc.open("{}{}.psx" .format(PATH_TO_IMAGES, IMAGE_PREFIX), read_only=False, ignore_lock=True)
except:
print("No document exists!\nCreating a new document.")
doc.save("{}{}.psx" .format(PATH_TO_IMAGES, IMAGE_PREFIX))
#AIW Adds a chunk to the current document.
chunk = doc.addChunk()
#SFB Build the list of image filenames
images = []
for image in range(1, 121):
filename = ("%s%s%04d.tif" %(PATH_TO_IMAGES, IMAGE_PREFIX, image))
images.append(filename)
print(images)
#SFB Indicate processing is starting
sys.stdout.flush()
print("\nStarting processing:")
start = time.time()
#AIW From API "Add a list of photos to the chunk."
# - Must be run before getting a reference to camera.
phaseTime = time.time()
PHASE_LABEL = "Adding Photos"
chunk.addPhotos(images, progress=progress_callback)
print_time_elapsed(phaseTime)
doc.save()
#AIW Getting reference to camera. Index is out of range if not run after chunk.addPhotos.
camera = chunk.cameras[0]
#AIW From API "Generate depth maps for the chunk."
# - First step of the Metashape GUI "Workflow" process called "Dense Cloud".
phaseTime = time.time()
PHASE_LABEL = "Building Depth Maps"
chunk.buildDepthMaps(quality=Metashape.LowQuality, filter=Metashape.AggressiveFiltering, progress=progress_callback)
print_time_elapsed(phaseTime)
doc.save