從ROS bag文件中提取圖像
創建launch文件,如下:
export.launch
<launch> <node pkg="rosbag" type="play" name="rosbag" args="-d 2 $(find image_view)/test.bag"/> <node name="extract" pkg="image_view" type="extract_images" respawn="false" output="screen" cwd="ROS_HOME"> <remap from="image" to="/camera/image_raw"/> </node> </launch>
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
將$(find image_view)/test.bag改為你自己的bag文件路徑。
然后,運行launch文件。
打開一個終端,運行
roscore
打開一個終端,cd到export.launch所在路徑下,運行 roslaunch export.launch
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
所提取的圖片在~/.ros
路徑下,將其移到你的目標文件中,如:
cd ~ mkdir Example mv ~/.ros/*.jpg ~/Example
- 1
- 2
- 3
- 1
- 2
- 3
參考ROS wiki: How to export image and video data from a bag file,另該wiki中還有將圖片制作成視頻的內容。