OpenCVPython:cv2.VideoCapture(0).grab和cv2.VideoCapture(0).read挂起

2024-09-29 21:37:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我的操作系统是Ubuntu 14.04 LTS。在

我使用的是python2.7和opencv3.0beta版,我的网络摄像头是logitechwebcam pro9000。在

Cheese应用程序运行良好,表明网络摄像头驱动程序没有问题。在

在调用cv2.VideoCapture(0).read()(或grab())时,我在大约10秒后收到错误“selecttimeout”。在

我在google上广泛搜索,找到了以下解决方案:

sudo rmmod uvcvideo

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

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


Tags: 网络程序运行readubuntusudocv2beta摄像头
1条回答
网友
1楼 · 发布于 2024-09-29 21:37:59

尝试使用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()

相关问题 更多 >

    热门问题