Ask Your Question
0

Take a picture with a webcam from within ROS

asked 2011-12-20 04:49:32 -0600

baseballmvp27 gravatar image

I posted this before, but then realized it should probably be its own question!

I have been browsing for hours! I am still confused...

I am running ROS Diamondback in Ubuntu. My codes compile, but I the webcam will not work with it!

I have a 2 Microsoft Webcams, and call opencv functions from within ROS, but the camera will not initialize. I don't understand it. I am just calling

capture = cvCaptureFromCAM(1); if (!capture) { printf("Couldn't initialize the camera for picture taking!\n"); return -1; }

and each time, the camera will not initialize!

I thought it had something to do with the fact that I didn't have a driver. However, i downloaded the usb_cam driver. I don't know how to link this in with the code to make it so that ROS can call opencv functions.

My ultimate goal is to use stereovision (2 cameras).

I can't even get one to work. What on earth do I have to do in order to get ROS to recognize my camera, and take pictures/video from inside a ROS node?!

-jj

edit retag flag offensive close merge delete

Comments

ROS drivers generally do not provide a C++ or Python API. They are meant to be run standalone and publish sensor data on a given topic, which you would then write a node to subscribe to. You would not link the driver into your code or "into ROS" and it won't allow OpenCV to start working.
Eric Perko gravatar image Eric Perko  ( 2011-12-21 07:46:55 -0600 )edit
Can you view the webcam output with a tool such as guvcview? Something like the Cheese application (or other "Photobooth" type application)?
Eric Perko gravatar image Eric Perko  ( 2011-12-21 07:53:05 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2011-12-20 06:40:51 -0600

mjcarroll gravatar image

updated 2011-12-21 08:57:10 -0600

I believe that most people just use a separate ROS node to capture the images, and then publish them over a topic. You can then separate the hardware-specific portions of your code from the software-algorithm aspects.

I believe that this question and answer on question #57 summarize the state of the camera drivers and which should work with your specific hardware.

For additional clarification: These drivers will provide a ROS node that outputs an sensors_msgs/Image format message, streamed from the camera. You would not have to use the OpenCV getImage functions, as the driver node will be doing all of the interface with the hardware. Most video4linux cameras should work with out too much trouble.

Once you have selected a hardware driver node, you can then launch that node to interface with the Camera hardware. You would then write your own node that subscribes to the output of the hardware driver node, and read in the ROS messages that the driver node publishes (sensors_msgs/Image). You can then manipulate this image data in whatever way that you want.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-12-20 04:49:32 -0600

Seen: 2,945 times

Last updated: Dec 21 '11