当前位置:网站首页>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 :
#### 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 .

边栏推荐
- awk从入门到入土(15)awk执行外部命令
- Report on research and investment prospect prediction of China's electronic grade sulfuric acid industry (2022 Edition)
- Awk from getting started to digging in (9) circular statement
- [C Advanced] file operation (2)
- Call Baidu map to display the current position
- Research Report on the current market situation and development prospects of calcium sulfate whiskers in China (2022 Edition)
- The upper layer route cannot Ping the lower layer route
- China electronic grade sulfur trioxide Market Forecast and investment strategy report (2022 Edition)
- [Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
- Display Chinese characters according to numbers
猜你喜欢

How college students choose suitable computers

Implementation principle of redis string and sorted set
![C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)](/img/dc/5c8077c10cdc7ad6e6f92dedfbe797.png)
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)

【无标题】转发最小二乘法

What if I forget the router password
](/img/dc/5c8077c10cdc7ad6e6f92dedfbe797.png)
C语言-入门-基础-语法-[变量,常亮,作用域](五)
](/img/3f/4d8f4c77d9fde5dd3f53ef890ecfa8.png)
C语言-入门-基础-语法-[运算符,类型转换](六)

FOC控制

User login function: simple but difficult

Go zero micro service practical series (IX. ultimate optimization of seckill performance)
随机推荐
swatch
C語言-入門-基礎-語法-[運算符,類型轉換](六)
Awk from entry to soil (5) simple condition matching
Educational Codeforces Round 115 (Rated for Div. 2)
Nurse level JDEC addition, deletion, modification and inspection exercise
Manjaro install wechat
Codeforces Round #750 (Div. 2)(A,B,C,D,F1)
老掉牙的 synchronized 锁优化,一次给你讲清楚!
Live in a dream, only do things you don't say
UML 时序图[通俗易懂]
The upper layer route cannot Ping the lower layer route
4 small ways to make your Tiktok video clearer
ctfshow web255 web 256 web257
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)
ctfshow web255 web 256 web257
Go zero micro service practical series (IX. ultimate optimization of seckill performance)
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(四)
Newh3c - network address translation (NAT)
《网络是怎么样连接的》读书笔记 - Tcp/IP连接(二)
How can we make a monthly income of more than 10000? We media people with low income come and have a look