Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv2.VideoCapture: Cannot read from file

Hi!

I try to process videos using the Python interface. I downloaded OpenCV 2.4.2 and copied the cv2.py file to the Python27\Lib\site-packages folder on Windows 7.

Using the following code, I'm not able to read video files. capture.isOpened() always returns false. Reading images from Webcam using cv2.VideoCapture(0) works fine, but not from files.

Did I miss to copy some importtant files to the Python directory?

import cv2

if __name__ == '__main__':


    capture = cv2.VideoCapture("test.mpg")

    if capture.isOpened():
            print("Device Opened\n")
    else:
            print("Failed to open Device\n")

    (ret, imageMat) = capture.read()

Cheers, Sly