I install Open CV and all the deps with brew
Following this tutorial:
http://docs.opencv.org/3.1.0/dd/d43/tutorial_py_video_display.html#gsc.tab=0
I'm able to have it working with my webcam but unable to read a AVI or MP4 file. Every time, when I execute this command:
ret, frame = cap.read()
, frame
is 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'`
Here is the script:
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()
Thanks in advance for your help!