Ask Your Question

Revision history [back]

I can't call the video that is stored in my laptop using VideoCapture() method of opencv.

f 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

click to hide/show revision 2
No.2 Revision

updated 2015-02-18 01:49:20 -0600

berak gravatar image

I can't call the video that is stored in my laptop using VideoCapture() method of opencv.

f 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

np

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

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

while (True):

ret, frame = cap.read()

cap.read()

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

cv2.COLOR_BGR2GRAY) cv2.imshow('Frame', frame)

cv2.imshow('Frame', frame)

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

break

cap.release() cv2.destroyAllWindows()

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

click to hide/show revision 3
No.3 Revision

I can't call the video that is stored in my laptop using VideoCapture() method of opencv.

f If I write: cap = cv2.VideoCapture(0), cv2.VideoCapture(0), my code works properly. but whenever I write cap = cv2.VideoCapture('C:\Users\Anjali\Documents\Python_Files\Video_tracking\slow.mp4'), 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: this:

cv2.imshow('Frame', frame)
error: ........\opencv\modules\highgui\src\window.cpp:261: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow

cv::imshow