Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: vicviod on June 07, 2017, 06:31:29 AM

Title: "Error: Empty Frame Path" when building orthomosaic (PhotoScan 1.2.0)
Post by: vicviod on June 07, 2017, 06:31:29 AM
Hello,
I am trying to automate the processing of a chunk (aligning photos,  building dense point cloud, generating mesh, adding texture, building orthomosaic, and exporting the orthomosaic)

However, when I try to build the orthomosaic, I get "error: empty frame path"

Here is my code:

Code: [Select]
import PhotoScan
import os
import sys

doc = PhotoScan.app.document
chunk = doc.chunk
doc.chunk.crs = PhotoScan.CoordinateSystem("EPSG::4326")

imagePath = sys.argv[1]

chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.ReferencePreselection)
chunk.alignCameras()
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation)
chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)
doc.save(path=os.path.join(imagePath, "test.psx"))

# Problem area
chunk.buildOrthomosaic(surface=PhotoScan.DataSource.ModelData, blending=PhotoScan.BlendingMode.MosaicBlending)
chunk.exportOrthomosaic(os.path.join(imagePath, "orthomosaic.tif"), format='tif')

It works until the saving of the file as a psx. Then I get the error when I try to build the orthomosaic.

I read somewhere that I should try to save the document before doing the processing steps, but when I tried that the outputs of the processing steps (tie points, dense point cloud, model, etc.) were not being added to the chunk, and when I tried to build the orthomosaic I got "Error: bad allocation"

I am using PhotoScan 1.2.0, and at the moment I am unable to change versions. How can I fix this?
Title: Re: "Error: Empty Frame Path" when building orthomosaic (PhotoScan 1.2.0)
Post by: Alexey Pasumansky on June 07, 2017, 11:31:30 AM
Hello vicviod,

"Empty frame path" means that the chunk that you are using to generate the orthomosaic is not saved.
When you use doc.save(path) method it works similar to "Save as" operation from the interface - the project is saved and re-opened, so you need to re-assign chunk = doc.chunk after using that operation, or alternatively, save the document in the very beginning of the script and then just use doc.save() without any arguments, it will act as simple save operation under the same name.
Title: Re: "Error: Empty Frame Path" when building orthomosaic (PhotoScan 1.2.0)
Post by: vicviod on June 08, 2017, 04:43:41 AM
Thanks! This fixed the problem.