Forum

Author Topic: Using existing camera calibration parameters with user_calib not working.  (Read 3637 times)

mvol12

  • Newbie
  • *
  • Posts: 7
    • View Profile
Hi All,

I am trying to use the python interface to load in some pre calibrated cameras, but agisoft seems to fail when i use sensor.user_calib.

In the script (below), I create multiple camera objects and a sensor for each camera, then set the parameters, see below.
My array 'cameras' contains a camera objects with the measured focal length and principal points. 

I then use chunk.matchPoints and chunk.alignCameras but the script fails with 'Error: Can't align cameras'.

The parameters in the camera calibration window for all cameras show up as zero and not the parameters which I have set.

Am i missing some settings in user_calib ?

Code: [Select]
#Add Chunk
chunk = PhotoScan.app.document.addChunk()

#Create each camera
for index in range(0,len(cameras)):

#Create Camera and load image file
camera = chunk.addCamera();
photo_file = input_directory + "%03d/"%index + "%05d.png"%frame_index
camera.open(photo_file)
camera.label = "Camera %02d"%index
camera.sensor = chunk.addSensor();

#Create Sensor
camera.sensor.label = "Sensor %02d"%index
camera.sensor.width = cameras[index].width
camera.sensor.height = cameras[index].height

#Calibration
camera.sensor.user_calib    = PhotoScan.Calibration()
camera.sensor.user_calib.width = cameras[index].width
camera.sensor.user_calib.height = cameras[index].height
camera.sensor.user_calib.cx = cameras[index].cx
camera.sensor.user_calib.cy = cameras[index].cy
camera.sensor.user_calib.f  = cameras[index].fx

# Finally Fix the sensor parameters
camera.sensor.fixed = True

I have also validated that the details in cameras are correct

Kind regards,
Marco

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14858
    • View Profile
Hello Marco,

I can suggest two things, first is adding image using chunk.addPhotos() function, since it will create corresponding sensor automatically.
And the second is related to the calibration itself, you need to define the variable of PhotoScan.Calibration class first:
Code: [Select]
calib    = PhotoScan.Calibration()
calib.width = cameras[index].width
calib.height = cameras[index].height
calib.cx = cameras[index].cx
calib.cy = cameras[index].cy
calib.f  = cameras[index].fx
and then assign
Code: [Select]
camera.sensor.user_calib = calib
Best regards,
Alexey Pasumansky,
Agisoft LLC

mvol12

  • Newbie
  • *
  • Posts: 7
    • View Profile
Thanks Alexey,

I have kept the photo loading as before, but changing the way the calibration is initialised to the way you suggested, has  fixed the problem :)

Thanks,
Marco