Forum

Author Topic: Memory spikes during buildOrthomosaic crashing ps (but not for older version)  (Read 6978 times)

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
I'm having some trouble with very high memory spikes during the buildOrthomosaic processing step that is actually crashing / failing photoscan for some projects (this doesn't happen for all projects).  I'm running version 1.2.2, and don't seem to have the same issue when running an older version of the software (1.1.6).

For example, for a relatively small project (99 images / 500MB) with version 1.2.2, I'm seeing a large memory spike up to about 50GB, but when running version 1.1.6 the memory usage never rose above about 14GB.  Here's a link to the input images if you want to replicate: https://www.dropbox.com/s/ysmjsuahw5nsagt/sample_images.zip?dl=0

My workflow for 1.2.2 is as follows:

Code: [Select]
import PhotoScan

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

chunk = doc.addChunk()
chunk.addPhotos(image_list)
chunk.loadReferenceExif()
coord_system = PhotoScan.CoordinateSystem('EPSG::4326')
chunk.crs = coord_system

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

chunk.buildDenseCloud(quality=PhotoScan.MediumQuality, 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=16)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

doc.save(path=new_project_path, chunks=[chunk])
doc = PhotoScan.Document()
doc.open(new_project_path)
chunk = doc.chunk
chunk.buildOrthomosaic()
chunk.exportOrthomosaic(ortho_path, projection=chunk.crs)
chunk.buildDem(source=PhotoScan.DenseCloudData)
chunk.exportDem(dem_path, projection=chunk.crs)

doc.save(path=project_path, chunks=[chunk])
app.quit()

My workflow for 1.1.6 is as follows:

Code: [Select]
import PhotoScan

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

chunk = PhotoScan.Chunk()
doc.addChunk(chunk)
chunk.addPhotos(image_list)
chunk.loadReferenceExif()
coord_system = PhotoScan.CoordinateSystem('EPSG::4326')
chunk.crs = coord_system

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

chunk.buildDenseCloud(quality=PhotoScan.MediumQuality, filter=PhotoScan.AggressiveFiltering)
chunk.buildModel(surface=PhotoScan.HeightField, source=PhotoScan.DensePoints, face_count=PhotoScan.HighFaceCount, interpolation=PhotoScan.EnabledInterpolation)
chunk.model.closeHoles()
chunk.model.fixTopology()
chunk.buildUV(mapping=PhotoScan.GenericMapping, count=16)  # try different mapping modes
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

chunk.exportOrthophoto(ortho_path, color_correction=False, blending=PhotoScan.MosaicBlending, projection=chunk.crs)
chunk.exportDem(dem_path, projection=chunk.crs)

doc.save(project_path)
app.quit()

 Is this a known issue / can I change my 1.2.2 workflow to avoid such high memory usage?

Any help greatly appreciated.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15424
    • View Profile
Hello Jeremy,

I'm downloading the images and will try to reproduce the issue (I believe that you've got the same issue, while running Build Orthomosaic from the GUI?). Meanwhile I can suggest to install version 1.2.4 and see, if the there's the same issue.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Thanks for the quick response as always Alexey!

I've actually just re-processed the project on 1.2.2 and this time it processed successfully (but again with a large memory spike during the buildOrthomosaic stage), so not sure if you'll be able to reproduce the crash I experienced previously.

Would you expect a large memory spike during the exportOrthomosaic stage (at least 2x the max memory used in other stages)? Would this be different in 1.2.4? This is not something I came across with the earlier version, so just wondering if I should be doing something different to avoid this behaviour with the newer versions of the software.

Thanks for your help,

Jeremy

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15424
    • View Profile
Hello Jeremy,

What is the number of polygons in the model you are using as a surface for the orthomosaic generation? I can also suggest to build DEM first and use it as a surface for the orthomosaic generation.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jeremyeastwood

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Hi Alexey,

I use the max number of faces for the polygon (not sure how many for this particular case, but this can be several million for larger projects):

Code: [Select]
chunk.buildModel(surface=PhotoScan.HeightField, source=PhotoScan.DenseCloudData, face_count=PhotoScan.HighFaceCount, interpolation=PhotoScan.EnabledInterpolation)
Would you suggest building DEM first and using that as a surface for the ortho as a sensible approach?  Will it affect orthomosaic quality at all (especially for things like vertical surfaces)?

Thanks again for your help