当前位置:网站首页>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 .
边栏推荐
- Sequence model
- Codeforces Global Round 21(A-E)
- awk从入门到入土(6)正则匹配
- [Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
- Awk from entry to earth (12) awk can also write scripts to replace the shell
- C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)
- Awk from entry to penetration (6) regular matching
- 微服务入门:Gateway网关
- LinkedList in the list set is stored in order
- How does Xiaobai buy a suitable notebook
猜你喜欢
C language - Introduction - Foundation - syntax - data type (4)
【无标题】转发最小二乘法
The basic syntax of mermaid in typera
Démarrage des microservices: passerelle
Nurse level JDEC addition, deletion, modification and inspection exercise
manjaro安装微信
Codeforces Global Round 21(A-E)
微服務入門:Gateway網關
Educational Codeforces Round 115 (Rated for Div. 2)
4 small ways to make your Tiktok video clearer
随机推荐
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
How does Xiaobai buy a suitable notebook
上周热点回顾(6.27-7.3)
Awk from entry to soil (5) simple condition matching
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(四)
The basic syntax of mermaid in typera
awk从入门到入土(8)数组
埃氏筛+欧拉筛+区间筛
C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)
Research Report on the current market situation and development prospects of calcium sulfate whiskers in China (2022 Edition)
《网络是怎么样连接的》读书笔记 - FTTH
Educational Codeforces Round 115 (Rated for Div. 2)
Educational Codeforces Round 119 (Rated for Div. 2)
In depth research and investment strategy report on China's hydraulic parts industry (2022 Edition)
Mantis creates users without password options
Live in a dream, only do things you don't say
How to solve the problem that computers often flash
Display Chinese characters according to numbers
Ehrlich sieve + Euler sieve + interval sieve
In depth investigation and Strategic Research Report on China's motion controller Market (2022 Edition)