Mike Lawrence
Mike Lawrence

Reputation: 1701

Webcam not working with python interface to OpenCV 2.4 on Ubuntu 12.04

Yesterday I installed Ubuntu 12.04 on a brand new HD, ran all the updates (sudo apt-get updates && sudo apt-get upgrade), installed a bunch of stuff from apt (sudo apt-get install git libsdl1.2-dev python-dev python-setuptools python-numpy python-scipy python-nose ipython python-pygame libcv-dev python-opencv), then installed openCV 2.4 from source (following the instructions here). However, when I attempt to use the python interface to capture an image from a webcam (I've tried both c910 and c920 models from logitech), I get "None" as the result:

>>> import cv
>>> webcam_stream = cv.CaptureFromCAM(0) #I've also tried cv.CaptureFromCAM(-1) with the same results
>>> this_image = cv.QueryFrame(webcam_stream)
>>> print(this_image)
None

Any ideas why this is failing? Webcam apps available from the Ubuntu software center (like Cheese) seem to grab images from the cameras just fine, so I'm very confused!

Upvotes: 2

Views: 1509

Answers (2)

Froyo
Froyo

Reputation: 18487

You need to install v4l-utils to set up the webcam. Here is a detailed step by step information about installing OpenCV 2.4 from source. http://jayrambhia.com/blog/install-opencv-2-4-in-ubuntu-12-04-precise-pangolin/

Upvotes: 0

user784435
user784435

Reputation:

Had exactly the same issue today, no idea why the webcam stopped working with openCV, to fix it I went into my OpenCV source build directory and ran sudo make install which worked - the answers with links to install howtos are pointless and misleading

Upvotes: 1

Related Questions