当前位置:网站首页>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 .
边栏推荐
- 没有Kubernetes怎么玩Dapr?
- Awk from entry to earth (15) awk executes external commands
- 【LeetCode 42】501. Mode in binary search tree
- C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)
- 根据数字显示中文汉字
- awk从入门到入土(15)awk执行外部命令
- awk从入门到入土(8)数组
- Basic operations of databases and tables ----- view data tables
- Flutter integrated amap_ flutter_ location
- 《网络是怎么样连接的》读书笔记 - FTTH
猜你喜欢
Educational Codeforces Round 115 (Rated for Div. 2)
Comparison between sentinel and hystrix
What if the wireless network connection of the laptop is unavailable
What if I forget the router password
4 small ways to make your Tiktok video clearer
Horizon sunrise X3 PI (I) first boot details
Newh3c - routing protocol (RIP, OSPF)
微服务入门:Gateway网关
【无标题】转发最小二乘法
CLion-控制台输出中文乱码
随机推荐
How to pass custom object via intent in kotlin
Mac platform forgets the root password of MySQL
There are 100 people eating 100 apples, one adult eating 4 apples, and four children eating 1 apple. How can they eat exactly 100 apples? Use any high-level language you are familiar with
ctfshow web255 web 256 web257
[untitled] forwarding least square method
HMS core helps baby bus show high-quality children's digital content to global developers
Manjaro install wechat
China electronic grade sulfur trioxide Market Forecast and investment strategy report (2022 Edition)
Awk from entry to earth (12) awk can also write scripts to replace the shell
awk从入门到入土(12)awk也可以写脚本,替代shell
Codeforces Round #803 (Div. 2)(A-D)
上周热点回顾(6.27-7.3)
System disk expansion in virtual machine
Educational Codeforces Round 115 (Rated for Div. 2)
Review of last week's hot spots (6.27-7.3)
Sword finger offer 30 contains the stack of Min function
C language - Introduction - Foundation - syntax - data type (4)
转:优秀的管理者,关注的不是错误,而是优势
Leetcode topic [array] - 121 - the best time to buy and sell stocks
Educational Codeforces Round 119 (Rated for Div. 2)