【发布时间】:2016-10-30 17:30:03
【问题描述】:
我有以下代码:
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
if ret:
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
print(ret)
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
这是打开网络摄像头的示例代码。几个月前,我可以毫无问题地运行它,并且网络摄像头与 QuickTime 配合得很好。
但是现在,不管怎样,cap.read() 总是返回 False。 我在 VideoCapture() 上尝试了从 -1 到 3 的不同数字,但它们都不起作用
我很确定这不是代码的错。但是环境肯定有什么问题。 目前我正在使用 python 3.5,open-cv 3.1.0 这个 python 解释器是 /usr/local/Cellar/python3/...
你有什么建议可以解决这个问题吗?
【问题讨论】:
标签: python-3.x opencv video-capture