Skip to content

minutiaes/camera_calibrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Camera Calibrator

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.

Features

  • Interactive calibration
  • Exporting necessary configuration file for camera_rgb node
  • All necessary parameters are stored in Launch File

Getting Started

Dependencies

  • OpenCV
    To install:
    $ python3 -m pip install opencv-python
  • PyYAML
    To install:
    $ python3 -m pip install pyyaml
    When you run the node, if you still get an error about PyYAML, check its version
    $ python3
    > import yaml
    > yaml.__version__
    If it is smaller than 5.1, you should update it
    $ python3 -m pip install -U pyyaml

Installation

  1. Clone repository to /your_workspace/src
    $ git clone https://git.fh-aachen.de/kurhan/camera_calibrator.git
  2. Build /your_workspace with colcon
    $ colcon build

Usage

Launch File

It contains parameters under 3 topic.

  1. Camera

    • camera_source holds index number of camera. If there is only one camera on the system, its index is probably 0.
      If it throws an error, you can check it

      $ ls -l /dev/video*
    • frame_width and frame_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.

  2. Checkerboard

    • horizontal_corner and vertical_corner are set according to inner corners of chekerboard like below.
    Checkerboard

    In this example horizontal_corner: 8 and vertical_corner: 6

    • square_size is set according to edge length[mm] of squares on checkerboard.
  3. 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.

How to Run Node

After setting all parameters in Launch File properly,

$ ros2 launch camera_rgb camera_rgb.launch.py

starts the node and camera window pop ups

Exported Configuration File

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 to home directory of user
  • image_width and image_height are equivalent of frame_width and frame_height
  • camera_source and camera_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
$$camera~intrinsic~matrix = \begin{bmatrix} f_x & 0 & c_x\\\ 0 & f_y & c_y\\\ 0 & 0 & 1 \end{bmatrix}$$
  • distortion_model is set to plumb bob by default. This model requires 1x5 distrotion matrix.
  • distortion_coefficients contains 5 coefficients.
$$distortion~coefficients = \begin{bmatrix} k_1 & 0 & k_2 & p_1 & p_2 & k_3 \end{bmatrix}$$

For more info you can check OpenCV tutorial and documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages