Camera calibration
The bin directory contains the executable file test_calibration:
test_calibration
Camera calibration program for lens distortion compensation to improve identification quality, example usage of the pbio::CameraCalibrator
object.
The program works in two modes:
calibrate
– perform the calibration processview
– view the result of distortion correction based on the calibration results
Launch parameters in calibrate
mode:
- path to the library file
libfacerec.so
orfacerec.dll
- path to the directory conf/facerec
- webcam id or video stream url
- desired frame width
- desired frame height
calibrate
- calibration pattern type (
acircles
,circles
orchessboard
) - calibration pattern width
- calibration pattern height
- path to the file in which to save the calibrated parameters
Example of launching from the bin directory in calibrate
mode:
- Windows
- Linux
test_calibration facerec.dll ../conf/facerec/ 0 640 480 calibrate acircles 4 11 ./camparam.bin
./test_calibration ../lib/libfacerec.so ../conf/facerec/ 0 640 480 calibrate acircles 4 11 ./camparam.bin
To perform calibration, you need to print the calibration template (See Camera calibration and distortion correction) section and attach it to a flat surface, preferably black. It is recommended to use the asymmetric circles grid template. Then move the calibration template or camera to shoot the template in different poses and orientations. The program displays an estimate of the coverage of the space of positions and orientations of the templates and gives a hint of the required template position. Then press the c
key to calibrate. This may take about a minute, during which time the program pauses.
If the calibration is successful, the program will display a reprojection error and perform distortion correction of the frames. Use the q
and w
keys to change the alpha distortion correction parameter. Press the s
key to save the calibrated parameters or shoot more frames and perform calibration again.
Launch parameters in view
mode:
- path to the
libfacerec.so
orfacerec.dll
library file - path to the conf/facerec directory
- webcam id or video stream url
- desired frame width
- desired frame height
view
- path to the file where the calibrated parameters were saved
Example of launching from the bin directory in view
mode:
- Windows
- Linux
test_calibration facerec.dll ../conf/facerec/ 0 640 480 view ./camparam.bin
./test_calibration ../lib/libfacerec.so ../conf/facerec/ 0 640 480 view ./camparam.bin
Use q
and w
keys to change the alpha distortion correction parameter.
Source code: test_calibration.cpp
The OpenCV library is required for building.