Machine vision (two)-camera calibration

Machine vision (two)-camera calibration

Overview

Cameras, such precision instruments, have high requirements for optical components. Due to some reasons inside and outside the camera, the generated object images are often distorted. In order to avoid errors caused by the data source, it is necessary to calibrate the camera parameters. ROS officially provides a function package for binocular and monocular camera calibration-camera_calibration.

One, camera_calibration function package

First use the following command to install the camera calibration package camera_calibration:

sudo apt-get install ros-kinetic-camera-calibration

Calibration requires a checkerboard pattern calibration target.
Insert picture description here

2. Start the calibration procedure

When everything is ready, it is ready to calibrate the camera. First use the following command to start the USB camera:

roslaunch robot_vision usb_cam.launch

Then use the following command to start the calibration procedure:

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

The cameracalibrator.py calibration program requires the following input parameters.
1) size: the number of internal corners of the calibrated checkerboard grid. The chessboard used here has 6 rows and each row has 8 internal corners.
2) square: This parameter corresponds to the side length of each checkerboard, the unit is meters.
3) image and camera: set the topic of the image released by the camera.
According to the used camera and the size of the checkerboard of the calibration target, modify the above parameters accordingly to start the calibration procedure.

Three, calibration camera

After the calibration program is successfully started, place the calibration target in the field of view of the camera, and you should see the graphical interface as shown in the figure.
Insert picture description here
Before the calibration is successful, the buttons on the right are gray and cannot be clicked. In order to improve the accuracy of the calibration, try to make the calibration target appear in each area within the camera's field of view. The progress bar in the upper right corner of the interface will prompt the calibration progress.
1) X: The left and right movement of the calibration target in the field of view of the camera.
2) Y: Up and down movement of the calibration target in the field of view of the camera.
3) Size: The front and back movement of the calibration target in the camera's field of view.
4) Skew: Tilt rotation of the calibration target in the field of view of the camera.
Keep moving the calibration target in the field of view until the "CALIBRATE" button changes color, indicating that the parameter collection of the calibration procedure is completed. Click the "CALIBRATE" button, the calibration program will start to automatically calculate the calibration parameters of the camera. This process will take a while, and the interface may become gray and unresponsive. Be careful not to close it.
After the parameter calculation is completed, the interface is restored, and the calibration result will be displayed in the terminal.
Insert picture description here
Click the "SAVE" button in the interface, the calibration parameters will be saved in the default folder, and you will see the path in the terminal, as shown in the figure.
At this time, you need to wait for a while, the computer needs to calculate for a while, don't think it is a card.
Insert picture description here
Click the "COMMIT" button to submit the data and exit the program. Then open the /tmp folder, you can see the compressed file calibrationdata.tar.gz of the calibration results; the content after decompressing the file is as shown in the figure, you can find the calibration result file named ost.yaml from it, and copy the file out , Rename it and it is ready to use.
Insert picture description here
Copy the content of the file and replace the content in camera_calibration.yaml in the robot_vision directory.

Guess you like

Origin blog.csdn.net/weixin_45661757/article/details/113256274