ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

unable to extract images from bag file

asked 2015-07-02 02:05:19 -0500

saikrishnagv gravatar image

updated 2015-07-02 19:01:54 -0500

130s gravatar image

http://wiki.ros.org/rosbag/Tutorials/... I am following this tutorial. after I did roslaunch export.launch,

"" [rosbag-2] process has finished cleanly
log file: /home/krish/.ros/log/2e6402e2-2086-11e5-8d8c-0026c72b65a2/rosbag-2*.log"""

this is the message i got I did ctrl+c moved this file into test directory. but I can;t see any images here

Also, i actually want to extract stereo images. when I do rosbag info, I get:

types:       sensor_msgs/Image [060021388200f6f0f447d0fcd9c64743]
topics:      /rrc_camera/left/image_raw    171 msgs    : sensor_msgs/Image
             /rrc_camera/right/image_raw   171 msgs    : sensor_msgs/Image
edit retag flag offensive close merge delete

Comments

Well, actually everything seems okay so far. I assume you have adjusted the launch file accordingly? I.e. set the bagfile name in line 2 of the launch file as well as remapped the topic in line 4?

Also, to get both images, you have to run it twice, once for left and once for right.

mgruhler gravatar image mgruhler  ( 2015-07-03 01:31:38 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-07-03 02:44:56 -0500

There are several ways to do this, and the best and the simplest one is to write your own package for this, as per your requirement; Here you need two exactly synchronized images at any given moment so subscribe to both the topics using msg_filter (see the section 7.2). once you are in call-back function convert both the images to cv::Mat and save them using imwrite("filenam",cv::Mat var) function. this way you can be sure about their time stamp.

another way is, using image_view package which comes with image_pipeline.

rosrun image_view extract_images _sec_per_frame:=0.01 image:=(image_topic_name) tLink

you will have to run this package for both the topics separately, but be sure that both the time you get same number of images (in your case 171 images). (otherwise they arent stereo-images). one issue here is, this package save the images in jpg format which can have some data loss due to jpg compression.

edit flag offensive delete link more

Comments

rosrun image_view extract_images _sec_per_frame:=0.01 image:=rrc_camera/left/image_raw but, it displayed: """[ INFO] [1435930468.661967546]: Initialized sec per frame to 0.010000""" and then, nothing is happening

saikrishnagv gravatar image saikrishnagv  ( 2015-07-03 08:47:03 -0500 )edit

run >> rosbag play bagfile.bag in another terminal window

Sudeep gravatar image Sudeep  ( 2015-07-03 09:04:25 -0500 )edit
0

answered 2017-03-03 08:55:14 -0500

Steve3nto gravatar image

updated 2017-03-06 10:08:13 -0500

Isn't there already an implementation somewhere to extract left and right images with identical timestamps from a rosbag? This seems quite a basic thing that should be part of ROS, given how much stereo cameras are used nowadays in robotics.

If someone has such a node, can it be shared please?

I can write my own I guess, but maybe someone else has a good implementation for this and sharing it would make life easier for me and many other ROS users.

-------------------------------------- EDIT -------------------------------------------------
After googling around a bit I have found two possible solutions that are already available to extract synched stereo_pairs from a rosbag.

Method 1) Use the rospy node that comes inside image_view from the image_pipeline. It can be run with
rosrun image_view extract_images_sync _inputs:='[/camera/left/image_raw,/camera/right/image_raw]'

Just modify the topic names and the rospy node according to your needs.

Method 2) Use this package http://wiki.ros.org/bag_tools?distro=...
It has some nice tools for working with rosbags acquired with stereo_cameras.

I hope this can be helpful to other ROS users!

Cheers!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-07-02 02:05:19 -0500

Seen: 2,665 times

Last updated: Mar 06 '17