Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: IanManning on February 24, 2016, 09:40:18 PM

Title: Pass a string variable to PhotoScan as a parameter !!!RESOLVED!!!
Post by: IanManning on February 24, 2016, 09:40:18 PM
Hi Folks,

Working on some scripting and have run into a road-block. I've got a script set-up to re-cursively test accuracy settings for the initial alignment.

I've got a list containing the Accuracy Settings (PhotoScan.HighAccuracy, PhotoScan.MediumAccuracy)

When I try to pass one of these values to the matchPhotos parameter I get the error

2016-02-24 14:30:08 TypeError: argument 1 must be PhotoScan.Accuracy, not str

I understand the error, the program doesn't want a string (which is what I'm serving it from the list) via my iterator. Is there a way to get around this, by somehow converting my string into something PhotoScan will accept?

I've made a separate version of the script where the accuracy settings are hard coded that works fine as a back-up. I just want to clean this up, so I can make quicker changes as required.

Thank you,
Ian

Title: Re: Pass a string variable to PhotoScan as a parameter
Post by: Alexey Pasumansky on February 25, 2016, 12:13:41 AM
Hello Ian,

Can you post the line where you define the list with the parameters?
Title: Re: Pass a string variable to PhotoScan as a parameter
Post by: Gall on February 25, 2016, 12:01:59 PM
You can convert a string parameter to an actual PhotoScan.Accuracy parameter this way:
Code: [Select]
PhotoScan.Accuracy.values[accuracy]where accuracy can be one the following values.
Code: [Select]
['HighestAccuracy', 'HighAccuracy', 'MediumAccuracy', 'LowAccuracy', 'LowestAccuracy']
This actually works for all enum classes.
Title: Re: Pass a string variable to PhotoScan as a parameter
Post by: IanManning on February 25, 2016, 05:02:46 PM
Thank you Alexey and Gall for responding.

@Gall, that worked perfectly, thank you for the suggestion! I knew there had to be a way to get at that functionality.

.value worked like a charm. Script looks much better, and allows for easily changing structure.

Thanks again,
Ian