Forum

Author Topic: Uploading camera calibration from external file via Python API  (Read 6418 times)

ingenuity2020

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hi, I'm trying to upload camera calibration data from Kalibr into Metashape. I have the camera calibration file currently in the correct Metashape XML format. I'm operating in headless mode so want everything to run through a Python script. How do I upload these calibration parameters to all cameras for a chunk, without having to individually set each calibration parameter?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: Uploading camera calibration from external file via Python API
« Reply #1 on: July 25, 2023, 04:20:18 PM »
Hello ingenuity2020,

I would suggest the following code:

Code: [Select]
import Metashape
doc = Metashape.Document()
doc.open(project_path)
chunk = doc.chunk
sensor = chunk.sensors[0] #first calibration group in the active chunk
calib = Metashape.Calibration()
calib.width = sensor.width
calib.height = sensor.height
calib.load(calibration_path, format = Metashape.CalibrationFormatXML)
sensor.user_calib = calib


[/code]
Best regards,
Alexey Pasumansky,
Agisoft LLC