Forum

Author Topic: Batch processing: Python  (Read 6847 times)

maddin

  • Full Member
  • ***
  • Posts: 161
    • View Profile
Batch processing: Python
« on: February 28, 2017, 04:00:17 PM »
Would be great to be able to use Python code as part of the Batch Process pipeline, e.g. by inserting a "Run Python code" element into the batch queue?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #1 on: February 28, 2017, 04:42:02 PM »
Hello maddin,

Run Script operation is already available in Batch Process dialog.
Best regards,
Alexey Pasumansky,
Agisoft LLC

maddin

  • Full Member
  • ***
  • Posts: 161
    • View Profile
Re: Batch processing: Python
« Reply #2 on: February 28, 2017, 04:48:18 PM »
Run Script operation is already available in Batch Process dialog.

Doh! I was looking at the online help (which did not have that command listed) but indeed it is already in the Job type list, at the very bottom...

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #3 on: February 28, 2017, 04:52:25 PM »
Hello maddin,

It's also in the batch task list of the PhotoScan Pro manual, but also in the very end of the list.
Best regards,
Alexey Pasumansky,
Agisoft LLC

maddin

  • Full Member
  • ***
  • Posts: 161
    • View Profile
Re: Batch processing: Python
« Reply #4 on: February 28, 2017, 04:55:13 PM »
It's also in the batch task list of the PhotoScan Pro manual, but also in the very end of the list.

Thanks!
Just to show that I did try to find this before posting: If you open the online help, type 'batch' into the search box, then select 'Automation' topic, you find a section called 'Batch processing' which has a list of operations, that does not contain any reference to running a script.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #5 on: February 28, 2017, 05:03:38 PM »
Maybe you've accidentally opened Standard edition manual? I think that Run Script was available in the version 1.2 already and the information was also included in Pro edition manual.

But anyway it's sorted out now.
Best regards,
Alexey Pasumansky,
Agisoft LLC

maddin

  • Full Member
  • ***
  • Posts: 161
    • View Profile
Re: Batch processing: Python
« Reply #6 on: February 28, 2017, 05:07:51 PM »
Maybe you've accidentally opened Standard edition manual? I think that Run Script was available in the version 1.2 already and the information was also included in Pro edition manual.

The information is indeed in the manual but not in the online help in .chm format.

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Batch processing: Python
« Reply #7 on: March 15, 2017, 01:05:40 PM »
Is anything possible regarding the other way around?

I mean, can a "Run Batch" be part of a Python Script?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #8 on: March 15, 2017, 01:13:45 PM »
Hello Thibaud,

Do you mean to import batch XML file via Python and treat it accordingly?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Batch processing: Python
« Reply #9 on: March 15, 2017, 01:24:04 PM »
Hello Alexey,

Any way would work, yes.

This mostly shows interest for version compatibility I'd say, when building the elements you need (Dense cloud, mesh etc.)
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #10 on: March 15, 2017, 01:34:14 PM »
Hello Thibaud,

The format of the XML file for the batch processing may change over time (when new arguments are added, for example), so the scripts may need the modifications when the newer versions are released.

So if the matter of the question is the need of scripts adapting to the newer releases, I don't think it would be solved, unless the development of Python API is freezed. At the moment we are trying to avoid major changes in API with the third number of PhotoScan release version, but with the second number there still could be some due to the changes in the internal representation fo the project, new features and functionality extension.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Batch processing: Python
« Reply #11 on: March 15, 2017, 01:47:22 PM »
Hello Alexey,

I did not consider possible changes in the XML format that may occur too, indeed.

Regarding script adaptation, is a backup compatibility possible? I mean, let 1.3 be able to fully read 1.2.x scripts, without making any change.

I'm using both versions depending on the workstation available, that's why I'm asking.
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #12 on: March 15, 2017, 02:07:18 PM »
Hello Thibaud,

When defining the set of the parameters for the processing functions you can use PhotoScan.app.version check and pass the parameters according to the actual version. Using scripts from the older versions is not always possible.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Batch processing: Python
« Reply #13 on: March 15, 2017, 02:10:29 PM »
Hello Alexey,

So you mean I could have a single script that'd call functions according to the PhotoScan.app.version return?
That'd be awesome!

What's the type of return? String?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Batch processing: Python
« Reply #14 on: March 15, 2017, 02:27:51 PM »
Hello Thibaud,

I mean something like the following:
Code: [Select]
if PhotoScan.app.version[:-2] == "1.1":
      ACCURACY = "High"
elif PhotoScan.app.version[:-2] in ["1.2", "1.3"]:
      ACCURACY = PhotoScan.Accuracy.HighAccuracy
else:
      print("Update PhotoScan")
      break

chunk.matchPhotos(accuracy = ACCURACY)
Best regards,
Alexey Pasumansky,
Agisoft LLC