python opencv+opencv_contrib 4.0dev 重新编译-----cmake+vs201764-----为了用SIFT、SURF这些算法

1、参考
https://blog.csdn.net/qq385105501/article/details/73770826
https://blog.csdn.net/u012900686/article/details/69442406?locationNum=13&fps=1
2、工具环境: cmake在这里插入图片描述
vs2017 64bit:
在这里插入图片描述
python3:
(base) C:\Users\Monster>python Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32 Type “help”, “copyright”, “credits” or “license” for more information.

3、opencv下载:两个都要下载
https://github.com/opencv/opencv
https://github.com/opencv/opencv_contrib

4、随便找个地方新建一个文件夹,我这里的方法是在D盘新建opencv,再新建source和build两个文件夹,在source文件夹内部将下载的两个opencv都解压进去如图在这里插入图片描述

5、CMAKE定位,定位到
在这里插入图片描述
在这里插入图片描述
6、configure在这里插入图片描述
7、检查有没有这一项在这里插入图片描述
8、在这里插入图片描述
在这里插入图片描述
9、复制下图中文件到D:\ProgramData\Anaconda3\Lib\site-packages在这里插入图片描述
10、添加环境变量
在这里插入图片描述
11、测试
在这里插入图片描述
在这里插入图片描述
成功

PS。
可能遇到的错误:
1、>>> import cv2
[‘D:/ProgramData/Anaconda3/Lib/site-packages/cv2\python-3.7’, ‘’, ‘D:\ProgramData\Anaconda3\python37.zip’, ‘D:\ProgramData\Anaconda3\DLLs’, ‘D:\ProgramData\Anaconda3\lib’, ‘D:\ProgramData\Anaconda3’, ‘D:\ProgramData\Anaconda3\lib\site-packages’, ‘D:\ProgramData\Anaconda3\lib\site-packages\win32’, ‘D:\ProgramData\Anaconda3\lib\site-packages\win32\lib’, ‘D:\ProgramData\Anaconda3\lib\site-packages\Pythonwin’]
Traceback (most recent call last):
File “”, line 1, in
File “D:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py”, line 89, in
bootstrap()
File “D:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py”, line 79, in bootstrap
import cv2
File “D:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py”, line 89, in
bootstrap()
File “D:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py”, line 23, in bootstrap
raise ImportError(‘ERROR: recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation.’)
ImportError: ERROR: recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation.
在这里插入图片描述

解决办法:
cd到我们编译的.\build\python_loader;我的是 D:\OpenCV4.0.1\build\python_loader。这个文件夹里面有个setup.py
命令行安装:python setup.py develop
running develop
running egg_info
creating opencv.egg-info
writing opencv.egg-info\PKG-INFO
writing dependency_links to opencv.egg-info\dependency_links.txt
writing requirements to opencv.egg-info\requires.txt
writing top-level names to opencv.egg-info\top_level.txt
writing manifest file ‘opencv.egg-info\SOURCES.txt’
reading manifest file ‘opencv.egg-info\SOURCES.txt’
writing manifest file ‘opencv.egg-info\SOURCES.txt’
running build_ext
Creating d:\programdata\anaconda3\lib\site-packages\opencv.egg-link (link to .)
Adding opencv 4.0.1 to easy-install.pth file

Installed d:\opencv4.0.1\build\python_loader
Processing dependencies for opencv4.0.1
Searching for numpy
1.15.4
Best match: numpy 1.15.4
Adding numpy 1.15.4 to easy-install.pth file

Using d:\programdata\anaconda3\lib\site-packages
Finished processing dependencies for opencv==4.0.1

测试:
(base) D:\OpenCV4.0.1\build\python_loader>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
cv2.version
‘4.0.1’

2、下载不动(GREATWALL的锅) opencv_ffmpeg.dll, opencv_ffmpeg_64.dll,ippicv_2019_win_intel64_20180723_general,
face_landmark_model.dat.dat,还有xfeatures2d里面的一坨东西

解决办法:
1、多configure几次就好了。实在不行,首先尝试从build文件夹里面的CMakeDownloadLog.txt看,里面有文件名,cmake下载这些文件的路径,尝试自己下载。然后放到source文件夹下(opencv4.0是source.cache\)
在这里插入图片描述
2、直接下载我的吧,传在网盘上,解压为.cache文件夹,直接放到source目录里面
在这里插入图片描述
链接: https://pan.baidu.com/s/1_tYr8DGvPp89IJKQesAO6A 提取码: 8xb7

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值