0

I am new to OpenCV and simply trying to read in a video file and display it. Unfortunately, it looks like I can't even open the video. Any ideas on what may be preventing me from opening a video file? I can open images just fine. Can anyone help me out? Thanks so much.

Code:

import numpy as np
import cv2

cap = cv2.VideoCapture("F:\\OpenCV\\Cam1_Indoor.avi")

if cap.isOpened():
    print "Opened"
else:
    print "Not opened"

while(1):
    ret, frame = cap.read()
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

Output:

Not opened --------------------------------------------------------------------------- error Traceback (most recent call last) in () 11 while(1): 12 ret, frame = cap.read() ---> 13 cv2.imshow('frame',frame) 14 if cv2.waitKey(1) & 0xFF == ord('q'): 15 break

error: C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\highgui\src\window.cpp:271: error: (-215) size.width>0 && size.height>0 in function cv::imshow

FullStack
  • 5,902
  • 4
  • 43
  • 77
  • It looks like you're trying to display an image with no size, possibly because `ret, frame = cap.read()` failed. – 101 Dec 08 '15 at 03:38
  • @101 - it looks like I can't even open the file, according to `isOpened`. Any ideas on what may be preventing me from opening a video file? I can open images just fine. – FullStack Dec 08 '15 at 03:47
  • 4
    Maybe this is your problem: https://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows – 101 Dec 08 '15 at 03:58
  • 1
    @101 - oh my, yes that solved it. Thanks so much!!! – FullStack Dec 08 '15 at 04:11

0 Answers0