Rosanswers logo


I use a launch-file in order to extract images from a stereo-camera (stereo/left & stereo/right). Thereby I use the package "image_view" with the node "extract" to grab the images from my bagfile.

   <arg name="path" default="/home/viki/bagfiles" />
   <arg name="bagfile" default="bagfile_stereo_raw.bag" />
   <arg name="folder_name" default="default_image_folder" />
   <arg name="format" default="png" />

   <param name="/use_sim_time" value="true" />

   <node name="rosbag" pkg="rosbag" type="play" 
      args="--clock -d 4 $(arg path)/$(arg bagfile)" />

   <node name="extract1" pkg="image_view"   type="extract_images" respawn="false" output="screen"                 cwd="ROS_HOME" >
   <remap from="image" to="/stereo/left/image_rect" />
   <param name="filename_format" value="/stereo_images/$(arg folder_name)/left/left_image%04i.$(arg                  format)"/>

   <node name="extract2" pkg="image_view" type="extract_images"  respawn="false" output="screen"                  cwd="ROS_HOME" >
   <remap from="image" to="/stereo/left/image_rect" />
   <param name="filename_format" value="/stereo_images/$(arg folder_name)/right/right_image%04i.$(arg                  format)"/>


I now receive all the desired images but they are 24-bit images. Now my question is: How can I setup the launch-file in order to receive 8-bit (grayscale) images? I cannot find any documentation regarding this. Also my question is how to obtain parameters from nodes like "extract" in ROS in general. I found out that there is a parameter called "file_format" for "extract" in the ROS answer sites but how can I see all the different parameters there are for this node. (I am sure my question would resolve by acquiring this info).

Also one other question: I need to create the directories before saving the images (with the launch file) into them. Is there a way that the roslaunch file creates the desired directories by itself?

Thanks in advance! Hector

Originally posted by mister_kay on ROS Answers with karma: 238 on 2014-07-30

Post score: 0

Original comments

Comment by ahendrix on 2014-07-30:
I believe your question about creating directories has been asked and answered elsewhere. ( http://answers.ros.org/question/188298/how-to-create-directories-in-a-ros-launch-file/ )

Comment by ahendrix on 2014-07-30:
image_proc should be able to create mono images from color images, but it looks like you're already subscribing to a mono topic. Are the saved images color or monochrome when viewed?

Comment by ahendrix on 2014-07-30:
There isn't any documentation of the extract_images node on the image_view wiki page. Perhaps you can write it once you've figured out all of the details?

Comment by mister_kay on 2014-08-22:
@ahendrix yes i can do that. unfortunately I couldn't find the site where ic an edit the documentaion for extract_images. can you give me a link for a tutorial how to create this docu?

Comment by ahendrix on 2014-08-22:
The wiki page for image_view is http://wiki.ros.org/image_view , and you can sign up for an account here


1 Answer 1


Rosanswers logo

The hacky version is to edit the source code in the image_view package named extract_view.cpp [line 105]:


image = cv_bridge::toCvShare(msg, "bgr8")->image;


image = cv_bridge::toCvShare(msg, "mono8")->image;

This way only 8bit grayscale images are extracted. (that was on of the things I wanted.) Of course i had to "catkin_make" my catkin_workspace first before this works!

I think it would be a good idea to add a parameter which makes it possible for every user to extract the images in her/his desired fileformat, e.g.

ros::NodeHandle nh("~");
string the_format;
const string default_format = "bgr8";

nh.param<std::string>("file_format", the_format, default_format);
image = cv_bridge::toCvShare(msg, the_format)->image;

I am not that good with GitHub, otherwise I would send a pull request to the creator of image_view.

Originally posted by mister_kay with karma: 238 on 2014-08-22

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by paulbovbel on 2014-08-22:
Never too early/late to learn!

  • open an issue in the repository
  • fork the repo directly in the Github gui
  • clone your fork, make/test your changes
  • commit your changes, referencing the issue in the comment
  • make a pull request through the Github gui to 'pull' your changes to the repo

Your Answer

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