Camera calibration and correction of distortion
If the camera transmits distorted images, you need to correct the distortion. For this correction it is necessary to calibrate the camera.
Camera calibration
To calibrate a camera, follow the steps below:
Before calibration print a calibration pattern and fix it on a flat surface, preferably black.
There are three pattern types:
- asymmetric circles grid pattern (recommended)
- chessboard pattern
- circles grid pattern
Here are examples of the patterns:

- Create
CameraCalibratorobject usingFacerecService.createCameraCalibratormethod. - Initialize
CameraCalibratorobject by calling theCameraCalibrator.initCalibrationmethod. - Capture the pattern in different poses with the camera you chose to calibrate and provide the captured frames in
CameraCalibrator.addImage. - Use
CameraCalibrator.getPatternSpaceCoverProgressmethod to get the approximate progress of pattern pose and orientation space coverage.CameraCalibrator.getTipmethod returns a tip, which pattern pose is required. - Call the
CameraCalibrator.calibratemethod. - After calibration is successfully completed (true), you can save the calibrated parameters using the
CameraCalibrator.saveCameraParametersmethod. Otherwise (false), add more images and perform a calibration again. - To reset the calibration, call
CameraCalibrator.initCalibrationmethod.
Camera calibration example: test_calibration.
Information on how to run and work with camera calibration sample: test_calibration.
![]() | ![]() | ![]() |
Distortion correction
To correct the distortion, do the following:
- First, load the saved calibrated parameters using the
CameraCalibrator.loadCameraParametersmethod. - Then, correct the image distortion using the
CameraCalibrator.undistortmethod.


