Forum

Author Topic: importPoints does nothing when running headless  (Read 1961 times)

jbak9141

  • Newbie
  • *
  • Posts: 18
    • View Profile
importPoints does nothing when running headless
« on: May 28, 2019, 03:35:09 PM »
Hi Alexey,

I've run into a strange issue that seems to affect Metashape when running headless that I'm hoping you can help with.

I have a simple Python script that does the following (please ignore any small typos below as I've pulled out the relevant functionality to keep it brief.

Code: [Select]
    chunk = Metashape.app.document.chunk
    chunk.crs = Metashape.CoordinateSystem('EPSG::28356')
    chunk.updateTransform()
    format = Metashape.PointsFormat.PointsFormatLAS
    chunk.importPoints(path='/Users/guest/example.las',
                       format=format,
                       projection=chunk.crs
                       )
    chunk.updateTransform()
    chunk.resetRegion()
    Metashape.app.document.save('/Users/guest/test.psx')


When I run this code line by line via the Python console on Mac OS X, the pt cloud imports and is visible in the chunk.

When I run Metashape headless on Linux, I am left with an empty project with nothing in it. The operation otherwise seems to complete extremely quickly without logging any errors.

Metashape is run using the following system call

Code: [Select]
./metashape.sh -r my_script.py -platform offscreen
Any ideas why this could be happening?

I also noticed that the help documentation around metashape.sh does not seem to make any mention of the "-platform" option on Linux. Is there somewhere we can see the comprehensive list of options that "metashape.sh"?

Thanks,

J

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14816
    • View Profile
Re: importPoints does nothing when running headless
« Reply #1 on: May 28, 2019, 07:07:48 PM »
Hello jbak9141,

Please try to modify your headless script in the following way and check, if it gives you a proper result:

Code: [Select]
    import Metashape
    doc = Metashape.Document()
    chunk = doc.addChunk()
    chunk.crs = Metashape.CoordinateSystem('EPSG::28356')
    #chunk.updateTransform()
    p_format = Metashape.PointsFormat.PointsFormatLAS
    chunk.importPoints(path='/Users/guest/example.las',
                       format=p_format,
                       projection=chunk.crs
                       )
    #chunk.updateTransform()
    chunk.resetRegion()
    doc.save('/Users/guest/test.psx')

I've also renamed your "format" variable, as format - is usually a reserved word in Python.
Best regards,
Alexey Pasumansky,
Agisoft LLC