Python安装OpenCV的示例代码


Posted in Python onMarch 05, 2020

Python安装OpenCV的示例代码

OpenCV介绍

OpenCV是一个基于BSD许可(开源)发行的跨平台计算机视觉库,可以运行在Linux、Windows、Android和Mac OS操作系统上。它轻量级而且高效——由一系列 C 函数和少量 C++ 类构成,同时提供了Python、Ruby、MATLAB等语言的接口,实现了图像处理和计算机视觉方面的很多通用算法。

OpenCV用C++语言编写,它的主要接口也是C++语言,但是依然保留了大量的C语言接口。该库也有大量的Python、Java and MATLAB/OCTAVE(版本2.5)的接口。这些语言的API接口函数可以通过在线文档获得。如今也提供对于C#、Ch、Ruby,GO的支持。

OpenCV 拥有包括 500 多个C函数的跨平台的中、高层 API。它不依赖于其它的外部库——尽管也可以使用某些外部库。

所有新的开发和算法都是用C++接口。一个使用CUDA的GPU接口也于2010年9月开始实现。

OpenCV 为Intel Integrated Performance Primitives(IPP)提供了透明接口。这意味着如果有为特定处理器优化的 IPP 库,OpenCV 将在运行时自动加载这些库。

注:OpenCV 2.0版的代码已显著优化,无需IPP来提升性能,故2.0版不再提供IPP接口。

好了,下面开始今天的正文。

安装python-3.7.3-amd64.exe

命令行进入到你Python的安装目录中的Scripts下:D:\Program Files\Python37\Scripts

安装pip

进入Python安装目录下的Scripts路径,执行 easy_install.exe pip

安装wheel

进入Python安装目录下的Scripts路径,执行 pip install wheel

安装numpy

进入Python安装目录下的Scripts路径,执行 pip install numpy

安装opencv

进入Python安装目录下的Scripts路径,执行 pip install opencv-python

Microsoft Windows [版本 10.0.17134.706]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\LiuJing>D:

D:\>cd D:\Program Files\Python37\Scripts

D:\Program Files\Python37\Scripts>easy_install.exe pip
Searching for pip
Best match: pip 19.0.3
Adding pip 19.0.3 to easy-install.pth file
Installing pip-script.py script to d:\program files\python37\Scripts
Installing pip.exe script to d:\program files\python37\Scripts
Installing pip3-script.py script to d:\program files\python37\Scripts
Installing pip3.exe script to d:\program files\python37\Scripts
Installing pip3.7-script.py script to d:\program files\python37\Scripts
Installing pip3.7.exe script to d:\program files\python37\Scripts

Using d:\program files\python37\lib\site-packages
Processing dependencies for pip
Finished processing dependencies for pip

D:\Program Files\Python37\Scripts>pip install wheel
Collecting wheel
 Downloading https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl
Installing collected packages: wheel
Successfully installed wheel-0.33.1
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

D:\Program Files\Python37\Scripts>pip install numpy
Collecting numpy
 Downloading https://files.pythonhosted.org/packages/4e/9d/c129d78e6b942303b762ccfdf1f8339de80c5e6021b14ef0c99ec5bdc6aa/numpy-1.16.3-cp37-cp37m-win_amd64.whl (11.9MB)
  100% |????????????????????????????????| 11.9MB 197kB/s
Installing collected packages: numpy
Successfully installed numpy-1.16.3
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

D:\Program Files\Python37\Scripts>pip install opencv-python
Collecting opencv-python
 Downloading https://files.pythonhosted.org/packages/a3/50/04d0669afe884f137c2f490642756e8c4a658254300a9eaf253d1e643085/opencv_python-4.1.0.25-cp37-cp37m-win_amd64.whl (37.3MB)
  100% |????????????????????????????????| 37.4MB 150kB/s
Requirement already satisfied: numpy>=1.14.5 in d:\program files\python37\lib\site-packages (from opencv-python) (1.16.3)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.1.0.25
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

D:\Program Files\Python37\Scripts>
import cv2

img = cv2.imread("01.jpg")
cv2.imshow("1", img)
cv2.waitKey(10000)

