0

It still gives the error. When I write the below code:

If I write: cap = cv2.VideoCapture(0), my code works properly. but whenever I write cap = cv2.VideoCapture('C:\Users\Anjali\Documents\Python_Files\Video_tracking\slow.mp4'), it does't work.

Below is my code:

import cv2
import numpy as np


cap = cv2.VideoCapture('C:\Users\Anjali\Documents\Python_Files\Video_tracking\slow.mp4')

while (True):

ret, frame = cap.read()

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

cv2.imshow('Frame', frame)

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

cap.release()
cv2.destroyAllWindows()

It gives the following error, please help me in this:

cv2.imshow('Frame', frame)
error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow
CAS
  • 535
  • 1
  • 8
  • 15
Anjali Changlani
  • 41
  • 1
  • 1
  • 3
  • try using cap = cv2.VideoCapture('C:\\Users\\Anjali\\Documents\\Python_Files\\Video_tracking\slow.mp4') – Rahul galgali Feb 18 '15 at 08:37
  • Refer to similar question http://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows?rq=1 – Rahul galgali Feb 18 '15 at 08:39
  • "\" is an escape character in Windows. It's always a good idea to check the value of `ret`. It'll tell you if the capture worked or not. Another member of `VideoCapture` is the function `isOpened()`. – a-Jays Feb 18 '15 at 10:32

0 Answers0