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

边栏推荐
- 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 to play dapr without kubernetes?
- Bishi blog (13) -- oral arithmetic test app
- Horizon sunrise X3 PI (I) first boot details
- Awk from entry to earth (14) awk output redirection
- Basic discipline formula and unit conversion
- China battery grade manganese sulfate Market Forecast and strategic consulting report (2022 Edition)
- Codeforces Round #750 (Div. 2)(A,B,C,D,F1)
- [attack and defense world | WP] cat
- How to solve the problem that computers often flash
猜你喜欢

Call Baidu map to display the current position

Codeforces Round #750 (Div. 2)(A,B,C,D,F1)

CLion-控制台输出中文乱码
![[error record] no matching function for call to 'cacheflush' cacheflush();)](/img/79/c00f9c835606b2dce1d342ec368d24.jpg)
[error record] no matching function for call to 'cacheflush' cacheflush();)
](/img/89/0f5f4ba07c637b09abe873016cba2d.png)
C语言-入门-基础-语法-[标识符,关键字,分号,空格,注释,输入和输出](三)
](/img/dc/5c8077c10cdc7ad6e6f92dedfbe797.png)
C语言-入门-基础-语法-[变量,常亮,作用域](五)

HMS core helps baby bus show high-quality children's digital content to global developers
](/img/3f/4d8f4c77d9fde5dd3f53ef890ecfa8.png)
C语言-入门-基础-语法-[运算符,类型转换](六)

Dede plug-in (multi-function integration)

Codeforces Round #803 (Div. 2)(A-D)
随机推荐
09 softmax regression + loss function
Awk from entry to earth (15) awk executes external commands
Awk from entry to earth (14) awk output redirection
【LeetCode 42】501. Mode in binary search tree
Horizon sunrise X3 PI (I) first boot details
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
Talk about single case mode
ArcGIS应用(二十二)Arcmap加载激光雷达las格式数据
Educational Codeforces Round 119 (Rated for Div. 2)
NewH3C——ACL
C # implements a queue in which everything can be sorted
swatch
Awk from getting started to digging in (4) user defined variables
C language - Introduction - Foundation - syntax - [main function, header file] (II)
Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)
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
Industry depression has the advantages of industry depression
[Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
[attack and defense world | WP] cat
The old-fashioned synchronized lock optimization will make it clear to you at once!