开发者

cvCreateCameraCapture returns null

开发者 https://www.devze.com 2023-01-05 21:24 出处:网络
I\'ve got a webcam which is working perfectly in vlc, and is 开发者_如何学Pythonavailable as /dev/video0. However, whenever I use cvCreateCameraCapture, it returns null. I\'ve used 0,1,-1 as indexes.

I've got a webcam which is working perfectly in vlc, and is 开发者_如何学Pythonavailable as /dev/video0. However, whenever I use cvCreateCameraCapture, it returns null. I've used 0,1,-1 as indexes. What could be causing the problem? I'm on Ubuntu 9.10 BTW, using openCV 2.1.0.1 ppa.


I'm using OpenCV 2.1 on Ubuntu 9.04 and this works fine:

CvCapture* capture = NULL;
if ((capture = cvCaptureFromCAM(-1)) == NULL)
{
    std::cerr << "!!! ERROR: cvCaptureFromCAM No camera found\n";
    return -1;
}

Note that I'm using cvCaptureFromCAM() instead of cvCreateCameraCapture().


I also used OpenCV on Ubuntu (but from the standard repos). I had very similar issues and the solution I found was to compile OpenCV from source. I activated the --with-v4l option and it worked fine (you may also need some other flags, depending on your needs). If you compile OpenCV on your own, use CMake. There are also makefiles for "normal" make, but they are old.

0

精彩评论

暂无评论...
验证码 换一张
取 消