Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Henry on April 19, 2018, 04:12:55 AM

Title: How to save project as PSX in python script (For building DEM and Ortho)
Post by: Henry on April 19, 2018, 04:12:55 AM
I'm trying to build a DEM and Ortho in a python script, but I keep running into this error:

Code: [Select]
LoadProject: path = /workspace/project.psx
loaded project in 0.005241 sec
BuildDem: projection = WGS 84, source data = Dense cloud, interpolation = Enabled, resolution = 0
Please save project in PSX format before processing
Traceback (most recent call last):
  File "test.py", line 35, in <module>
    projection=PhotoScan.CoordinateSystem("EPSG::4326"))
RuntimeError: Empty frame path

Here is the snippet from my script:

Code: [Select]
doc.save("/workspace/project.psx")
chunk.buildDem(source=PhotoScan.DataSource.DenseCloudData,
               interpolation=PhotoScan.EnabledInterpolation,
               projection=PhotoScan.CoordinateSystem("EPSG::4326"))

It looks to me like I am saving it in PSX format before trying to build the DEM, so what's the problem?
Title: Re: How to save project as PSX in python script (For building DEM and Ortho)
Post by: Geend on April 24, 2018, 03:48:07 PM
You need to save the document with doc.save()
So without the path parameter before building the dem or orthophoto. For whatever reason doc.save("path") and doc.save() do different things...


Code: [Select]
doc.save("/workspace/project.psx")
doc.save()
chunk.buildDem(source=PhotoScan.DataSource.DenseCloudData,
               interpolation=PhotoScan.EnabledInterpolation,
               projection=PhotoScan.CoordinateSystem("EPSG::4326"))

Should work.
Title: Re: How to save project as PSX in python script (For building DEM and Ortho)
Post by: Alexey Pasumansky on April 24, 2018, 04:56:06 PM
Hello,

Saving document with path parameter works as "save as" option, so after that you need to re-assign the chunk variable, if it has been previously defined, for example:
Code: [Select]
doc.save(path)
chunk = doc.chunks[0]
chunk.buildDem()