Forum

Author Topic: get current Optimize Camera parameters  (Read 7859 times)

davesc

  • Newbie
  • *
  • Posts: 2
    • View Profile
get current Optimize Camera parameters
« on: September 05, 2017, 09:29:18 PM »
Does anyone know how to get the current parameters used in Optimize Cameras?  In my script I would like to keep the last parameters specified by the user when I call
Code: [Select]
chunk.optimizeCameras([params])

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15420
    • View Profile
Re: get current Optimize Camera parameters
« Reply #1 on: September 05, 2017, 09:50:51 PM »
Hello davesc,

You can find the list of the optimized parameters for the active chunk (as a string) using the following line:
Code: [Select]
PhotoScan.app.document.chunk.meta['optimize/fit_flags']
The list of last parameters used for the optimization is not stored anywhere at the moment, since PhotoScan suggest to optimize parameters that have non-zero adjusted values (or when initial focal length is different from adjusted).
Best regards,
Alexey Pasumansky,
Agisoft LLC

davesc

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: get current Optimize Camera parameters
« Reply #2 on: September 05, 2017, 11:23:28 PM »
Thanks Alexey, that's exactly what I was looking for

Mycobiont

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: get current Optimize Camera parameters
« Reply #3 on: February 03, 2021, 08:17:21 PM »
With the shift to Metashape, I think this may have changed?  The following code errors on the lack of a .find method.

Code: [Select]
optParams = Metashape.app.document.chunk.meta['optimize/fit_flags']
chunk.optimizeCameras(fit_f =  (optParams.find('f') > 1))
/code]
« Last Edit: February 03, 2021, 08:24:31 PM by Mycobiont »

Paulo

  • Hero Member
  • *****
  • Posts: 1495
    • View Profile
Re: get current Optimize Camera parameters
« Reply #4 on: February 03, 2021, 09:23:26 PM »
I think you shoud use

 
Code: [Select]
optParams = Metashape.app.document.chunk.meta['OptimizeCameras/fit_flags']
chunk.optimizeCameras(fit_f =  (optParams.find('f') >=  0))
Best Regards,
Paul Pelletier,
Surveyor

Mycobiont

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: get current Optimize Camera parameters
« Reply #5 on: February 04, 2021, 08:26:51 AM »
One more note: I just found that I continue to get "Error: 'NoneType' object has no attribute 'find'" if I run my code before having run the standard Optimization tool in MetaShape.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15420
    • View Profile
Re: get current Optimize Camera parameters
« Reply #6 on: February 05, 2021, 12:09:47 AM »
Hello Mycobiont,

You can use .find after the check, that 'OptimizeCameras/fit_flags' exists in chunk.meta.key(), or just use try-except concept when calling .find method (which assumes to be applied to the string).
Best regards,
Alexey Pasumansky,
Agisoft LLC