A standalone camera calibration node for ROS2. Unlike official package, it does not involve any highgui function of OpenCV which are not fully supported in OpenCV on Wheels.
- Interactive calibration
- Exporting necessary configuration file for camera_rgb node
- All necessary parameters are stored in Launch File
- OpenCV
To install:$ python3 -m pip install opencv-python
- PyYAML
To install:When you run the node, if you still get an error about PyYAML, check its version$ python3 -m pip install pyyaml
If it is smaller than$ python3 > import yaml > yaml.__version__
5.1
, you should update it$ python3 -m pip install -U pyyaml
- Clone repository to
/your_workspace/src
$ git clone https://git.fh-aachen.de/kurhan/camera_calibrator.git
- Build
/your_workspace
withcolcon
$ colcon build
It contains parameters under 3 topic.
-
Camera
-
camera_source
holds index number of camera. If there is only one camera on the system, its index is probably0
.
If it throws an error, you can check it$ ls -l /dev/video*
-
frame_width
andframe_height
set camera resolution, e.g. 1920x1080 or 1280x720
To check possible resolution,v4l2-utils
is required.$ sudo apt install v4l2-utils
$ v4l2-ctl --list-formats-ext
-
camera_fps
sets camera frame rate. Possible values can be seen with same command above. However this setting may not work with every camera.
-
-
Checkerboard
horizontal_corner
andvertical_corner
are set according to inner corners of chekerboard like below.
In this example
horizontal_corner: 8
andvertical_corner: 6
square_size
is set according to edge length[mm] of squares on checkerboard.
-
Calibration
sample_no
designates desired number of snapshots for calibration process.delay
set time gap[sec] between two snapshots. In the meantime desired pose of checkerboard can be set.
After setting all parameters in Launch File properly,
$ ros2 launch camera_rgb camera_rgb.launch.py
starts the node and camera window pop ups
The node exports a YAML file for camera_rgb. The YAML file contains matrices for calibration and some more additional parameters which are already explained above as Launch File parameters.
- After calculation of calibration parameters,
camera.yaml
file is exported tohome
directory of user -
image_width
andimage_height
are equivalent offrame_width
andframe_height
-
camera_source
andcamera_fps
share same name and value in both files. -
camera_name
is useful when there are multiple cameras on the system. -
camera_matrix
is a unique result derived from calculations done on checkerboard.$f_x$ and$f_y$ are focal lengths and$c_x$ and$c_y$ are optical centers
distortion_model
is set toplumb bob
by default. This model requires1x5
distrotion matrix.distortion_coefficients
contains 5 coefficients.
For more info you can check OpenCV tutorial and documentation