我安装了Open CV和brew
的所有深度
http://docs.opencv.org/3.1.0/dd/d43/tutorial_py_video_display.html gsc.tab = 0
我可以让它与我的网络摄像头一起工作,但无法读取AVI或MP4文件。每次,当我执行这个命令时:
ret, frame = cap.read()
, frame
为None
。
Python 2.7.10 (default, Sep 23 2015, 04:34:14)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.12'`
脚本如下:
import cv2
cap = cv2.VideoCapture('drop.avi')
while cap.isOpened():
ret, frame = cap.read() # frame is ALWAYS None.
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
提前感谢您的帮助!
可以尝试重新安装支持python和ffmpeg的opencv
brew install opencv --with-ffmpeg -v
但在此之前安装perian
http://www.perian.org/