I'd like to automatically save the (.psz) project files at the end of my scripted process so that I can return to them later on and manually edit the project if necessary. I am currently doing this with " doc.save(project_path)" at the end of my workflow, however the saved .psz file is very small and can't be opened. My full current workflow is this:
complete_file = os.path.join('/tmp', 'photoscan.txt')
blockw = 4096
blockh = 4096
app = PhotoScan.Application()
doc = PhotoScan.Document()
chunk = PhotoScan.Chunk()
for image in image_list:
print('Loading camera = {}'.format(image))
camera = PhotoScan.Camera()
camera.open(image)
chunk.cameras.add(camera)
count -= 1
if count == 0:
break
gc = PhotoScan.GroundControl(chunk)
gc.loadExif()
gc.apply()
crs = PhotoScan.CoordinateSystem()
crs.init('EPSG::4326') # WSG84
chunk.crs = crs
chunk.projection = crs
try:
open(complete_file, mode='w').write('matching')
chunk.matchPhotos(accuracy='high', preselection='ground control')
open(complete_file, mode='w').write('aligning')
chunk.alignPhotos()
# optimise alignment by limiting poor quality matches
open(complete_file, mode='w').write('restricting point reprojection error')
chunk.buildPoints(error=1)
# optimise camera params
open(complete_file, mode='w').write('optimising point cloud and camera parameters')
chunk.optimizePhotos()
open(complete_file, mode='w').write('building dense cloud')
chunk.buildDenseCloud(quality='high')
# chunk.decimateModel(100000)
open(complete_file, mode='w').write('building model')
chunk.buildModel(surface='height field', faces='high')
# chunk.model.closeHoles()
open(complete_file, mode='w').write('fixing topology')
try:
chunk.model.fixTopology()
except:
pass
open(complete_file, mode='w').write('building points')
chunk.buildPoints(error=1)
open(complete_file, mode='w').write('building texture')
chunk.buildTexture(blending='mosaic')
open(complete_file, mode='w').write('exporting report')
chunk.exportReport(report_path)
open(complete_file, mode='w').write('exporting model')
chunk.exportModel(model_path, format='3ds')
open(complete_file, mode='w').write('exporting points')
chunk.exportPoints(points_path, format='obj')
open(complete_file, mode='w').write('exporting ortho')
chunk.exportOrthophoto(orthophoto_path, blockw=blockw, blockh=blockh, color_correction=False, blending='mosaic', write_kml=True, write_world=True, projection=chunk.projection)
open(complete_file, mode='w').write('saving project')
doc.save(project_path)
open(complete_file, mode='w').write('done' + '\n' + 'success')
app = PhotoScan.Application()
app.quit()
except Exception as e:
open(complete_file, mode='w').write('error' + '\n' + str(e))
app = PhotoScan.Application()
app.quit()
The saved .psz file is only 189B and can't be opened after. Any ideas about how to save the full .psz file so I can open it manually in Photoscan later on would be greatly appreciated.
Thanks