How to build an OpenCV and Python environment

(*-*)浩
Release: 2019-07-09 10:22:38
Original
2569 people have browsed it

Open Source Computer Vision Library.OpenCV was established by Intel in 1999 and is now supported by Willow Garage. OpenCV is a cross-platform computer vision library released under the BSD license (open source) and can run on Linux, Windows, and MacOS operating systems. It is lightweight and efficient - it consists of a series of C functions and a small number of C classes. It also provides interfaces in Python, Ruby, MATLAB and other languages, and implements many common algorithms in image processing and computer vision. The latest version is 3.1, released on January 29, 2016.

How to build an OpenCV and Python environment

#In short, openCV can be used to edit computer images and videos. It is widely used in image recognition, motion tracking, machine vision and other fields.

After everything is ready, run cmd or PowerShell as administrator. Enter the following commands in sequence: (Recommended learning: Python video tutorial)

pip install --upgrade setuptools
pip install numpy Matplotlib
pip install opencv-python
Copy after login

The opencv environment has been completed, it is that simple. It only requires three packages: numpy, Matplotlib, and opencv-python. It can be downloaded quickly and easily. If an error or wrong occurs during downloading, just re-enter the command.

Test

#导入cv模块
import cv2 as cv
#读取图像,支持 bmp、jpg、png、tiff 等常用格式
img = cv.imread("D:\python\test.jpg")
#创建窗口并显示图像
cv.namedWindow("Image")
cv.imshow("Image",img)
cv.waitKey(0)
#释放窗口
cv2.destroyAllWindows()
Copy after login

Run the above script. If the test image can be displayed, the environment is set up successfully.

For more Python related technical articles, please visitPython tutorial column for learning!

The above is the detailed content of How to build an OpenCV and Python environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!