从ROS bag文件中提取图像

从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>

将$(find image_view)/test.bag改为你自己的bag文件路径

然后,运行launch文件。

打开一个终端,运行
roscore

打开一个终端,cd到export.launch所在路径下,运行
roslaunch export.launch

所提取的图片在~/.ros路径下,将其移到你的目标文件中,如:

cd ~
mkdir Example
mv ~/.ros/*.jpg ~/Example

参考ROS wiki: How to export image and video data from a bag file,另该wiki中还有将图片制作成视频的内容。

原文地址:https://www.cnblogs.com/corfox/p/5414987.html