Reputation: 23
i have been working on a localization via image processing localization project and the data sets we got was a compressed images in a .bag files so i have multiple ways to extract these images at first i tried the following method:
mkdir images
cd ./images
rosrun image_view extract_images _sec_per_frame:=0.01 image:=<IMAGETOPICINBAGFILE>
run rosbag play <BAGFILE>
and i have tried to use the launch file as well
<launch>
<node pkg="rosbag" type="play" name="rosbag" args="-d 2 /home/devo/datasets/Ch2_002/HMB_1.bag"/>
<node name="extract" pkg="image_view" type="extract_images" respawn="false" output="screen" cwd="ROS_HOME" args="compressed">
<remap from="image" to="/camera/image_raw"/>
<param name="image_transport" value="compressed"/>
</node>
</launch>
but it always ended up giving me the same error
[ERROR] [1486685243.634766995]: Client [/extract_images_1486684806987962257] wants topic /can_bus_dbw/can_rx to have datatype/md5sum [sensor_msgs/Image/060021388200f6f0f447d0fcd9c64743], but our version has [dataspeed_can_msgs/CanMessageStamped/33747cb98e223cafb806d7e94cb4071f]. Dropping connection.
so i just wanted to know what did i do wrong and how can i extract these images from the bag (knowing that my ROS version : 1.12.6)
Upvotes: 2
Views: 3630
Reputation: 3150
try the folowing :
1- In a writable directory :
$ rosrun image_view extract_images image:=<IMAGETOPICINBAGFILE> _image_transport:=compressed
2 - In another terminal, play your bag file
this should save your images in that directory.
Now, if that doesen't work, are you sure that your image_transport compressed is true ? cause the error means that the publisher and subscriber on the same topic have different message types. This also might happen if you bag is created using a different platform with a different message definitions other than the one you'r playing it on.
Edit :
Another way around is to decompress data and then save it. It goes like this :
$rosrun image_transport republish compressed in:=<IMAGETOPICINBAGFILE> raw out:=image/raw
$rosrun image_view image_saver image:=image/raw _save_all_image:=all _filename_format:=%04d.%s
$ rosbag play <bagfile>
Hope that helps !
Upvotes: 0