[英]OpenCV-Python: cv2.VideoCapture(0).grab and cv2.VideoCapture(0).read hangs
我的操作系統是Ubuntu 14.04 LTS。
我正在將Python 2.7與OpenCV 3.0 Beta一起使用,而我的網絡攝像頭是Logitech網絡攝像頭專業版9000。
Cheese應用程序運行正常,指示網絡攝像頭驅動程序沒有問題。
在調用cv2.VideoCapture(0).read()
(或grab()
)時,大約10秒鍾后出現錯誤“選擇超時”。
我對此進行了廣泛的搜索,找到了以下解決方案:
sudo rmmod uvcvideo
sudo modprobe uvcvideo nodrop=1 timeout=5000 quirks=0x80
現在,API cv2.VideoCapture(0).read()
(或grab()
)剛剛掛起。
嘗試使用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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.