Imagine you have had dumped some ros bag files in which some topics were publishing images and now you want to extract those images and save them.
You can play your ros bag and then implement a node that listens to that topic and you save the data. In ros, There is a neat solution for that. All you have to do is just install image-view package, i.e ros-indigo-image-view if you are using indigo.
Then you can use this simple launch file that I have created to extract images from you favorite topic.
1 2 3 4 5 6 7 8 |
<launch> <arg name="bagfile" /> <arg name="topic" /> <node pkg="rosbag" type="play" name="rosbag" args="$(arg bagfile)" /> <node name="extract" pkg="image_view" type="extract_images" respawn="false" output="screen" cwd="ROS_HOME"> <remap from="image" to="$(arg topic)" /> </node> </launch> |
The example of run:
1 |
roslaunch export.launch bagfile:= topic:=/kinect2/rgb_rect/image |
This will store image in the ROS folder at
1 2 3 4 |
/home/<username>/.ros/frame0000.jpg /home/<username>/.ros/frame0001.jpg /home/<username>/.ros/frame0002.jpg /home/<username>/.ros/frame0003.jpg |
What about the compressed images?