在树莓派上使用opencv4 videocapture对象将read()冻结2次

时间:2019-02-20 16:40:24

标签: python-2.7 opencv raspberry-pi3 video-capture opencv4

在树莓派上使用opencv4 videocapture对象将read()冻结2次。

详细信息:

 - Raspberrypi Jessie
 - python 2.7 + opencv 4 
 - python code can be run on windows10 (py2.7 and opencv4) without problem

这是基于示例的代码:

import cv2
ret, frame = cap.read()
cap = cv2.VideoCapture(0)
countDown = 20
while(countDown > 0 ):

    ret, frame = cap.read()
    print countDown , "readed"
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # cv2.imwrite (  "test" + str(countDown) +   ".png" , gray )
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    countDown -= 1 

cap.release()

结果:

20 readed
19 readed
then hangs forever........

0 个答案:

没有答案