I want to load AVI format videos frame by frame using OpenCV from Python: blush:
I called the read method of cv2.VideoCapture to read the frame of the video and drew it with cv2.imshow, but it turned black all over and was not displayed correctly: rage:
Image of the executed script
cap = cv2.VideoCapture('test.avi')
ret, frame = cap.read()
cv2.imshow('frame', frame)
The video can be played with other software.
I installed Anaconda 3 on Windows10 (64bit) and built a virtual environment of Python 2.7. I installed libraries such as matplotlib, numpy, and pyqt in the virtual environment. In the following, the installation path of Anaconda is C: \ Anaconda
, and the name of the virtual environment is py27
. At this time, the virtual environment configuration file is saved in C: \ Anaconda \ envs \ py27
.
The Python script is edited and executed in the jupyter notebook started from Anaconda.
Download the zip file containing the set of binaries for windows (for example, opencv3.3.0.zip) from the official OpenCV website and unzip it. Copy build \ python \ 2.7 \ x64 \ cv2.pyd
in the unzipped zip file to
C: \ Anaconda \ envs \ py27 \ Lib \ site-packages```. Now you can use the basic functions of OpenCV.
(Please tell me if there is a better way)
Check the following file in `\ build \ bin`
in the zip file (opencv3.3.0.zip earlier) downloaded when you installed OpenCV.
Since this is a 64-bit environment, select ʻopencv_ffmpeg330_64.dll and copy it to
C: \ Anaconda \ envs \ py27 \ Library \ bin`.
that's all.
The content of this article may be inaccurate. We are not responsible for any damage caused by the contents of this article or its use.
[1] https://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows
Recommended Posts