Preamble: python (x, y) has been used before, but it is found to be prone to some pythonw.exe to stop working when using OPENCV. Later found that their operating system is 64-bit, but installed a 32-bit Python (x, y), although this has been installed before the Theano, OPENCV and other packaged libraries, but spent an afternoon of time did not solve the problems before the problem, the temporary solution is not the root causes. Therefore, decisively give up treatment, choose Opecv + Anaconda. Anaconda Python is a collection of Python science and technology packages, similar in functionality to Python (x, y). It's a new show that has been updated many times. Package management using Conda,gui based on pyside, all packages are basically the latest version, no PYQT and Wxpython, etc., the capacity is moderate, but the scientific calculation package has: Numpy,sicpy,matplotlib,spyder, etc., is a completely free enterprise-class Python release for large-scale data processing, predictive analytics, and scientific computing tools.
No more talking, go straight to the steps.
1. Download and install Anaconda corresponding version. Website Link https://www.continuum.io/downloads
2, the network management download OPENCV corresponding version ( Note: The python2.7 version can only be used with opencv2.4 version only available ). Website Link: http://opencv.org/, after installation, do the following two operations
First step: Copy Cv2.pyd from the OPENCV installation directory D:\Program files\opencv\build\python\2.7\x64 to the Anaconda installation directory C:\Anaconda2\Lib\ Under the site-packages.
Step two: Copy the Opencv_ffmpeg_64.dll under D:\Program files\opencv\sources\3rdparty\ffmpeg to C:\Anaconda2 and rename it to Opencv_ Ffmpeg2413_64.dll, where 2413 refers to the OpenCV version number, I downloaded the 2.4.13 version.
Read the video code below, where the second step is mainly to avoid the problem of reading video failure:
1 #-*-coding:utf-8-*-2 ImportCv23 4Cap = Cv2. Videocapture ('01.avi')5 6 while(cap.isopened ()):7Ret,frame =Cap.read ()8Cv2.imshow ('Video Test', frame)9Key = Cv2.waitkey (10)Ten ifKey = = 27: One Break A ifKey = = Ord (' '): -Cv2.imwrite ('vid_result.jpg', frame)
Cv2.imshow (' video test ', frame)
Cv2.error:.. \.. \.. \.. \opencv\modules\highgui\src\window.cpp:261:error: ( -215) size.width>0 && size.height>0 in function CV:: Imshow
OPECV + Anaconda Read video (Windows)