Welcome to AI View Depth camera 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 chessboard with 20 mm squares, which needs to be flattened during calibration. Calibration uses the internal vertices of the chessboard, so a "10x7" chessboard uses the internal vertex parameters "9x6", as shown in the example below. Any size of calibration board can be used, just change the parameters. A more open area without obstacles and calibration board patterns
Monocular camera that publishes images through ROS
2. Start calibration
Install the calibration function package camera_calibration. Take foxy as an example. Enter in the terminal,
xxxxxxxxxxsudo apt install ros-foxy-camera-calibration*
Start the camera before calibration, and turn it off after all calibrations are completed. Start the camera and enter in the terminal,
xxxxxxxxxxros2 launch orbbec_camera gemini2.launch.py
Use the following command to view the topic terminal input,
xxxxxxxxxxros2 topic list
The topic we need to use to calibrate RGB color images is /camera/color/image_raw.
Run the calibration program and enter in the terminal,
xxxxxxxxxxros2 run camera_calibration cameracalibrator --size 9x6 --square 0.02 --ros-args --remap /image:=/camera/color/image_raw
size: The number of internal corner points of the calibrated chessboard, for example, 9X6, the corner points have six rows and nine columns.
square: The side length of the chessboard, in meters.
Topic name: /camera/color/image_raw. If you are starting usb_cam, change it to /image_raw

X: Left and right movement of the chessboard in the camera's field of view
Y: Up and down movement of the chessboard in the camera's field of view
Size: Front and back movement of the chessboard in the camera's field of view
Skew: Tilt and rotation of the chessboard in the camera's field of view
As shown in the figure above, you need to capture the image by flipping up and down, front and back, left and right, so that the X, Y, Size, and Skew on the right turn green, as shown in the figure below, and then click CALIBRATE to start calibration.

After the calibration is completed, click SAVE, as shown in the figure below.

The calibration results are saved to [/tmp/calibrationdata.tar.gz], and the saved path is the terminal directory where the calibration program is started. After the calibration is completed, you can move out the [/tmp/calibrationdata.tar.gz] file to see the content
xxxxxxxxxxsudo mv /tmp/calibrationdata.tar.gz ~
Terminal input,
xxxxxxxxxxcd ~tar -xvf calibrationdata.tar.gz
You will get the calibrated png file, ost.yaml and ost.txt files in the terminal directory
Since the gemini2 driver loads the built-in parameters calibrated in the code when it is started, it is not necessary to load the calibrated parameters, but when the USB camera is started, the parameters need to be loaded. Therefore, after calibration, the parameters need to replace the original built-in parameters, rename the calibrated ost.yaml to camera_info.yaml, and then replace the original camera_info.yaml, and enter the docker terminal,
xxxxxxxxxx#First copy the file to /opt/ros/foxy/share/usb_cam/configsudo cp ost.yaml /opt/ros/foxy/share/usb_cam/config#Switch to the /opt/ros/foxy/share/usb_cam/config directorycd /opt/ros/foxy/share/usb_cam/config#Backup the original camera_info.yamlsudo mv camera_info.yaml camera_info_BK.yaml#Rename ost.yaml to camera_info.yamlsudo mv ost.yaml camera_info.yaml