[Nav2 Chinese website] ROS2 monocular camera calibration tutorial

This article comes from: Nav2 Chinese Network Tutorial

For complete Nav2 documentation and tutorials please visit: http://nav2.fishros.com

Nav2 communication group: 139707339

WeChat public account: Yuxiang ROS

Camera calibration

Overview

This tutorial demonstrates how to obtain the parameters of a monocular camera through calibration.

Require

1- Use the package manager of the operating system to install the software packages required for camera calibration

sudo apt install ros-<ros2-distro>-camera-calibration-parsers

sudo apt install ros-<ros2-distro>-camera-info-manager

sudo apt install ros-<ros2-distro>-launch-testing-ament-cmake

2- The Image Pipeline package needs to be built from source in your workspace with the following command:

git clone – b <ros2-distro> [email protected]:ros-perception/image_pipeline.git

Also, make sure you have the following: 

  • A large chessboard of known size. This tutorial uses a 200mm x 200mm square chessboard. ** Since the camera calibration uses the inner vertices of the checkerboard, an "8x10" checkerboard is required. So using the internal vertex parameter is exactly "7x9" as shown in the example below. **  Can be  downloaded from  here .

  • A well-lit 5m x 5m area to clear obstacles and check the checkerboard pattern

  • A monocular camera that can publish images on ROS

Tutorial Steps

1- Start a terminal in the GUI 

2- Launch the ROS driver for the camera being used.

3- Make sure the camera is publishing images via ROS. This can be tested by running: 

ros2 topic list

4- This will show all your posted threads, make sure there is an image thread inside /camera/image_raw. Make sure the image_raw topic is a real topic and is posting images, you need to check how often the topic is posted:

ros2 topic hz /camera/image_raw

5- Start the camera calibration node 

ros2 run camera_calibration cameracalibrator --size 7x9 --square 0.20 image:=/my_camera/image_raw camera:=/my_camera

Camera Name:

-c, --camera_name
        name of the camera to appear in the calibration file


Chessboard Options:

You must specify one or more chessboards as pairs of --size and--square options.

  -p PATTERN, --pattern=PATTERN
                    calibration pattern to detect - 'chessboard','circles', 'acircles','charuco'
  -s SIZE, --size=SIZE
                    chessboard size as NxM, counting interior corners (e.g. a standard chessboard is 7x7)
  -q SQUARE, --square=SQUARE
                    chessboard square size in meters

ROS Communication Options:

 --approximate=APPROXIMATE
                    allow specified slop (in seconds) when pairing images from unsynchronized stereo cameras
 --no-service-check
                    disable check for set_camera_info services at startup

Calibration Optimizer Options:

 --fix-principal-point
                    fix the principal point at the image center
 --fix-aspect-ratio
                    enforce focal lengths (fx, fy) are equal
 --zero-tangent-dist
                    set tangential distortion coefficients (p1, p2) to
                    zero
 -k NUM_COEFFS, --k-coefficients=NUM_COEFFS
                    number of radial distortion coefficients to use (up to
                    6, default 2)
 --disable_calib_cb_fast_check
                    uses the CALIB_CB_FAST_CHECK flag for findChessboardCorners

    This will open a calibration window which highlight the checkerboard.

6 In order to get better calibration results, it is necessary to continuously move the checkerboard within the camera's field of view:

  • Make the checkerboard reach the left, right, top, and bottom of the camera's field of view 

    ◦ X-left/right orientation in camera field of view

    Y - up and down in the camera's field of view 

    ◦ Size - approach/away from the camera and tilt relative to the camera

  • checkerboard filling the whole field of view

  • Skew the checkerboard to the left, right, up, and down (Skew)

7 As the checkerboard moves continuously, the length of the 4 horizontal bars on the sidebar of the calibration window will continue to grow. The "CALIBRATE" button will illuminate when all 4 bars are green and there is enough data available for calibration. Click to view the results. Calibration takes about a minute.

8- When the calibration is complete, the save and submit buttons are illuminated. The calibration results can also be seen in the terminal.

9- The result can be viewed after pressing the save button. Data is saved to "/tmp/calibrationdata.tar.gz" 

10- To use the camera calibration result file, execute the following command to unzip the file (calibration.tar.gz) 

tar -xvf calibration.tar.gz

11- In the calibration results folder, you can see all the images used for the calibration along with the "ost.yaml" and "ost.txt" files. You can use a yaml file that contains calibration parameters for the camera driver.

Guess you like

Origin blog.csdn.net/qq_27865227/article/details/123198498