最简单方法:windows平台下python安装opencv,即实现import cv2功能

之前用的下面旧方法装好了opencv,重装系统后按照原来的方法重装了下opencv,结果一直报错:
ImportError: Module use of python27.dll conflicts with this version of Python
最后找到了更为简单便捷的新方法,特此更新:


新方法

准备工作
首先安装python、pip、numpy
安装教程参考以前的文章:
安装python:http://blog.csdn.net/lyj_viviani/article/details/51763101
安装pip: http://blog.csdn.net/lyj_viviani/article/details/70568434
安装numpy:使用命令行输入pip install numpy即可自动安装

正式步骤
进入https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv,根据之前python的版本决定下载whl格式文件,下载后进入文件所在位置,命令行输入pip install *.whl

这里写图片描述

最后验证下这样就安装成功了,so easy!


旧方法
【准备工作】先安装python、pip、numpy、OpenCV
【正式步骤】
(1)在opencv的安装目录”
\opencv\build\python\2.7\x64”或”\opencv\build\python\2.7\x86”(根据python版本)文件夹中找到cv2.pyd
(2)复制到Python安装目录的”\Python27\Lib\site-packages”文件夹中。

这里写图片描述

这里写图片描述

(3)测试是否成功,没有报错,果断成功。

这里写图片描述

### OpenCV on Windows Installation and Usage Guide #### Unpacking OpenCV To begin with, one should choose a directory where OpenCV will be unpacked. For instance, placing it under `C:\Work\android-opencv\` allows easy access within projects that require computer vision capabilities[^1]. #### Setting Up Environment Variables After installing OpenCV, adding its path to the system's environment variables is essential for ensuring applications can locate necessary libraries during runtime. Specifically, appending `D:\opencv346vc16vs2019\x64\vc16\bin` ensures all required binaries are accessible globally across different development environments such as command line or IDEs like Eclipse when working on Java-based Android projects[^2]. #### Integrating OpenCV into Development Environments Once these steps are completed successfully, integrating OpenCV becomes straightforward using popular Integrated Development Environments (IDE). In particular, opening both the main library alongside sample codes provided by default inside an IDE facilitates immediate experimentation without additional setup hassles. #### Python Integration via Symbolic Linking For developers preferring Python over C++ API of OpenCV, creating symbolic links might prove useful especially if multiple versions coexist side-by-side. An example would involve linking `/usr/local/python/cv2/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so` which could serve similar purposes even though this specific instruction targets Linux systems rather than Windows ones; analogous methods exist depending upon personal preferences regarding version management tools used locally[^3]. #### Additional Tools Setup Beyond core functionalities offered directly through OpenCV itself, incorporating external OCR engines enhances overall utility significantly. Installing packages like PyTesseract enables text recognition from images effortlessly once Tesseract has been properly set up according to official documentation guidelines tailored towards respective operating platforms including but not limited to Ubuntu distributions mentioned here[^4].
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值