Calibration of depth camera by ROS


foreword

Use the calibration board to calibrate the depth camera yourself.


Reference: http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration

1. Prepare the calibration plate

The checkerboard calibration board can be downloaded from the website below, and can be printed on A4 paper.
http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration?action=AttachFile&do=view&target=check-108.pdf

Second, use the ROS toolkit for calibration

1. Turn on the camera

1.1 Enter the ROS kernel

roscore

1.2 Turn on the camera

roslaunch realsense2_camera demo_pointcloud.launch

2. Install the calibration kit

$ rosdep install camera_calibration

3. View topics

rostopic list

The topic of the RGB image:
/camera/color/camera_info
/camera/color/image_raw
The topic of the Depth image:
/camera/depth/camera_info
/camera/depth/image_rect_raw
Note: My depth is _rect_raw, in the modification of the calibration code Pay attention to the path.

4. Run the calibration code

4.1 Calibrate RGB camera

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.243 image:=/camera/color/image_raw camera:=/camera/color 

illustrate:

  • size: the number of corner points inside the chessboard
  • square: the side length of the cell of the checkerboard, in m
  • image: the topic path of the image
  • camera: the information path of the camera

If the above code reports an error:
“Waiting for service /camera/color/set_camera_info …
Service not found”
, then add “–no-service-check” after the above code:

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.0243 image:=/camera/color/image_raw camera:=/camera/color --no-service-check

You can enter the calibration interface:
insert image description here
move the calibration board up and down, left and right, and when "CALIBRATE" turns green, it's ok.
insert image description hereAfter clicking "CALIBRATE", wait for a while, and you can see the calibrated parameters on the terminal:
insert image description here

4.2 Calibration depth

Note that the image path here is "/camera/depth/image_rect_raw".

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.0243 image:=/camera/depth/image_rect_raw camera:=/camera/depth --no-service-check

The problem that has not been solved yet:
the depth camera calibration depth needs to cover the infrared emitter with an opaque material, and in a dark environment, use infrared light to irradiate
here. There are two infrared cameras here. Is it necessary to use a binocular camera? calibration?
Official documentation for binocular camera calibration: http://wiki.ros.org/camera_calibration/Tutorials/StereoCalibration
My calibration interface is dark.
The cameras I saw on the Internet that calibrate the depth map are all kinect cameras, and some models of kinect The camera is based on TOF, and the realsense d435 is based on structured light. This may be the reason why I failed to perform depth map calibration.
Try kinect another day.

5. Significance of Calibration Parameters

The camera_calibration package in ROS, its code implementation mainly uses the calibration module in OpenCV.
The obtained calibration results are as follows:

 = [0.23244826907781227, -0.08573299096457011, 0.05008213017343726, -0.08067275070179597, 0.0]
K = [1135.1350732747046, 0.0, 41.11323684505894, 0.0, 1067.9415171380786, 509.1845758553174, 0.0, 0.0, 1.0]
R = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P = [1086.77734375, 0.0, 18.500314902303217, 0.0, 0.0, 1084.970458984375, 527.9177954151601, 0.0, 0.0, 0.0, 1.0, 0.0]
None
# oST version 5.0 parameters


[image]

width
640

height
480

[narrow_stereo]

camera matrix
1135.135073 0.000000 41.113237
0.000000 1067.941517 509.184576
0.000000 0.000000 1.000000

distortion
0.232448 -0.085733 0.050082 -0.080673 0.000000

rectification
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000

projection
1086.777344 0.000000 18.500315 0.000000
0.000000 1084.970459 527.917795 0.000000
0.000000 0.000000 1.000000 0.000000

The meaning of each calibration parameter:
image_width, image_height represent the length and width of the picture
camera_name is the camera name
camera_matrix specifies the internal parameter matrix of the camera
distortion_model specifies the distortion model
distortion_coefficients specifies the coefficient of the distortion model
rectification_matrix is ​​the correction matrix, generally the unit matrix
projection_matrix is ​​the external world The projection matrix of the coordinates to the image plane

6. Save parameters

Click SAVE to save the calibration parameters and images used in the calibration. Everything will be available in the compressed folder /tmp/calibrationdata.tar.gz.

Click save, and the terminal will appear:
insert image description herethe saved file will appear in this path:
insert image description here
the calibrated picture and the txt file and yaml file of the obtained parameters are stored in it:
insert image description here

7. Create yaml file

Camera Calibration Parser helps you to create a yml file, you can use camera_info_url parameter to load almost all ros camera drivers.

8. Correct the image

Simply loading a calibration file does not correct the image. For rectification, use the image_proc package .


Summarize

Tip: Here is a summary of the article:
For example: the above is what I will talk about today. This article only briefly introduces the use of pandas, and pandas provides a large number of functions and methods that allow us to process data quickly and easily.

Guess you like

Origin blog.csdn.net/weixin_44934373/article/details/129067568