Forum

Author Topic: How to run a .py Script  (Read 2646 times)

bgreenstone

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
How to run a .py Script
« on: September 29, 2021, 04:25:24 AM »
I keep seeing references to the ability to run a Python script from the Tools menu or from a Batch, but I'm not seeing it.  Is this feature not available in the Standard version of Metashape?

Thanks,

-Brian

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: How to run a .py Script
« Reply #1 on: September 29, 2021, 12:05:36 PM »
Hello Brian,

Python scripting is available in Professional edition only.
Best regards,
Alexey Pasumansky,
Agisoft LLC

bgreenstone

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: How to run a .py Script
« Reply #2 on: September 29, 2021, 03:52:41 PM »
Bummer  :(   So, on a related note, is there any way with the Standard version to automate the process of removing tie points and optimizing the camera parameters?  I found a great Python script online for doing this:  https://figshare.com/articles/code/Agisoft_Metashape_Python_Script_to_Automate_Gradual_Selection_Camera_Optimization_and_Error_Reduction_Steps/10325909

Unfortunately, I cannot run it with my Standard version of MetaShape.  I really wish that this capability (a more simplified version) was available as a Batch option.  If the Batch option had a simple dialog with simple options for performing this cleanup/optimization task it would really be helpful.

I wish I could afford the Pro version, but my little home 3D printing business doesn't even make as much as MetaShape Pro costs :(

Thanks,

-Brian

BetaTest

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to run a .py Script
« Reply #3 on: September 30, 2021, 08:48:54 PM »
Hi Brian,
Although I don't have a suggestion to get around the limits of the "Standard" version -- the steps taken by the script you linked are not exceptionally time-consuming.

The gradual selections are obvious near real-time and although the first optimization takes a couple minutes for a couple thousand photos, subsequent runs are very fast.

One key thing to consider / speed the process:  When optimizing -- the script does not check the boxes for B1, B2, K4, P3, P4, Adaptive, Covariance, or Additional Corrections (for the first two gradual-selections).  On the third gradual-selection (Reprojection Error) you will select the Adaptive option (disabling all others).  With these settings, your first two attempts should be expedited and your third attempt will be faster, despite the extra processing, because the images are much more optimized prior to the operation.

In short, while I agree, it would be extremely valuable to add "Gradual Selection" to the "Batch" feature, at least you can replicate this script without too much time.

Also, this script appears to use Reconstruction Uncertainty at 15, Projection Accuracy at 15 (typically I believe 5 is a better range for this, if it doesn't remove too many tie-points), and Reprojection Error iterates up to four times to reach 0.20 starting at 10.

Sorry I don't have a better option, but I hope this helps :)

bgreenstone

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: How to run a .py Script
« Reply #4 on: September 30, 2021, 08:53:28 PM »
Thanks!  Very helpful info!  The main reason I'm hoping to automate it is because I often Batch process these things for multiple scans overnight.  I load up a bunch of scans into different Chunks and then let the Batch go to work on it while I'm asleep.  If I have to break it up and do any of it manually it nixes that :(

-Brian

BetaTest

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to run a .py Script
« Reply #5 on: September 30, 2021, 09:07:02 PM »
I often Batch process these things for multiple scans overnight.
Hi Brian, I couldn't agree more.  I do the exact same thing (and I assume many others do as well).

Because "Gradual Selection" is so integral in the Metashape workflow, I am surprised it is not part of the "Batch" features.

My assumption has always been that it might not be, due to many people changing the values based on the output of each.  No two projects are the same and to get the best output, people often tweak the amount the "gradually select".

None the less, there are many times where we might be re-running a project where we know the values, or running an initial rendering/test to get masks or an idea of where things lie, etc.

For all these reasons and more, I do agree, it's still very valuable to have gradual-selection added to the batch tool!

bgreenstone

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: How to run a .py Script
« Reply #6 on: September 30, 2021, 09:40:53 PM »
It seems like Metashape should have the ability to do all of this on its own.  I mean it already does various forms of filtering on its own, so why not have another filter setting that lets it do all if this automatically under the hood?  While it’s nice to have manual control too, it seems a pretty simple algorithm could figure out how to get pretty darn close to what a human would choose to do manually.