Forum

Author Topic: do I have to save and re-load the project before calling chunk.buildOrthomosaic?  (Read 4974 times)

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
I had some difficulty replicating my 1.1.6 workflow with the new 1.2.x api, but managed to get it working by saving the project in .psx format then re-loading before calling the new chunk.buildOrthomosaic() method.  Is this the correct way to go about ortho export, or is there a cleaner method?  Will this be changing with future releases?

My workflow is summarised below:

Code: [Select]
import PhotoScan
import glob

images = glob.glob('/path/to/project/directory/images/*.jpg')
ouput_path = '/path/to/project/directory/'


app = PhotoScan.Application()
doc = PhotoScan.Document()
chunk = doc.addChunk()

chunk.addPhotos(images)
chunk.loadReferenceExif()

coord_system = PhotoScan.CoordinateSystem('EPSG::4326')
chunk.crs = coord_system

chunk.matchPhotos(accuracy=PhotoScan.LowAccuracy, preselection=PhotoScan.ReferencePreselection, tiepoint_limit=10000)
chunk.alignCameras()

chunk.optimizeCameras()

chunk.buildDenseCloud(quality=PhotoScan.LowQuality, filter=PhotoScan.AggressiveFiltering)

chunk.buildModel(surface=PhotoScan.HeightField, source=PhotoScan.DenseCloudData, face_count=PhotoScan.HighFaceCount, interpolation=PhotoScan.EnabledInterpolation)

chunk.model.closeHoles()
chunk.model.fixTopology()

chunk.buildUV(mapping=PhotoScan.GenericMapping, count=4)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

doc.save(path=ouput_path + 'project.psx', chunks=[chunk])

doc = PhotoScan.Document()
doc.open(ouput_path + 'project.psx')
chunk = doc.chunk

chunk.buildOrthomosaic()
chunk.buildDem(source=PhotoScan.DenseCloudData)

chunk.exportOrthomosaic(ouput_path + 'ortho.tif')

chunk.exportDem(ouput_path + 'dem.tif')

chunk.exportPoints(ouput_path + 'points.las', source=PhotoScan.DenseCloudData, format='las')

chunk.exportModel(ouput_path + 'model.obj', texture_format='jpg', texture=True, format='obj')

app.quit()

Any suggestions on how to improve it based on the new api also very welcome

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Apparently this is the new way to go, doc.save(path, doc.chunks) works as 'save as' and doc.save() works as 'save'. So you have to 'save as' and reload the first time you create the project file then simply 'save'.

Code: [Select]
# Create project file
doc.save(project_path, chunks = doc.chunks)
doc.open(project_path)
chunk = doc.chunk

# Do some process

# Save project
doc.save()

3DWinter

  • Full Member
  • ***
  • Posts: 103
    • View Profile
I have tried anything I can think of including the above posts, and I am still cannot process a DEM.
Code: [Select]
[code]---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-15-cf6332dcacb4> in <module>
      1 #doc.open(project_name)
----> 2 chunk.buildDem(source_data=Metashape.DenseCloudData)

RuntimeError: Empty frame path

[/code]

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Hello 3DWinter,

Orthomosaic, DEM and tiled model can be only generated and saved in the PSX file format.

I suggest to save the project in PSX format from the very beginning (right after creating Metashape.Document instance) and then just call doc.save() method without path argument.
Best regards,
Alexey Pasumansky,
Agisoft LLC

3DWinter

  • Full Member
  • ***
  • Posts: 103
    • View Profile
Thanks for that Alexey,
Using PSX file format and not PSZ solved my problem.

What is the purpose of PSZ does it take smaller space (compressed)?
thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Hello 3DWinter.

PSZ format is the original project format used in older PhotoScan versions, when there was no support for tiled model, DEM and orthomosaic display in the application as a part of the project.
As for now, sometimes it is easier to share the project as a single file, rather than packing PSX folder structure.

Other limitations of PSZ - it cannot be used for network or cloud processing and could not benefit from the fine-level task subdivision for most of tasks. Additionally loading and saving large projects could take considerable amount of time, as the archive should be unpacked and loaded to memory (on load) or the project should be re-written completely (on save), whereas PSX project on save only updates the modified files.
Best regards,
Alexey Pasumansky,
Agisoft LLC