Rosanswers logo

When I convert a bagfile (containing depth and RGB data) to picture frames, I get different number of picture frames each time I launch the code given in the tutorial given below and the subsequent video I compile is totally wayward.


Please guide me through this

Originally posted by shravan on ROS Answers with karma: 3 on 2014-12-12

Post score: 0


2 Answers 2


Rosanswers logo

If the number of frames is different all the time probably your computer is not fast enough to save (and jpeg compress) all images with the same frequency they are coming out of the bag file.... Consider using the rosbag play -r (rate) option to slow down the message frequency (e. g. -r 0.2 to run at 20% of the original rate). Your computer should then be able to save all images without missing some. If therefore in the end your video looks kind of slow-mow you can speed it up using any common video processing program....

Edit example launch:

  <node pkg="rosbag" type="play" name="rosbag" args="-r 0.2 -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"/>

Originally posted by Wolf with karma: 7555 on 2014-12-12

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by shravan on 2014-12-12:
Sorry if I ask anything silly. But I am new to ROS. I convert the rosbag to frames using the roslaunch file created in the tutorial. I never use the rosbag play command while doing this. So how and where should I change it? Thanks in advance

Comment by Wolf on 2014-12-12:
I edited the answer; See where I added the -r 0.2 in the launch sample of the tutorial you linked....

Comment by shravan on 2014-12-13:
Thanks a lot for the answer. It helped me a lot :)


Rosanswers logo

I had written a code for this long back, If it helps. https://github.com/nihalsoans91/Bag_to_Depth

Originally posted by nihalsoans91 with karma: 21 on 2018-10-23

This answer was NOT ACCEPTED on the original site

Post score: 1

Original comments

Comment by Beatrice on 2019-08-02:
Does your code extract the rdb image and the corresponding frame of depth? (Are they the same time frame for RGB and depth).

Comment by nihalsoans91 on 2019-11-20:
Hi Beatrice, Sorry about the delayed reply. I have updated the code to have it in sync . i.e have corresponding frame of depth. Also I have written c++ implementation for jpg files. Please let me know if you have any issues. You can also create an issue n the github repository.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.