2. Calibration of camera internal reference2.1、Code Function Description2.2、Preparation before calibration2.3、Start up2.3.1、Start the camera2.3.2、Color Image Calibration2.3.3、ir infrared calibration
Checkerboard (calibration board)
Take starting the Astra pro camera as an example, after SSH connects to the car, enter in the terminal,
ros2 launch astra_camera astro_pro_plus.launch.xml
Start the camera before calibration, and turn off the camera until all calibrations are completed.
Obi Zhongguang camera model and the corresponding launch file:
launch file | camera model |
---|---|
ros2 launch astra_camera astra_pro.launch.xml | Astrapro |
ros2 launch astra_camera astro_pro_plus.launch.xml | Astraproplus |
ros2 launch astra_camera astra.launch.xml | Astramini |
Since the car has no graphical interface, the next calibration program needs to be run in a virtual machine.
Enter following command in the virtual machine terminal.
xxxxxxxxxx
ros2 topic list
The topic we need to calibrate the RGB color image is /camera/color/image_raw, and the topic used to calibrate the ir infrared image is /camera/ir/image_raw.
The virtual machine installs the camera calibration function package.
Input following command in virtual machine terminal.
xxxxxxxxxx
sudo apt install ros-foxy-camera-calibration*
Input " y", press Enter to start the installation, and wait for the installation to complete.
Input following command in virtual machine terminal.
xxxxxxxxxx
ros2 run camera_calibration cameracalibrator --size 9x6 --square 0.02 --ros-args --remap /image:=/camera/color/image_raw
Collect images by moving up, down, back and forth, left and right, and turning them over, 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 calculating the internal camera parameters. About 60-70 pictures.
After the calibration is completed, click [SAVE], as shown in the figure below.
The calibration result is saved to [/tmp/calibrationdata.tar.gz], and the file can be moved out to view the content.
After exiting the program, enter the following command in the virtual machine terminal.
x
#move the file to the current directory
sudo mv /tmp/calibrationdata.tar.gz .
#create folder
mkdir calibrationdata_rgb
#Unzip to a specified folder
tar -zxvf calibrationdata.tar.gz -C ./calibrationdata_rgb
We will get the calibrated png file, ost.yaml and ost.txt files in the calibrationdata_rgb folder in this directory.
Since the Astra driver loads the calibrated built-in parameters in the code when it starts, there is no need to load the calibrated parameters. In the case of [AR vision] in [opencv series courses], the internal reference of the camera will be used.
Since the RGBD camera uses structured light as the depth imaging principle, the infrared light projected by it is a special disordered spot, which makes the infrared receiving device unable to receive clear and complete picture content.
At this point we can have several special processing methods:
Choose a processing method according to your needs.
Enter the following command in the virtual machine terminal.
xxxxxxxxxx
ros2 run camera_calibration cameracalibrator --size 9x6 --square 0.02 --ros-args --remap /image:=/camera/ir/image_raw
In the same way, the following operation is similar to the color camera calibration, change different poses, and fill the lines under [X], [Y], [Size], and [Skew] as much as possible.
Click [CALIBRATE] to calculate the internal parameters of the camera, and click [SAVE], as shown below.
The calibration result is saved to [/tmp/calibrationdata.tar.gz], and the file can be moved out to view the content.
After exiting the program, enter the following command in the virtual machine terminal.
x
#move the file to the current directory
sudo mv /tmp/calibrationdata.tar.gz .
#create folder
mkdir calibrationdata_depth
#Unzip to a specified folder
tar -zxvf calibrationdata.tar.gz -C ./calibrationdata_depth
We will get the calibrated png file, ost.yaml and ost.txt files in the calibrationdata_depth folder in this directory.