Welcome to Jetson AGX Thor repository
02.Camera calibration (USB)
Camera Calibration (USB)
Camera Calibration (USB)1. Install Plugins2. Start the Camera3. Image Calibration3.1. Calibration Board3.2. Viewing Topics and Services3.3. Image Calibration
1. Install Plugins
Install Image Calibration Tool
sudo apt install ros-${ROS_DISTRO}-image-pipeline -y

Install Official USB Camera Tool
xxxxxxxxxxsudo apt install ros-${ROS_DISTRO}-usb-cam -y

2. Start the Camera
Restart the terminal, re-enable the ROS environment, and then run the following command to start the USB camera node.
xxxxxxxxxxros2 run usb_cam usb_cam_node_exe

Open another terminal and launch rqt:
xxxxxxxxxxrqt

3. Image Calibration
3.1. Calibration Board

3.2. Viewing Topics and Services
xxxxxxxxxxros2 topic listros2 service list


3.3. Image Calibration
Launch the Image Calibration Tool
Launch the ROS 2 camera calibration tool, camera_calibration, to perform the camera calibration. Note: The camera must be started before running the calibration tool.
xxxxxxxxxxros2 run camera_calibration cameracalibrator --size 9x6 --square 0.02 --ros-args --remap /image:=/image_raw --remap camera/set_camera_info:=usb_cam/set_camera_info
Parameter Explanation
--size: The number of internal corners on the chessboard pattern → 9 rows by 6 columns of internal corners.
--square: The side length of each square on the chessboard pattern → 0.02 meters
--ros-args: Pass ROS arguments
--remap: Topic remapping → /image_raw serves as the image input stream

Calibration Process

Parameter Descriptions
X: Move the chessboard left and right within the camera's field of view
Y: Move the chessboard up and down within the camera's field of view
Size: Move the chessboard forward and backward within the camera's field of view
Skew: Tilt and rotate the chessboard within the camera's field of view
When X, Y, Size, and Skew turn green, you can click CALIBRATE to compute the camera's intrinsic parameters. Note: The more images used for calibration, the longer the process will take, and there is a possibility that the program may freeze.


Once calibration is complete, click SAVE to save the results!

Close the program after the results have been successfully saved! Calibration Results
Default save location and filename for the calibration results:
xxxxxxxxxx/tmp/calibrationdata.tar.gz
Copy and extract the calibration results:
xxxxxxxxxxsudo mv /tmp/calibrationdata.tar.gz ~mkdir calibrationdatatar -xzvf calibrationdata.tar.gz -C ~/calibrationdata
The extracted files include the calibration *.png, ost.yaml, and ost.txt files. We will primarily copy the data contained within the ost.yaml file into the camera_usb.yaml file.
ost.yaml
Replace the corresponding data in the camera_usb.yaml file with the values for image_width, image_height, the data field within camera_matrix, the data field within projection_matrix, and the data field within distortion_coefficients.
xxxxxxxxxximage_width: 1280image_height: 800camera_name: narrow_stereocamera_matrix:rows: 3cols: 3data: [2126.24686, 0. , 1045.90416,0. , 2038.73134, 292.1827 ,0. , 0. , 1. ]distortion_model: plumb_bobdistortion_coefficients:rows: 1cols: 5data: [0.618718, -0.496057, -0.038096, 0.134905, 0.000000]rectification_matrix:rows: 3cols: 3data: [1., 0., 0.,0., 1., 0.,0., 0., 1.]projection_matrix:rows: 3cols: 4data: [2049.23772, 0. , 1082.02717, 0. ,0. , 2153.52835, 282.33049, 0. ,0. , 0. , 1. , 0. ]
camera_usb.yaml
Modified File:
xxxxxxxxxx%YAML:1.0---image_width: 1920image_height: 1080camera_name: cameracamera_matrix: !!opencv-matrixrows: 3cols: 3dt: ddata: [2126.24686, 0. , 1045.90416,0. , 2038.73134, 292.1827 ,0. , 0. , 1. ]distortion_model: plumb_bobdistortion_coefficients: !!opencv-matrixrows: 1cols: 5dt: ddata: [0.618718, -0.496057, -0.038096, 0.134905, 0.000000]rectification_matrix:rows: 3cols: 3data: [1., 0., 0.,0., 1., 0.,0., 0., 1.]projection_matrix:rows: 3cols: 4data: [2049.23772, 0. , 1082.02717, 0. ,0. , 2153.52835, 282.33049, 0. ,0. , 0. , 1. , 0. ]