Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: LDBL on December 22, 2018, 01:49:51 AM
-
Hello collective,
I'm trying to emulate the "reset current alignment" option in the GUI.
Essentially, I have a 'base' model I need to rebuild multiple times with different setting via python, but to do so, I need to be able to reset the current alignment each time.
My code thus far is;
import PhotoScan
doc = PhotoScan.app.document
doc.open('XXX.psz')
chunk = doc.chunk
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True, reference_preselection=False, keypoint_limit=40000, tiepoint_limit=4000)
chunk.alignCameras(reset_alignment=True)
doc.save('XXX.psz')
But this fails. Selecting to reset alignment in the GUI works fine.
Any help please?
Thanks,
Leon
-
Hello Leon,
If reset_alignment parameter doesn't work, please try to use the following code:
for camera in chunk.cameras:
camera.transform = None
But please specify, which version of PhotoScan you are using?
-
Hi Alexey,
Thanks for your quick reply, and apologies for my slow response.
To confirm, I'm using 1.4.3.
Will try the amended script now.
Cheers,
Leon
-
OK, so I've amended the code and tried running it and I'm still not getting a rebuild in the same way as with the GUI.
Is there something else I'm missing?!
Code is;
import PhotoScan
doc = PhotoScan.app.document
doc.open('/mnt/w/Coverack_PP/C1/C1_base_MA_TPA.psz')
chunk = doc.chunk
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True, reference_preselection=False, keypoint_limit=40000, tiepoint_limit=4000)
for camera in chunk.cameras:
camera.transform = None
doc.save('/mnt/w/Coverack_PP/C1/C1_40k_4k.psz')
Cheers,
Leon
-
Hello Leon,
Please try this:
import PhotoScan
doc = PhotoScan.app.document
doc.open('/mnt/w/Coverack_PP/C1/C1_base_MA_TPA.psz')
chunk = doc.chunk
chunk.point_cloud = None
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True, reference_preselection=False, keypoint_limit=40000, tiepoint_limit=4000)
for camera in chunk.cameras:
camera.transform = None
chunk.alignCameras(adaptive_fitting = False)
doc.save('/mnt/w/Coverack_PP/C1/C1_40k_4k.psz')
-
That's fixed it.
Legend, thank you!
-
- fixed -
my fault :)