This repository contains MATLAB and Python tools to extract and synchronize point clouds and images from a rosbag for extrinsic calibration.
- ROS (tested on Kinetic and Melodic)
- Python 2.X (tested on 2.7.17)
- MATLAB (tested on 2020a and 2021b)
Use pcl_ros to extract point clouds from a rosbag:
rosrun pcl_ros bag_to_pcd <input_file.bag> <topic> <output_directory>
-
Change the following lines in
config.ini
:; Parameter Setup [DEFAULT] ; ; Change rosbag path here. ; bag_path = <your roabag path> ; ; Change image topic here. ; image_topic = <your image topic> ; ; Change image destination folder path here. ; image_path = <your image destination folder path> ; ; Change cropped image destination folder path here. ; cropped_path = <your cropped image destination folder path> ; ; Change cropped resolution from bottom here. ; cropped_resolution = <your cropped resolution from bottom>
-
Use
extract_image.py
to extract images from a rosbag (Python 2.X):python extract_image.py
-
Use
crop_image_bottom.py
to crop images from bottom (Python 2.X):python crop_image_bottom.py
-
Change the following lines in
main.m
:%% Determine Folder Path path = "<your root folder path>"; % Change folder path here. path_img = strcat(path, "img/*.jpg"); % Place images in ./img/ folder path_pcd = strcat(path, "pcd/*.pcd"); % Place point clouds in ./pcd/ folder
-
Run
main.m
to synchronize timestamps. -
Check synchronized data in
./img_sync/
and./pcd_sync/
respectively.
After extracting and synchronizing data from the rosbag, use CameraCalibrator
app in MATLAB to calculate the intrinsic of the camera. Later, use the method mentioned in the following paper1 to calibrate the extrinsic between LiDAR and camera.
- Read config file to get parameters.
- Check and create destination folder.
- Add progressbar.
- Use Python to extract both point cloud and image.
- Use Python to synchronize point cloud and image messages.
- Manually select images and corresponding point cloud.
- Release and maintain code for extrinsic calibration (All credit goes to the authors of the paper above).