Forum

Author Topic: Finish half-processed Projects via API  (Read 1206 times)

Sparkling_Water

  • Newbie
  • *
  • Posts: 6
    • View Profile
Finish half-processed Projects via API
« on: March 19, 2022, 09:24:33 PM »
Hi
I've got a bunch of projects where we did the data import and geo-tagging manually and I would like to do the DEM and Orthomosaic via API, as it is less clicking than the batch method. I can re-open and re-save a half-finished project with the my code, but afterwards it gets stuck.
I was wondering whether this is possible, since all the codes I have reviewed in the forum start with importing the photos and forming the chunks, whereas I already have my photos aligned in one chunk. I keep getting error messages related to the chunk and the data source.

Thank you

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Finish half-processed Projects via API
« Reply #1 on: March 21, 2022, 05:06:32 PM »
Hello Sparkling_Water,

If you need to apply only a certain part of the complete workflow to your projects, than in the script you need to remove the part that loads images, coordinate data and aligns the cameras, instead open the existing project and start from optimization (if needed) or directly from the depth maps generation.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Sparkling_Water

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Finish half-processed Projects via API
« Reply #2 on: March 22, 2022, 04:20:49 PM »
Thank you!

I've tried and so far it opens the project and makes it readable with a small workaround that I found in this forum

Code: [Select]
i = "***\test.psx"
path = i
doc = Metashape.app.document
doc.open(path, read_only=True)
doc.read_only = False
doc = Metashape.app.document
doc.open(path, read_only=False)
#save
doc.save()

(I've got this from https://www.agisoft.com/forum/index.php?topic=9324.0 )

then, when I try to build the DEM with

Code: [Select]
buildDem(source=Metashape.PointCloudData, interpolation=Metashape.EnabledInterpolation) or
Code: [Select]
chunk.buildDem(source=Metashape.PointCloudData, interpolation=Metashape.EnabledInterpolation)
I get the errors
NameError: name 'chunk' is not defined or NameError: name 'buildDem' is not defined

so I tried to select the chunk but didn't manage without building it. But I just want the half-finished project that is already sitting in the chunk (usually there is only 1 chunk).

How can I fix this?

Thanks



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Finish half-processed Projects via API
« Reply #3 on: March 22, 2022, 05:10:04 PM »
Hello Sparkling_Water,

If there's only single chunk in the project, then after the project open with doc.open() you need to make the following assignment:
Code: [Select]
chunk = doc.chunk
Best regards,
Alexey Pasumansky,
Agisoft LLC

Sparkling_Water

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Finish half-processed Projects via API
« Reply #4 on: March 22, 2022, 05:54:22 PM »
Thanks!
That helps, it's now working!

 :)