Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Reading video from a video file not working.

import cv2

cap = cv2.VideoCapture('vtest.avi')

while(cap.isOpened()):

ret, frame = cap.read()


if(ret): 

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


    cv2.imshow('frame',gray)
    if cv2.waitKey(1000) & 0xFF == ord('q'):
        break
else:
    break


if cv2.waitKey(1) & 0xFF == ord('q'):
    break

cap.release() cv2.destroyAllWindows()

The code runs but outputs nothing. I am using python 3 and opencv 3 on mac high sierra

Reading video from a video file not working.

import cv2

cap = cv2.VideoCapture('vtest.avi')

while(cap.isOpened()):Code:

import cv2

cap = cv2.VideoCapture('vtest.avi')

while(cap.isOpened()):

    ret, frame = cap.read()


 if(ret): 

     gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


     cv2.imshow('frame',gray)
     if cv2.waitKey(1000) & 0xFF == ord('q'):
         break
 else:
     break


 if cv2.waitKey(1) & 0xFF == ord('q'):
     break

cap.release()
cv2.destroyAllWindows()

cap.release() cv2.destroyAllWindows()

The code runs but outputs nothing. I am using python 3 and opencv 3 on mac high sierra