Open CV 3.0.0 video not processing windows winpython 2.7.9
Question: I wrote the following code to open a video file and the file is in the same
directory as the script, moreover the code to write a video feed from the
camera to the file is not working!

    
    
    import numpy as np
    import cv2
    cap = cv2.VideoCapture('F:/vtest.avi')
    print cap.isOpened()
    if(cap.isOpened()== False):
        cap.open('F://vtest.avi')
        print cap.isOpened()
    while(cap.read()):
        ret,frame = cap.read()
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('frame',gray)
        if cv2.waitKey(1) == ord('q'):
            break
    cap.release()
    cv2.destroyAllWindows()
    

But the code threw the following errors. I tried moving the ffmpeg.dll file in
Python directory but to no avail.

    
    
    False
    False
    Traceback (most recent call last):
      File "F:\2.py", line 11, in <module>
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    error: ..\..\..\..\opencv\modules\imgproc\src\color.cpp:3480: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
    


Answer: Try this:

    
    
    import numpy as np
    import cv2
    cap = cv2.VideoCapture('F:/vtest.avi')
    while(cap.isOpened()):
        ret,frame = cap.read()
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('frame',gray)
        if cv2.waitKey(1) == ord('q'):
            break
    cap.release()
    cv2.destroyAllWindows()
    

Also, place the video in the same directory as this script and check if it
works.

