一看就会的 Anaconda 搭建 OpenCV for Python 环境(全平台通用)

科技资讯 投稿 6000 0 评论

一看就会的 Anaconda 搭建 OpenCV for Python 环境(全平台通用)

前言

视频教程

准备工作

安装 Anaconda 配置好国内镜像源

Windows 安装

Ubuntu 安装

版本信息

3.6
OpenCV 版本 3.4.1.15
OpenCV 扩展包版本 3.4.1.15
dlib 版本 19.6.1

开始搭建

conda create -n OpenCV3.6 python=3.6    # 通过 anaconda 创建虚拟环境

# 点 y 即可

激活虚拟环境

activate OpenCV3.6 # 激活虚拟环境

安装所需资源库

pip install opencv-python==3.4.1.15
pip install opencv-contrib-python==3.4.1.15
pip install dlib==19.6.1
pip install numpy
pip install matplotlib

检查是否成功
显示 3.4.1 就没问题了

# 检查是否成功

python
import cv2
cv2.__version__

程序测试

# 导入cv模块
import cv2

# 读取图像,支持 bmp、jpg、png、tiff 等常用格式
img = cv2.imread('img\cat.jpg'

# 创建窗口并显示图像
cv2.imshow('image', img
cv2.waitKey(0

# 释放窗口
cv2.destroyAllWindows(

参考资料

编程笔记 » 一看就会的 Anaconda 搭建 OpenCV for Python 环境(全平台通用)

赞同 (27) or 分享 (0)
游客 发表我的评论   换个身份
取消评论

表情
(0)个小伙伴在吐槽