OpenCV + Ubuntu 11.04 + Macbook Pro: Can't initialize webcam?

I installed OpenCV-2.3.1a and ffmpeg built with x264. The operating system is Ubuntu 11.04 running on a Macbook Pro 7,1 laptop.

No matter what I do, I can't get the webcam to work. For example, I tried running the sample code video_dmtx.cpp and I always get the "Failed to open a video device or video file!" error.

I know my built-in iSight webcam and external webcam are working because

ls /dev/video* returns

/dev/video0 /dev/video1

I've tested them both out using xawtv -c /dev/video0

To eliminate problems pertaining to multiple webcams, I unplugged the external cam and ran the sample code to see if the default iSight would be detected, but the pointer is still null.

Please help!!!


I fixed the problem!

The camera did indeed work with other software so I knew it wasn't a hardware issue and had something to do with the installation.

I did a clean install of OpenCV following this guide: http://ozbots.org/opencv-installation/

As mentioned in the discussions at the end of the tutorial, I also did the following to avoid build errors: 1) In step 4 where I installed x264, I replaced '--enable-static' with '--enable-shared --enable-pic'

2) In step 5 where I installed ffmpeg, I appended '--enable-shared --enable-pic' to the end of the ./configure command

The camera worked afterwards! I think the problem was that I was missing some packages...

Anyway, hope this helps anyone else experiencing similar problems!

链接地址: http://www.djcxy.com/p/83776.html

上一篇: Webcam框架在Java中不能用于macbook

下一篇: OpenCV + Ubuntu 11.04 + Macbook Pro:无法初始化网络摄像头?