当前位置:网站首页>Opencv environment construction (I)
Opencv environment construction (I)
2022-07-04 08:56:00 【Brother Lei talks about programming】
This environment is built OpenCV Of python( For short py) Development environment construction , Based on the py3 Environment and syntax .
windows System building
System environment :windows 10 + python 3.6 + OpenCV 3.4.1
One 、 install python
python Before the installation of python Self study notes The project described , Don't repeat here , Friends in need , Click to see : python Environmental installation
Two 、 install numpy modular
According to the above tips , Now we have installed it correctly python and pip( Installation and management python Package tools ), In formal installation OpenCV Before , First we need to install numpy modular . numpy: Is a language extension that defines numeric array and matrix types and their basic operations ,OpenCV Refer to the numpy modular , So install OpenCV Must be installed before numpy.
This article installs python The module uses .whl File installed .
whl What is the file ?
whl It's a python The package , Which includes py Files and compiled pyd file .
whl Installation command
pip install Storage path \xxx.whl
Back to the topic , We are going to install numpy Modular .
First go to the website to download the corresponding numpy edition , Download address : https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy I am a 64 For the system python3.6 So the corresponding latest version is :numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl, Click download to D: root directory .
The first 2 Step , Start the command form to run
pip install d:\numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl
The command form displays :
Processing d:\numpy-1.14.2+mkl-cp36-cp36m-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.14.2+mkl
The installation is successful .
3、 ... and 、 install OpenCV
Also install OpenCV Module and numpy Similar way , Download from the website OpenCV For the .whl Version pack , website : https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv The version I downloaded is :opencv_python‑3.4.1‑cp36‑cp36m‑win_amd64.whl 64 Bit system corresponds to python3.6 Of , Download to d Packing list .
The first 2 Step , Start the command form to run
pip install d:\opencv_python-3.4.1-cp36-cp36m-win_amd64.whl
Form display :
Processing d:\opencv_python-3.4.1-cp36-cp36m-win_amd64.whl
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.1
Description installation successful .
Four 、 function OpenCV
Here we are , Our environment configuration has been completed , Finally, it's time to roll up the code , Think of a little excitement .
import cv2
print(cv2.__version__)
# Output :3.4.1
- 1.
- 2.
- 3.
- 4.
- 5.
Above we simply print OpenCV Version number of , If it can output normally, no error will be reported , It means that we have OpenCV Of python Environment building ok 了 .
what ? It doesn't feel good yet , Let's draw a picture , use OpenCV Show it , The code is as follows :
import cv2
filepath = "img/meinv.png"
img = cv2.imread(filepath)
cv2.namedWindow('Image')
cv2.imshow('Image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
Linux Build version environment
>Ubuntu 18.04
>Python 3.6.5
>Pip 10.0.1
>Numpy 1.14.3
>OpenCV 3.4.0
Ubuntu One advantage is built-in Python Environmental Science , No need to be like Windows That's for Python The environment is tossed , But here's the thing Ubuntu It comes with itself apt-get And installed pip The data source of is foreign , So it's very slow to use , Must put apt-get and pip Replace the data source with domestic , Please move to :[《Ubuntu apt-get and pip Source replacement 》](http://www.cnblogs.com/vipstone/p/9038023.html)
### The formal installation ###
According to the tips above , You have configured the development environment , Now it needs to be officially installed , Of course Ubuntu The installation of is also better than Windows Simple a lot , Just use pip Installation package , Install the corresponding module .
#### install Numpy ####
Use command :pip3 install numpy
Use command :python3, Get into python Script execution environment , Enter the code to view numpy Is the installation successful , as well as numpy Installation version of :
```
import numpy
numpy.__version__
```
Enter the version number normally , Proof of successful installation .
Pictured :![](http://icdn.apigo.cn/numpy-setup-success.png)
#### install OpenCV ####
OpenCV Is installed in Ubuntu and numpy be similar , Use command :
>pip3 install opencv-python
Use command :python3, Get into python Script execution environment , Enter the code to view OpenCV edition :
```
import cv2
cv2.__version__
```
Enter the version number normally , Proof of successful installation .
# Common mistakes #
A wrong 、python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1` with `/lib/x86_64-linux-gnu/librt.so.1` for IFUNC symbol `clock_gettime`
Segmentation fault (core dumped)
Solution :apt install python3-opencv
More updates , Welcome to visit mine github: https://github.com/vipstone/faceai
Follow the QR code below , Subscribe to more .
边栏推荐
- 【无标题】转发最小二乘法
- Clion console output Chinese garbled code
- NewH3C——ACL
- 1211 or chicken and rabbit in the same cage
- 2022 tower crane driver examination and tower crane driver examination questions and analysis
- Research and investment strategy report of China's electronic hydrogen peroxide industry (2022 Edition)
- 【LeetCode 42】501. Mode in binary search tree
- 地平线 旭日X3 PI (一)首次开机细节
- L1 regularization and L2 regularization
- Report on research and investment prospect prediction of China's electronic grade sulfuric acid industry (2022 Edition)
猜你喜欢
How to re enable local connection when the network of laptop is disabled
Relationship and operation of random events
Sequence model
How college students choose suitable computers
Sword finger offer 30 contains the stack of Min function
C語言-入門-基礎-語法-[運算符,類型轉換](六)
Codeforces Round #803 (Div. 2)(A-D)
What should I do if there is a problem with the graphics card screen on the computer
Guanghetong's high-performance 4g/5g wireless module solution comprehensively promotes an efficient and low-carbon smart grid
AI Winter Olympics | is the future coming? Enter the entrance of the meta universe - virtual digital human
随机推荐
A subclass must use the super keyword to call the methods of its parent class
Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
Awk from entry to penetration (6) regular matching
C语言-入门-基础-语法-[运算符,类型转换](六)
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)
How to play dapr without kubernetes?
What if I forget the router password
In depth research and investment strategy report on China's hydraulic parts industry (2022 Edition)
ArcGIS application (XXII) ArcMap loading lidar Las format data
Report on research and investment prospects of polyglycolic acid industry in China (2022 Edition)
Talk about single case mode
Horizon sunrise X3 PI (I) first boot details
Guanghetong's high-performance 4g/5g wireless module solution comprehensively promotes an efficient and low-carbon smart grid
Industry depression has the advantages of industry depression
Awk from getting started to digging in (9) circular statement
Report on research and investment prospect prediction of China's electronic grade sulfuric acid industry (2022 Edition)
How can we make a monthly income of more than 10000? We media people with low income come and have a look
[C Advanced] file operation (2)
《网络是怎么样连接的》读书笔记 - 认识网络基础概念(一)