Hi, I'm trying to write a script so that I can process my data on my home computer while I'm on my laptop. I've installed the standalone python module for 1.5.2 on my home windows computer but can't seem to run my scripts because there is no existing psx file to open. I'll get rid of the hard-coded filepaths later but I keep getting a NoneType error when trying to save the document and add the chunk.
import Metashape
import os
def process_imagery():
doc = Metashape.app.document
doc.save("S:\\ImageProcessing\AutoPhoto\ProcDoc.psx")
path_photos = "S:\\ImageProcessing\ProcessImagery\Test"
photo_export = 'S:\\ImageProcessing\ProcessImagery\MsExport'
# creating new chunk
if len(doc.chunks):
chunk = Metashape.app.document.chunk
else:
chunk = doc.addChunk()
chunk.label = 'New Chunk'
# loading images
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
if photo.rsplit(".", 1)[1].lower() in ["jpg", "jpeg", "tif", "tiff"]:
photo_list.append("/".join([path_photos, photo]))
chunk.addPhotos(photo_list)
# align photos
chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=False, reference_preselection=True)
chunk.alignCameras()
chunk.buildDepthMaps(quality=Metashape.MediumQuality, filter=Metashape.AggressiveFiltering)
chunk.buildDenseCloud()
chunk.buildModel(surface=Metashape.Arbitrary, interpolation=Metashape.EnabledInterpolation)
chunk.buildUV(mapping=Metashape.GenericMapping)
Metashape.app.update()
# export
chunk.exportModel(photo_export + '\\model.tif', format = 'tif')
print ('Processing complete')
doc.save()
process_imagery()