Python安装OpenCV的示例代码
作者:D.D.U 发布时间:2022-05-25 23:35:44
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)
如果能导入并显示图片则成功
来源:https://blog.csdn.net/u010921682/article/details/89675847
猜你喜欢
- 1、拆箱>>> a, b, c = 1, 2, 3>>> a, b, c(1, 2, 3)>>
- model.py:#!/usr/bin/python# -*- coding: utf-8 -*-import torchfrom torc
- AICodeHelper是一款AI编程助手,旨在帮助程序员提高他们的编码技能。简单的像尝试的代码直接问就行,但是一些复杂的,就得需要写技巧;
- 目录1. 线程的概念1.1 Manager_进程通信1.2 线程的概念2. 线程的基本使用3. 自定义线程_守护线程3.1 自定义线程3.2
- 批处理可以很方便地和其它各种语言混合编程,除了好玩,还有相当的实用价值,比如windows版的ruby gem包管理器就是运用了批处理和ru
- 一、了解Variable顾名思义,Variable就是 变量 的意思。实质上也就是可以变化的量,区别于int变量,它是一种可以变化的变量,这
- 我想要向您介绍能想像到的开始 GUI 编程的最简单方法,就是使用 Scriptics 的 TK 和 Tkinter 封装器。我们将与 dev
- 开门见山,直接以例子介绍: 代码如下:CREATE TABLE [dbo].[course]( [id] [int] NULL,
- 出现原因:缺失相应的whl文件。解决办法:下载并安装对应的whl文件。提供一个whl文件的下载网址:http://www.lfd.uci.e
- 本文实例讲述了Python通过公共键对字典列表排序算法。分享给大家供大家参考,具体如下:问题:想根据一个或多个字典中的值来对列表排序解决方案
- 这是个基于three.js的插件,预览地址:戳这里使用方法:1、这个插件的用法很简单,引入如下2个js<script src=&quo
- 1. js的数据类型1.1 js引入方式<!DOCTYPE html><html lang="en"&
- ActiveServerPages,ASP0126(0x80004005)-->找不到包含文件MicrosoftOLEDBProvid
- 1.交换变量x = 6y = 5x, y = y, xprint x>>> 5print y>>> 62
- 本文实例为大家分享了python爬取哈尔滨天气信息的具体代码,供大家参考,具体内容如下环境:windows7python3.4(pip in
- 什么是GBFF文件GenBank纯文本文件格式(GenBank flatfile, 简称GBFF)GBFF是GenBank数据库的基本信息单
- 文件可以传输,但是对比传输前后的文件:socket_test.txt,末尾有一些不一致服务端代码:#!/usr/bin/python# -*
- YAML是一种直观的能够被电脑识别的的数据序列化格式,容易被人类阅读,并且容易和脚本语言交互。YAML类似于XML,但是语法比XML简单得多
- 如下所示:#!/usr/bin/python3# -*- coding:UTF-8-*-# Author: zhuhongqiangfrom
- 这篇是Nicholas讨论如果防止脚本失控的第二篇,主要讨论了如何重构嵌套循环、递归,以及那些在函数内部同时执行很多子操作的函数。基本的思想