Skip to main content
Version: 3.13.0

Camera Calibration and Correction of Distortion

The CameraCalibrator object is used for camera calibration and correction of image distortion. To create this object, call FacerecService.createCameraCalibrator.

To correct the distortion, perform a calibration or just load the calibrated parameters using the CameraCalibrator.loadCameraParameters member function. After that, correct the image distortion using the CameraCalibrator.undistort member function.

For calibration print a calibration template and fix it on a flat surface, preferably black.

There are three pattern types:

  • asymmetric circles grid pattern
  • chessboard pattern
  • circles grid pattern

Here are examples of the patterns:

Full size images are stored in the share/calibration directory.

We recommend you to use the asymmetric circles grid pattern.

Before calibration initialize the CameraCalibrator object by calling the CameraCalibrator.initCalibration member function. Then capture the pattern in different poses with the camera you chose to calibrate and provide the captured frames in CameraCalibrator.addImage.

You can get the approximate progress of pattern pose space coverage using CameraCalibrator.getPatternSpaceCoverProgress member function. Using the CameraCalibrator.getTip member function you can get a tip, what pattern pose is required.

Then call the CameraCalibrator.calibrate method.

After a successful calibration view the results by calling the CameraCalibrator.undistort method. If the result is appropriate, save the calibrated parameters using the CameraCalibrator.saveCameraParameters method. Otherwise, add more images and perform a calibration again.

To reset the calibration, call the CameraCalibrator.initCalibration method again.