1

I am using Windows 7 and I have installed python3.6 in it. I have created a virtual environment in which I have installed openCV using pip3 install (it appears as follows in my pip3 list: opencv-python 3.4.1.15).

When I stream a video direclty from the webcam of the laptop it works and frame is a 'numpy.ndarray':

frame= cv2.VideoCapture(0) 

However, when I try to read it from an external .avi file, frame appears to be empty:

frame=cv2.VideoCapture(video.avi) 

My question is similar to this one [1], and apparently the solution they have provided him is adding some dll opencv files to the windows path. However, I am not sure how I could do that if I installed the opencv with pip inside my virtualenv.

[1] OpenCV 2.4 VideoCapture not working on Windows

jotNewie
  • 426
  • 4
  • 17
  • 1
    actually it returns an object, so you call: `grap()` on it, to get `frame`! – Yasin Yousif May 31 '18 at 15:24
  • If I do grab(), in both cases it just hangs and does not return anything – jotNewie May 31 '18 at 15:28
  • 1
    See [this answer](https://stackoverflow.com/a/47116576/2286337). – zindarod May 31 '18 at 15:31
  • Thanks @zindarod, the link is extremely useful. I discovered that .avi is not suitable. Now I am trying with a .mpeg video (my ffmpeg should work on it) and the code is not crashing any more. However it is hanging and not going further. But still a step forward! – jotNewie May 31 '18 at 16:16
  • 1
    You did not read the answer properly. It's not about whether AVI is unsuitable and MPEG is suitable. You should find out 1) if your opencv is built with ffmpeg support 2) if ffmpeg has codec for decoding the video file. – zindarod May 31 '18 at 16:54

0 Answers0