Forum

Author Topic: Externally Run Agisoft PhotoScan with Python  (Read 4072 times)

cvernon3

  • Newbie
  • *
  • Posts: 4
    • View Profile
Externally Run Agisoft PhotoScan with Python
« on: June 13, 2017, 08:47:56 PM »
Hi, I've read a few posts about doing this but haven't been able to figure it out.

I can open agisoft externally no problem importing os and can essentially run the python scripts I want by clicking on the tools menu, the run script button, and then manually selecting the path I need to run the code I want; however, I would like to be able to simply tell a python program to first open agisoft, click the tools menu, click run script, and insert the path to my other scripts. In other words I would like to make it be fully automated

I was thinking that the command line might be a way to do this (or some type of macro), but was wondering if there is a simpler solution (ie. some function that clicks menu items that has already been made without having to import PhotoScan)

Thanks for the help!

-cvernon3

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14099
    • View Profile
Re: Externally Run Agisoft PhotoScan with Python
« Reply #1 on: June 13, 2017, 08:53:16 PM »
Hello cvernon3,

Version 1.3 allows to run the script from the command line:

On Windows:
photoscan.exe -r <scriptname.py>
On Linux:
./photoscan.sh -r <scriptname.py>
On Mac OS X:
./PhotoScanPro.app/Contents/MacOS/PhotoScanPro -r <scriptname.py>

Optionally you can pass the arguments to the script.
Best regards,
Alexey Pasumansky,
Agisoft LLC

cvernon3

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Externally Run Agisoft PhotoScan with Python
« Reply #2 on: June 16, 2017, 06:19:55 PM »
Thanks,

by running:

import subprocess
subprocess.run("C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe)

It opens PhotoScan but will not run my other python files automatically when I use:

subprocess.run("C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe <filename.filetype>")

However, using tools, run script I can manually run that same file. I read somewhere that the document class is blocked on code that occurs when agisoft is opening, so I am wondering if there is a workaround to this (ie. code beneath the subprocess function that opens photoscan that will then call the other python files I want to import photos, run the batch process, and export the model / or some command prompt input that lets me get around this issue).

Thanks again!

Sincerely,

cvernon3

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14099
    • View Profile
Re: Externally Run Agisoft PhotoScan with Python
« Reply #3 on: June 16, 2017, 06:33:32 PM »
Hello cvernon3,

Wouldn't it be more convenient to have just single "master" script that can be called externally like in the example that I've provided above? Or it is critical, by any reason, to open the GUI?
Best regards,
Alexey Pasumansky,
Agisoft LLC