Welcome to RDK X5 Board repository
2.Camera internal parameter calibration
2、Camera internal parameter calibration
1. Preparation before calibration
A large chessboard of known size. This tutorial uses a 9x6 checkerboard and a 20mm square, which should be flattened during calibration. Calibration uses the internal vertices of the chessboard, therefore the "10x7" chessboard uses the internal vertex parameter "9x6", as shown in the following example. Any specification of calibration board is acceptable, just adjust the parameters. An open area without obstacles or calibration board patterns
Monocular camera for publishing images through ROS
2. Start calibration
Install the function package camera_calibration for calibration, taking Humble as an example.
Input following command in terminal.
sudo apt install ros-humble-camera-calibration*
Before calibration, start the camera until all calibrations are completed before turning off the camera.
Start the camera.
Input following command in terminal.
xxxxxxxxxxros2 launch astra_camera gemini.launch.xml
Input following command in terminal to view the topic.
xxxxxxxxxxros2 topic list
The topic we need to use for calibrating RGB color images is/camera/color/image_raw
Run the calibration program.
Input following command in terminal.
xxxxxxxxxxros2 run camera_calibration cameracalibrator --size 9x6 --square 0.02 --ros-args --remap /image:=/camera/color/image_raw
Size: Calibrate the number of internal corners of the chessboard, for example 9X6, with a total of six rows and nine columns of corners.
Square: The side length of a chessboard, measured in meters.
Topic name:/camera/color/image_raw. If you are starting usc_cam, please modify it to /image_raw

X: The left and right movement of the checkerboard in the camera's field of view
Y: The up and down movement of the checkerboard in the camera's field of view
Size: The forward and backward movement of the checkerboard in the camera's field of view
Skew: Tilt rotation of checkerboard pattern in camera field of view
As shown in the above figure, it is necessary to capture the image by flipping it up, down, back, left, right, left, and right so that the X, Y, Size, and Skew on the right turn green, as shown in the figure below. Then click CALIBRATE to start calibration.

After calibration is complete, click SAVE, as shown in the following figure.

The calibration results are saved to 【/tmp/calibrationdata. tar. gz】 in the terminal directory where the calibration program is launched.
After calibration is complete, you can move out the file 【/tmp/calibrationdata. tar. gz】 to see its contents
xxxxxxxxxxsudo mv /tmp/calibrationdata.tar.gz ~
Input following command in terminal.
xxxxxxxxxxcd ~tar -xvf calibrationdata.tar.gz
We will obtain the calibrated png file, ost.yaml, and ost.txt files in the terminal directory
Since the Gemini2 driver loads the pre calibrated built-in parameters in the code when starting, there is no need to load these calibrated parameters. However, when starting the USB camera, parameters need to be loaded. Therefore, after calibration, the parameters need to be replaced with the original built-in parameters. The calibrated ost.yaml needs to be renamed camera_info.yaml, and then the original camera_info.yaml needs to be replaced. Docker terminal input is used,
xxxxxxxxxx#Copy file to /opt/ros/humble/share/usb_cam/configsudo cp ost.yaml /opt/ros/humble/share/usb_cam/config#Switch to /opt/ros/humble/share/usb_cam/configcd /opt/ros/humble/share/usb_cam/config#Backup the original camera_info.yamlsudo mv camera_info.yaml camera_info_BK.yaml#Rename ost.yaml为camera_info.yamlsudo mv ost.yaml camera_info.yaml