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

OpenCV VideoCapture Not Working in Diamondback?

asked 2011-06-05 02:21:12 -0600

dkst gravatar image

Hi all, I recently updated my diamondback version to the latest version and I realised that my packages that I had written previously that used OpenCV's VideoCapture (webcam) fail to work. That is the code:

cv::VideoCapture capture;;

always returns FALSE. When I compile the latest OpenCV 2.2 library outside the ROS framework and run it, my web cam is always initialised properly so I know its not a problem with OpenCV. My webcam works fine with Cheese as well so it's not at fault too. I am running Ubuntu 10.04 LTS with a full clean install of ROS Diamondback with the required vision-opencv stacks.

Has anyone else had the same experience? Or does anyone have any advice for me to take?


edit retag flag offensive close merge delete


Do you have an isolated test case that runs properly when linked against your manually compiled OpenCV libraries works, and does not work if linked against the pre-built OpenCV libraries in Diamondback? That would be pretty strange. Did you check out OpenCV 2.2 from branches/2.2 in revision 5206?
Julius gravatar image Julius  ( 2011-06-07 14:24:37 -0600 )edit
Hi, dkst, have u solved this problem yet? I go through this problem, and have no idea about it. I reinstall my ROS, but it also doesn't work.
Yongqiang Gao gravatar image Yongqiang Gao  ( 2011-06-11 00:03:48 -0600 )edit

3 Answers

Sort by » oldest newest most voted

answered 2011-06-20 05:49:32 -0600

James Bowman gravatar image

Hi all, the ROS opencv packge (opencv2) does not build the video interface options - we took this decision early because of the fragility of the OpenCV video capture and I/O code.

In use this tends not to be a problem because we usually source images via ROS, and use cv_bridge to import images (or sequences of images for video) into OpenCV.

edit flag offensive delete link more


Brian Gerkey gravatar image Brian Gerkey  ( 2011-06-20 06:48:38 -0600 )edit

answered 2011-06-08 15:04:15 -0600

Yongqiang Gao gravatar image

That problem falls to me unluckily, after i arrange my older openCV libraries for trying to solve the problem that it can't open local video file.

I think it disorder the connections between vision_opencv. I haven't any constructively suggestion, except to re-install diamondback.

Anyone has some better advice?

edit flag offensive delete link more


I would have surely used this Idea if the others didn't work.Thanks

Leyonce gravatar image Leyonce  ( 2014-03-30 22:38:02 -0600 )edit

answered 2011-06-12 06:21:02 -0600

nicktheanimal25 gravatar image

updated 2011-06-12 06:21:41 -0600

I was having the same problem trying to use create_webcam. It looks like there is just something wrong with whatever version of opencv gets installed through the ros repositories. My quick and dirty solution was to compile/install opencv from source, and then copy all of the libraries into the ros opencv/lib directory:

$ roscd opencv2/opencv

$ sudo mv lib/ lib.orig/

$ mkdir lib

$ cd lib

$ sudo cp <path to="" opencv="" binaries="">libopencv* ./

Hopefully ros will get this sorted out soon, but this fix is working for me at the moment.

edit flag offensive delete link more


I have just solved with this problem. For ROS originally doesn't support ffmpeg, we should turn on those flags at Makefile in "Opencv2" in "vision_opencv" , and then rebuild it. By the way, if ros in /opt/, it doesn't rebuild very well, so I copy "vision_opencv" into my "~/". Hope for helping u.
Yongqiang Gao gravatar image Yongqiang Gao  ( 2011-06-12 13:32:43 -0600 )edit

Cool pal.That's so cool.

Leyonce gravatar image Leyonce  ( 2014-03-30 22:35:26 -0600 )edit

Question Tools


Asked: 2011-06-05 02:21:12 -0600

Seen: 2,290 times

Last updated: Jun 20 '11