Welcome to ROSMASTER M1 PRO repository
2.USB Camera Intrinsic Calibration
USB Camera Intrinsic Parameters Calibration
USB Camera Intrinsic Parameters Calibration1. Course Content2. Preparation3. Calibration Case Demonstration4. Camera Intrinsic Parameters Explanation
1. Course Content
Calibrate the camera intrinsic parameters of the USB camera using a checkerboard calibration board, to be used for publishing the camera
camera_infoinformation
Important
This section is intended for users of the USB camera version; depth camera users please skip this section
Camera intrinsic parameters have already been calibrated in the factory image. Do not directly modify the factory camera intrinsic parameters file! This section only teaches the camera intrinsic parameters calibration method and does not modify the factory camera intrinsic parameters. If you have development needs, you can modify and adjust the camera intrinsic parameters yourself.
2. Preparation
Prepare a checkerboard calibration board. From the accompanying materials [Attachments — Camera Checkerboard Calibration Board], download and print the calibration board for the corresponding camera and attach it to a hard cardboard or other flat surface

Start the camera intrinsic parameters calibration program
xxxxxxxxxxros2 launch yahboomcar_bringup camera_demo.launch.py demo:=camera_calibration

3. Calibration Case Demonstration
size: the number of inner corners of the calibration checkerboard, for example 9X6, meaning six rows and nine columns of corners in total.
square: the side length of the checkerboard, in meters.
Calibration Interface
X: left-right movement of the checkerboard in the camera's field of view; Y: up-down movement of the checkerboard in the camera's field of view; Size: front-back movement of the checkerboard in the camera's field of view; Skew: tilted rotation of the checkerboard in the camera's field of view
Place the checkerboard in the center of the image and change its pose. The system will recognize it automatically. The best case is that the lines below 【X】, 【Y】, 【Size】, and 【Skew】 first turn from red to yellow and then to green as data is collected, filling up as much as possible.

Click 【CALIBRATE】 to calculate the camera intrinsic parameters. The more images, the longer it takes; just wait. (Sixty or seventy images is about enough; too many can easily cause it to freeze).
Click 【SAVE】 to save the calibration result to 【/tmp/calibrationdata.tar.gz】 in the currently running terminal.
After calibration is finished, you can move the 【/tmp/calibrationdata.tar.gz】 file to your user directory to view its contents
Move and decompress the calibration file
xxxxxxxxxxsudo mv /tmp/calibrationdata.tar.gz ~
After decompression, it contains the images just calibrated, an ost.txt file, and an ost.yaml file. ost.yaml is the intrinsic parameters of the calibrated camera

4. Camera Intrinsic Parameters Explanation
The path of the camera intrinsic parameters file actually loaded when the USB camera starts:
xxxxxxxxxx~/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_bringup/param/usb_camera_info.yaml
image_width/image_height: camera image resolution, here 640×480 pixelscamera_name: camera name identifiercamera_matrix: 3×3 camera intrinsic matrix K = [fx, 0, cx; 0, fy, cy; 0, 0, 1]fx,fy: focal lengths in the x/y directions (in pixels), which determine the image scaling ratiocx,cy: principal point coordinates (the pixel position of the optical center in the image), ideally close to the image center
distortion_model: distortion model;plumb_bobis the 5-parameter distortion model (k1, k2, p1, p2, k3)distortion_coefficients: distortion coefficientsk1,k2,k3: radial distortion coefficients, describing the barrel/pincushion distortion caused by lens curvaturep1,p2: tangential distortion coefficients, describing the distortion caused by lens mounting deviation
rectification_matrix: 3×3 rectification matrix; for a monocular camera it is the identity matrix (no stereo rectification needed)projection_matrix: 3×4 projection matrix P = [fx', 0, cx', Tx; 0, fy', cy', Ty; 0, 0, 1, 0]For a monocular camera Tx=0, Ty=0, used to project 3D points onto the 2D image plane
ximage_width640image_height480camera_namedefault_camcamera_matrix rows3 cols3 data501.151190 0.000000 318.316070 0.000000 501.041160 233.093700 0.000000 0.000000 1.000000distortion_modelplumb_bobdistortion_coefficients rows1 cols5 data-0.423255 0.174200 -0.001304 -0.000501 0.000000rectification_matrix rows3 cols3 data1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000projection_matrix rows3 cols4 data401.241640 0.000000 316.343020 0.000000 0.000000 445.965330 230.087560 0.000000 0.000000 0.000000 1.000000 0.000000