1. Download the projection processing code
Code link: https://github.com/jhzhang19/ros_project_pc_to_image
2. Unzip it into the ros workspace catkin_ws/src
(If you don’t know how to create a ros workspace, you can refer to my other blog, which records how to create a ros workspace.
Blog link: https://blog.csdn.net/qq_49959714/article/details/127028396?spm=1001.2014.3001.5502
)
Since the developer of this code created an extra subdirectory, we need to remove the redundant subdirectory, that is, copy the ros_detection_tracking folder in the ros_project_pc_to_image directory to the src directory, and then delete ros_project_pc_to_image.
(You can also clone the code to the src directory by command git clone code link)
3. Compile
roscore
Open a new terminal and enter the following command
cd ~/catkin_ws //进入到ros工作空间目录下
catkin_make //编译
source devel/setup.bash
rosrun ros_detection_tracking projector
4. Play rosbag (the rosbag in the kitti data set is used here for testing, other rosbags can also be used, but the corresponding parameters need to be modified)
rosbag download link:
Link: https://pan.baidu.com/s/1vpBCDgHcRzllvDxi7lpRug
Extraction code: m1ji
Enter the rosbag storage directory and play rosbag
cd xx
play rosbag
rosbag play -l example_new.bag //-l为循环播放
5. Open Rviz to display the projection effect
Enter rosrun rviz rviz in a new terminal to open rviz
rosrun rviz rviz
Click on Panels in rviz, then check display
Click Add below in the Displays window
In the pop-up window, select the Image theme under /project_pc_image
Finally you can see the following effect:
kitti point cloud projected onto image plane
Reference blog: