Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: mindful_drone on June 03, 2022, 01:44:38 PM

Title: Access Tweaks outside of Metashape GUI?
Post by: mindful_drone on June 03, 2022, 01:44:38 PM
Hi Alexey, all,

Is there a way to set tweaks flags using the Python API outside of the Metashape application/GUI?

I'd like to use the tweak to use the old depth maps functionality (specifically BuildDepthMaps/pm_enable) in a Python script, but the settings don't actually update outside of the GUI/application environment when I set them.

Screenshots attached to show behaviour inside vs outside of the GUI. From the GUI in white, and outside of GUI in dark mode.
Title: Re: Access Tweaks outside of Metashape GUI?
Post by: Alexey Pasumansky on June 03, 2022, 03:42:30 PM
Hello mindful_drone,

In Python API you can use tweaks for the processing operations as hidden parameters of the processing tasks, see the example below:

Code: [Select]
task = Metashape.Tasks.BuildDepthMaps()
task.downscale = 2
task.filter_mode = Metashape.FilterMode.MildFiltering
task["pm_enable"] = "0"
task.apply(chunk)
Title: Re: Access Tweaks outside of Metashape GUI?
Post by: Paulo on June 03, 2022, 04:28:09 PM
Hi Alexey,

What does
Code: [Select]
task["pm_enable"] = "0"
mean? pm_enable True or False

PS. I got the answer
Code: [Select]
task["pm_enable"] = "0" # PM_version False
task["pm_enable"] = "1" # PM_version True
Title: Re: Access Tweaks outside of Metashape GUI?
Post by: Alexey Pasumansky on June 06, 2022, 03:18:47 PM
Hello Paul,

Yes, that is correct.

Boolean type (true/false) tweaks should be defined as "0" or "1" string values via Python, where "0" is False and "1" - True.
Title: Re: Access Tweaks outside of Metashape GUI?
Post by: mindful_drone on June 09, 2022, 04:54:21 PM
Hi Alexey,

This saved us so much trouble, thank you so much!

Best regards