OpenCV-Python:cv2.VideoCapture(0).grab和cv2.VideoCapture(0).read挂起

时间:2015-01-04 19:39:22

标签: python opencv ubuntu

我的操作系统是Ubuntu 14.04 LTS。

我正在使用带有OpenCV 3.0 Beta的Python 2.7,我的网络摄像头是Logitech webcam pro 9000。

干酪应用程序正常运行,表明网络摄像头驱动程序没有问题。

在致电cv2.VideoCapture(0).read()(或grab())时,我收到错误' select timeout'大约10秒后。

我广泛搜索了这个,并找到了以下解决方案:

sudo rmmod uvcvideo

sudo modprobe uvcvideo nodrop=1 timeout=5000 quirks=0x80

现在,API cv2.VideoCapture(0).read()(或grab())就会挂起。

1 个答案:

答案 0 :(得分:0)

尝试使用cv代替cv2

import numpy
import cv2.cv as cv
import cv2
capture = cv.CreateCameraCapture(-1)
while True:

    frame = cv.QueryFrame(capture)
    aframe = numpy.asarray(frame[:,:])
    cv2.imshow("w1", aframe)
    c = cv.WaitKey(5)
    if c == 110: #to quit, the 'n' key is pressed
        exit()
相关问题