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

Revision history [back]

Right click in image_view saves the current image in the stream to file. You can use run this node with your choice of camera driver to save images at will.

click to hide/show revision 2
edited answer based on further elaboration of question

Right click in image_view saves the current image in the stream to file. You can use run this node with your choice of camera driver to save images at will.

EDIT: There are a number of ways in which you can store the image in a computationally efficient manner. If possible, try to avoid changing the driver code itself unless absolutely necessary. You can try something like:

  • Use a usb cam driver that provides a nodelet interface. I don't think usb_cam supports a nodelet, but I believe uvc_camera does so.
  • Create a nodelet that subscribes to the image stream (sensor_msgs/Image) produced by the camera, and an empty message (std_msgs/Empty) on a topic such as 'save_image'. Whenever you receive an empty message, you can set a boolean flag which saves the image using cv::imwrite in the image callback.
  • Launch both nodelets in to the same nodelet manager. This should remove any copy costs while saving the image. You can then save images by typing the following at the command line: rostopic pub /save_image std_msgs/Empty

This should allow you to save images programmatically as well if needed.