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

How to call onSaveImage() function in rviz with a constant rate?

asked 2014-02-20 18:07:46 -0600

ZiyangLI gravatar image

Hi all,

I find out that I can save an image by choosing File->Save Image in rviz.

What if I want to save images automatically with a constant rate? Anybody knows how to do this?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2014-02-20 21:19:54 -0600

davinci gravatar image

updated 2014-02-20 21:20:40 -0600

You should write a node which subscribes to the image stream and saves the images. Use the rate command so that it runs at a constant rate.

Or use Rosbag to save the image stream, although you won't get a constant stream then.

edit flag offensive delete link more


Thanks for your answer, but I also want to record other sensor messages in a video. Like the point cloud and marker arrays.

ZiyangLI gravatar image ZiyangLI  ( 2014-02-21 12:44:16 -0600 )edit

Then just use a screen recorder program like RecordMyDesktop

davinci gravatar image davinci  ( 2014-02-23 06:17:09 -0600 )edit

I have tried both glc-capture and RecordMyDesktop. glc-capture gives very good result but if I convert the .glc file to .avi file, the color changes and it looks blurry. With RecordMyDesktop the color is not good from the beginning.

ZiyangLI gravatar image ZiyangLI  ( 2014-02-24 20:57:53 -0600 )edit

answered 2014-02-20 21:49:03 -0600

This would likely require changes in rviz source code. Another option is just recording the part of the screen you´re interested in with a external tool like ffmpeg.

To install the necessary packages:

sudo apt-get install ffmpeg libavcodec-extra-53

Recording the screen is then as easy as typing (for example)

ffmpeg  -s 1920x1080 -f x11grab -r 30 -i :0.0+1920,0 -vcodec libx264 -vpre lossless_ultrafast -threads 0 video.mkv

By specifying the same parameters you used for setting the rviz window size as described here you could even largely automate things when putting them into a script.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-02-20 18:07:46 -0600

Seen: 231 times

Last updated: Feb 20 '14