Forum

Author Topic: "Error writing TIFF header" when building an orthomosaic in a python script  (Read 1524 times)

cbo

  • Newbie
  • *
  • Posts: 1
    • View Profile
Hi,

I have the following error when I try to build an orthomosaic in a python script:
Code: [Select]
libtiff error: Error writing TIFF header
RuntimeError: TIFFClientOpen: unexpected error: memory stream

Do you know why I could get this error? The weird thing is that when I execute the same code within the Metashape software with GUI, it goes fine.

Here is the code that I execute in the python script:
Code: [Select]
import Metashape
document = Metashape.Document()
document.open(folder + "project_before_ortho.psx", ignore_lock=True)

chunk = document.chunk
task = Metashape.Tasks.BuildOrthomosaic()
task.surface_data = Metashape.ModelData
task.blending_mode = Metashape.MosaicBlending
task.fill_holes = True
task.cull_faces = False
task.refine_seamlines = False
task.resolution_x = 0.001
task.resolution_y = 0.001
proj = Metashape.OrthoProjection()
proj.crs = Metashape.CoordinateSystem("LOCAL")
proj.matrix = Metashape.Matrix([
  [1.0, 0.0, 0.0, 0.0],
  [0.0, 0.0, 1.0, 0.0],
  [0.0, -1.0, 0.0, 0.0],
  [0.0, 0.0, 0.0, 1.0]
])
task.projection = proj
chunk.addOrthomosaic()
chunk.orthomosaic = chunk.orthomosaics[-1]
task.apply(chunk)

In the software, I just open Metashape and execute the same code, except for the first lines:
Code: [Select]
document = Metashape.app.document
document.open(folder + "project_before_ortho.psx", ignore_lock=True)
And as I said, when done in the Metashape software, I don't have the error and the orthomosaic is built...

Any help would be great!
Thanks a lot

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14943
    • View Profile
Hello cbo,

Do you have the libtiff error right on the script start?

I have tried to run exactly the same script as you do for a random project and it worked without any error. So can you please also specify, if the script started from the command line fails on any project, for example, a small project for testing purposes?
Best regards,
Alexey Pasumansky,
Agisoft LLC