如果能导入并显示图片则成功

总结

到此这篇关于Python安装OpenCV的示例代码的文章就介绍到这了,更多相关Python安装OpenCV内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
Python Queue模块详解
Nov 30 Python
Python的Django框架中的select_related函数对QuerySet 查询的优化
Apr 01 Python
python生成ppt的方法
Jun 07 Python
Python延时操作实现方法示例
Aug 14 Python
python requests 库请求带有文件参数的接口实例
Jan 03 Python
Python编程实现tail-n查看日志文件的方法
Jul 08 Python
python实现socket+threading处理多连接的方法
Jul 23 Python
详解用python生成随机数的几种方法
Aug 04 Python
Python利用requests模块下载图片实例代码
Aug 12 Python
Python中包的用法及安装
Feb 11 Python
基于Python的一个自动录入表格的小程序
Aug 05 Python
解决jupyter notebook启动后没有token的坑
Apr 24 Python
opencv python在视屏上截图功能的实现
Mar 05 #Python
谈谈Python:为什么类中的私有属性可以在外部赋值并访问
Mar 05 #Python
python如何将两张图片生成为全景图片
Mar 05 #Python
Python 定义只读属性的实现方式
Mar 05 #Python
Pycharm中import torch报错的快速解决方法
Mar 05 #Python
Python中私有属性的定义方式
Mar 05 #Python
Python实现AI自动抠图实例解析
Mar 05 #Python
You might like
PHP抓取远程图片(含不带后缀的)教程详解
2016/10/21 PHP
php中遍历二维数组并以表格的形式输出的方法
2017/01/03 PHP
PHP简单实现循环链表功能示例
2017/11/10 PHP
js中数组Array的一些常用方法总结
2013/08/12 Javascript
javascript内存管理详细解析
2013/11/11 Javascript
Ajax同步与异步传输的示例代码
2013/11/21 Javascript
快速解决jquery之get缓存问题的最简单方法介绍
2013/12/19 Javascript
提取jquery的ready()方法单独使用示例
2014/03/25 Javascript
jQuery实现的Div窗口震动特效
2014/06/09 Javascript
jQuery选择器querySelector的使用指南
2015/01/23 Javascript
jQuery实现仿美橙互联两级导航菜单的方法
2015/03/09 Javascript
jquery中添加属性和删除属性
2015/06/03 Javascript
JS简单实现浮动窗口效果示例
2016/09/07 Javascript
给easyui的datebox控件添加清空按钮的实现方法
2016/11/09 Javascript
Angularjs+bootstrap+table多选(全选)支持单击行选中实现编辑、删除功能
2017/03/27 Javascript
vue mintui-Loadmore结合实现下拉刷新和上拉加载示例
2017/10/12 Javascript
Vue实现web分页组件详解
2017/11/28 Javascript
nodejs超出最大的调用栈错误问题
2017/12/27 NodeJs
Element Table的row-class-name无效与动态高亮显示选中行背景色
2018/11/30 Javascript
vue中$nextTick的用法讲解
2019/01/17 Javascript
vue-cli3项目配置eslint代码规范的完整步骤
2020/09/10 Javascript
ES2020让代码更优美的运算符 (?.) (??)
2021/01/04 Javascript
Python面向对象类继承和组合实例分析
2018/05/28 Python
Django 浅谈根据配置生成SQL语句的问题
2018/05/29 Python
Python 调用PIL库失败的解决方法
2019/01/08 Python
Django ModelForm组件使用方法详解
2019/07/23 Python
关于Tensorflow分布式并行策略
2020/02/03 Python
《与象共舞》教学反思
2014/02/24 职场文书
合作意向书范本
2014/03/31 职场文书
作风建设整改方案
2014/10/27 职场文书
北京英语导游词
2015/02/12 职场文书
如何理解Vue简单状态管理之store模式
2021/05/15 Vue.js
Java Socket实现Redis客户端的详细说明
2021/05/26 Redis
Python激活Anaconda环境变量的详细步骤
2021/06/08 Python
Python函数式编程中itertools模块详解
2021/09/15 Python
Python 绘制多因子柱状图
2022/05/11 Python