Hi Alexey. I tried your suggestion. This is the code I used -
doc = PhotoScan.app.document
chunk = doc.addChunk()
chunk.addPhotos(images)
# image matching and alignment
for frame in chunk.frames:
frame.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection, keypoint_limit=40000, tiepoint_limit=1000) # HighestAccuracy
chunk.alignCameras()
realign_list = list()
for camera in chunk.cameras:
if not camera.transform:
realign_list.append(camera)
chunk.alignCameras(cameras = realign_list)
I have attached the output from the GUI & the API. As you can see the output from the GUI is still quite different from what I get from the API. What am I doing wrong?
For reference, this is the full orthophoto generation pipeline I'm using -
doc = PhotoScan.app.document
doc.save(project_psx_path)
# add photos
chunk = doc.addChunk()
chunk.addPhotos(images)
# image matching and alignment
for frame in chunk.frames:
frame.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection, keypoint_limit=40000, tiepoint_limit=1000) # HighestAccuracy
chunk.alignCameras()
realign_list = list()
for camera in chunk.cameras:
if not camera.transform:
realign_list.append(camera)
chunk.alignCameras(cameras=realign_list)
# dense point cloud
chunk.buildDenseCloud(quality=PhotoScan.HighQuality,filter=PhotoScan.MildFiltering) # quality=PhotoScan.UltraQuality
# build mesh
chunk.buildModel(surface=PhotoScan.HeightField, interpolation=PhotoScan.EnabledInterpolation, face_count=PhotoScan.MediumFaceCount, source=PhotoScan.DenseCloudData) # classes provide control on which kind of terrain we are mapping
# build UV
chunk.buildUV(mapping=PhotoScan.OrthophotoMapping)
# build texture
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=8192)
doc.save()
# build orthophoto
chunk.buildOrthomosaic()
# export orthophoto
orthophoto_path = "{0}/{1}_ortho.tif".format(project_files_path, project_name)
chunk.exportOrthomosaic(path=orthophoto_path, jpeg_quality=99)
# resize for easier viewing
orthophoto = cv2.imread(orthophoto_path)
orthophoto_resized = cv2.resize(orthophoto, (0, 0), fx=0.5, fy=0.5)
cv2.imwrite(orthophoto_path, orthophoto_resized)
# report_path = "{0}/{1}_report.pdf".format(project_files_path, project_name)
# chunk.exportReport(path=report_path, title="API Processing Report")
t2 = time.time()
print("Time Taken : {} seconds".format(t2-t1))