NingMingHao / LidarCameraCalibration

Steps to use MATLAB calibration toolbox for lidar camera calibration
5 stars 0 forks source link
calibration camera lidar lidar-camera-calibration matlab

LidarCameraCalibration

Steps to use MATLAB calibration toolbox for lidar camera calibration

This repo includes the steps to use the MATLAB single camera calibration toolbox and lidar camera calibration toolbox.

It covers the following topics:

Data Collection

The checkerboard used in this repo is a 9x6 checkerboard with 90mm square size, the padding is 60mm, as shown in the following figure.

Checkerboard

The data is collected as rosbag files, the lidars and cameras are fixed on a parked vehicle, the checkerboard is hold by a person (it's recommended to use a tripod to hold the checkerboard).

Notes for data collection:

RecommendedCheckerboardOrientation

Data Preprocessing

Use this parseRosbag.m to convert the rosbag file to png and pcd files. This will synchronize the lidar point cloud and camera image, and downsample the point cloud and image to the specified rate. This script is based on this link. Here you need to modify the following parameters:

Single Camera Calibration

Camera Calibration

Undistort Images

Use the undist_all_images.m script to undistort the images, it also generate a new undistCameraParams to store the parameters for the undistorted images, which will be used in the lidar camera calibration. Here you need to modify the following parameters:

You can also run the convert_intrinsic_into_yaml.m to convert the intrinsic parameters into yaml file, which can be used in the image_proc ROS package.

Lidar Camera Calibration

Preparation

Before you start the lidar camera calibration, you are recommended to check the following things:

Lidar Camera Calibration

Rigid3d

Export the calibration result into ROS desired format

Through the Lidar Camera Calibration, we can get the transformation matrix that transforms the lidar points into the camera frame.

However, the transformation matrix is not in the format that can be used in ROS. So we need to convert the transformation matrix into the format that can be used in ROS. Here we use the convert_tform_to_ROS.m script to convert the transformation matrix into yaml file, where you can use it in the static transform publisher to publish the transformation between the lidar and camera frame.

The desired format is shown below: static_transform_publisher x y z yaw pitch roll frame_id child_frame_id period_in_ms (yaw is rotation about Z, pitch is rotation about Y, and roll is rotation about X) in radians. The frame_id is typically the lidar frame, and the child_frame_id is typically the camera frame. So the translation vector is the position of the camera frame in the lidar frame, and the rotation vector is the rotation of the camera frame in the lidar frame.