Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: LDBL on December 22, 2018, 01:49:51 AM

Title: reset_alignment
Post 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;

Code: [Select]
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
Title: Re: reset_alignment
Post by: Alexey Pasumansky on December 23, 2018, 07:58:30 PM
Hello Leon,

If reset_alignment parameter doesn't work, please try to use the following code:
Code: [Select]
for camera in chunk.cameras:
    camera.transform = None
But please specify, which version of PhotoScan you are using?
Title: Re: reset_alignment
Post by: LDBL on January 08, 2019, 12:29:42 PM
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
Title: Re: reset_alignment
Post by: LDBL on January 08, 2019, 12:37:13 PM
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;

Code: [Select]
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
Title: Re: reset_alignment
Post by: Alexey Pasumansky on January 08, 2019, 07:56:01 PM
Hello Leon,

Please try this:

Code: [Select]
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')
Title: Re: reset_alignment
Post by: LDBL on January 08, 2019, 10:01:46 PM
That's fixed it.

Legend, thank you!
Title: Re: reset_alignment
Post by: Eckemon on October 16, 2020, 01:08:32 PM
- fixed -
my fault :)