OpenCV It's based on BSD The license ( Open source ) Cross platform distribution Computer vision and machine learning Software library , Can run in Linux、Windows、Android and Mac OS On the operating system . It's lightweight and efficient -- By a series of C Functions and small quantities C++ Class a , It also provides Python、Ruby、MATLAB Language interface , Realized The image processing And many general algorithms in computer vision .
OpenCV use C++ Language writing , It has C ++,Python,Java and MATLAB Interface , And support Windows,Linux,Android and Mac OS,OpenCV Mainly for real-time visual applications , And use when available MMX and SSE Instructions , Now it's also available for C#、Ch、Ruby,GO Support for .
This article applies to Win10 64 Bit system Python3.8.6.python3.8.6、pip As a prerequisite .
python It can be downloaded from the official website ：https://www.python.org/downloads/windows/, It is recommended to use exe installer,pip It will be installed with it .
Add... To the environment variable python The installation path ：
pip install numpy pip install matplotlib pip install opencv-python
C:\Windows\system32>pip list // result Package Version --------------- --------- certifi 2020.6.20 cycler 0.10.0 kiwisolver 1.2.0 matplotlib 3.3.2 numpy 1.19.3 opencv-python 184.108.40.206 Pillow 8.0.1 pip 20.2.4 pyparsing 2.4.7 python-dateutil 2.8.1 setuptools 50.3.2 six 1.15.0 wheel 0.35.1
such ,OpenCV The environment has been set up .
Write as follows Python Script ：
# Import cv modular import cv2 as cv # Read images , Support bmp、jpg、png、tiff And so on img = cv.imread("D:\Lena.jpg") # Create windows and display images cv.namedWindow("Image") cv.imshow("Image",img) cv.waitKey(0) # release window cv2.destroyAllWindows()
Run the above script , If you can show the test image , Then the environment is built successfully .