Forum

Author Topic: Fisheye Calibration [solved]  (Read 3731 times)

AnttiV

  • Newbie
  • *
  • Posts: 4
    • View Profile
Fisheye Calibration [solved]
« on: June 05, 2017, 12:44:04 PM »
I'm trying to calibrate images with our metadata coming from the camera with following script.
Code: [Select]
for eye in self.m_fisheyes:
c = PhotoScan.app.document.addChunk()
c.label = eye.m_name

for p in eye.m_files:
c.addPhotos([p])

sensor = c.sensors[0]
sensor.width = 2048
sensor.height = 2048
sensor.calibration.type = PhotoScan.Sensor.Type.Fisheye
cal = sensor.calibration
cal.cx = eye.m_metadata.m_center[0]
cal.cy = eye.m_metadata.m_center[1]
cal.f = eye.m_metadata.m_focal
cal.k1 = eye.m_metadata.m_distortions[0]
cal.k2 = eye.m_metadata.m_distortions[1]
cal.k3 = eye.m_metadata.m_distortions[2]
cal.k4 = eye.m_metadata.m_distortions[3]

I get chunks and images there nicely, but when I check those calibrations with Tools->Camera Calibration nothing have gone in. What am I doing wrong?
« Last Edit: June 05, 2017, 07:53:40 PM by AnttiV »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Fisheye Calibration
« Reply #1 on: June 05, 2017, 12:53:47 PM »
Hello AnttiV,

If you need to add sensor.calibration = cal to the end of your script.

Also please note that if you need to load the values to the Initial tab (and then fix the calibration) you need to use sensor.user_calib method.
Best regards,
Alexey Pasumansky,
Agisoft LLC

AnttiV

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Fisheye Calibration
« Reply #2 on: June 05, 2017, 02:28:51 PM »
I was thinking as well that I need to use user_calib for this, but I get none when I try get it.

Code: [Select]
for eye in self.m_fisheyes:
c = PhotoScan.app.document.addChunk()
c.label = eye.m_name

for p in eye.m_files:
c.addPhotos([p])

sensor = c.sensors[0]
sensor.width = 2048
sensor.height = 2048
sensor.calibration.type = PhotoScan.Sensor.Type.Fisheye
cal = sensor.user_calib
cal.cx = eye.m_metadata.m_center[0]
cal.cy = eye.m_metadata.m_center[1]
cal.f = eye.m_metadata.m_focal
cal.k1 = eye.m_metadata.m_distortions[0]
cal.k2 = eye.m_metadata.m_distortions[1]
cal.k3 = eye.m_metadata.m_distortions[2]
cal.k4 = eye.m_metadata.m_distortions[3]
sensor.user_calib = cal

This code gives me the error which I attached to this post.


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Fisheye Calibration
« Reply #3 on: June 05, 2017, 02:41:36 PM »
AnttiV,

Code: [Select]
                        sensor = c.sensors[0]
                        cal = sensor.calibration
cal.type = PhotoScan.Sensor.Type.Fisheye
cal.cx = eye.m_metadata.m_center[0]
cal.cy = eye.m_metadata.m_center[1]
cal.f = eye.m_metadata.m_focal
cal.k1 = eye.m_metadata.m_distortions[0]
cal.k2 = eye.m_metadata.m_distortions[1]
cal.k3 = eye.m_metadata.m_distortions[2]
cal.k4 = eye.m_metadata.m_distortions[3]
sensor.user_calib = cal
                        s.fixed = True

Best regards,
Alexey Pasumansky,
Agisoft LLC

AnttiV

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Fisheye Calibration
« Reply #4 on: June 05, 2017, 06:29:56 PM »
Thanks! Almost there, but still one issue. Script doesn't set camera type to fisheye?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Fisheye Calibration
« Reply #5 on: June 05, 2017, 06:50:06 PM »
Hell AnttiV,

Then you can add sensor.type = PhotoScan.Sensor.Type.Fisheye to the very end of the given script sample.
Best regards,
Alexey Pasumansky,
Agisoft LLC

AnttiV

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Fisheye Calibration
« Reply #6 on: June 05, 2017, 07:53:18 PM »
Thanks for your help. This script worked!
Code: [Select]
sensor = c.sensors[0]
sensor.width = 2048
sensor.height = 2048
sensor.type = PhotoScan.Sensor.Type.Fisheye
cal = sensor.calibration
cal.cx = eye.m_metadata.m_center[0]
cal.cy = eye.m_metadata.m_center[1]
cal.f = eye.m_metadata.m_focal
cal.k1 = eye.m_metadata.m_distortions[0]
cal.k2 = eye.m_metadata.m_distortions[1]
cal.k3 = eye.m_metadata.m_distortions[2]
cal.k4 = eye.m_metadata.m_distortions[3]
sensor.user_calib = cal
sensor.fixed = True