开发者

python opencv: no image

I am trying to capture from a Sony Handicam DCR-HC38, running the code below, and passing [-1 .. 3] to the CaptureFromCAM function. Th开发者_如何学运维e code runs, but I get no image. Do I need to "wrap" the camera somehow? Skype recognizes the camera, but python/opencv won't. I'm running Windows Vista if that helps any.

import cv

cv.NamedWindow("camera", 1)

capture = cv.CaptureFromCAM(-1)

while True:
    img = cv.QueryFrame(capture)
    cv.ShowImage("camera", img)
    if cv.WaitKey(10) == 27:
        break


try increasing the delay on the cv.WaitKey


not sure if you fixed it or not. But the solution I figured out is by checking which driver OpenCv is trying to access... I have both v4l1 and v4l2, however I can only access device /dev/video0 by using gstreamer codec and the v4l2 driver on my lenovo x200 (internal webcam) using ubuntu 10.10. So I had to recompile Opencv from source, by firstly applying the patch found at:

Opencv-2.0.0.link.v4l2.patch

extract the patch to your opencv root directory: then open terminal and cd to the opencv root directory, and do the following:

patch -p0 <OpenCV-2.0.0-link-v4l2.patch

then:

make
make install

Now your opencv libraries should access the v4l2 driver instead, hope this helps someone

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