0
$\begingroup$

Rosanswers logo

Hi everybody,

I want to use a webcam as a photocamera which can be triggered to to take single pictures (the sensor is 3.1 MP). I'm pretty new to the imaging part and would like to know how it would be the easiest way to take a single photo? I already use the usb_cam package but this is just for streaming. Can I modify the source code to trigger a single shot? because there they only use v4l2.


Originally posted by dinamex on ROS Answers with karma: 447 on 2012-06-15

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by piyushk with karma: 2871 on 2012-07-08

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by dinamex on 2012-07-08:
I'm using Ubuntu server so imageview + right klick will not work. Furthermore I would like to reduce the amount of processed data because of computational limitations.

Comment by piyushk on 2012-07-08:
@dinamex: see updated answer

Comment by Eric Perko on 2012-08-09:
You could run image_view on a separate machine with a GUI that was connected to the Ubuntu server over the network. See http://www.ros.org/wiki/ROS/Tutorials/MultipleMachines for example.

Comment by dinamex on 2012-08-09:
where is the difference between nodelet and node? @Eric: I can't use a GUI because the system should be independent. I just want to save Images (best as jpg) to use them later.

Comment by piyushk on 2012-08-10:
@dinamex: multiple nodelets can run in the same process, and do not incur any copy costs for transmitting data from 1 nodelet to another. See the ROS wiki: http://www.ros.org/wiki/nodelet (and the tutorials). You can implement the above using nodes, but you'll be sending some image data over TCP.

$\endgroup$

Your Answer

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