原文地址

It's been two years already that I see the same subject that hangs on several times concerning SIFT and SURF which cause problems for some. there is always a post about these two.

First of all, you need to understand something: OpenCV is an open source library, which implements algorithms designed by researchers, some of these algorithms are free to use whether for personal or commercial use, others are free for personal use.

Beginning with a small explanation depending on the versions of OpenCV: opencv2 -> opencv3 -> opencv4 -> new_versions of opencv

  • We’re not going to talk about opencv 2 (I guess hardly anyone uses it right now). The only thing you have to remember from this version is that SIFT and SURF worked fine.
  • Since the release of OpenCV3, the SIFT and SURF implementations have been removed from the default installation of OpenCV 3, same for OpenCV 4.

The reason for removing SIFT and SURF is because of what OpenCV calls “non-free” algorithms. SIFT and SURF are (summer) both proprietary and patented algorithms, which means that you must technically obtain permission to use them in commercial algorithms (they are, however, free for academic and research purposes).

For this reason, OpenCV made the decision to move patented algorithms (with experimental implementations) to the package named "opencv_contrib". This means to access SIFT and SURF.

  • Case of OpenCV in C++: you have to compile and install OpenCV from source with opencv-contrib support enabled. (We will see this later)

  • Case of OpenCV in python: you need to install via pip the opencv-contrib-python package as follows:

    pip install opencv-contrib-python
    

however, in some of the versions of OpenCV 3, (the one you are having trouble with in python), both SIFT and SURF algorithms do not want to work, and you get this error: "module 'cv2.cv2' has no attribute 'xfeatures2d' ”.

I can give you an explanation (which is my own opinion), but before that you should know that the OpenCV python package is built by compiling the OpenCV source. Pythons packages are Wheel type files so the extension is ".whl".

So when you do ** pip install opencv-python **, you will actually consult this https://pypi.org/project/opencv-python/#files which will choose the wheel file corresponding to your configuration (operating system as well as the version of python), same for opencv-contrib-python whose link is the following https://pypi.org/project/opencv-contrib-python/#files.

So why don't SIFT and SURF work in all versions of OpenCV?

Hypothesis 1: Forget about activating extra modules, and non-free algorithms from the developers when compiling the source and building the opencv-contrib-python package. But since this problem is not present in just one release, but in ten, this generates a second hypothesis.

Hypothesis 2: it was done on purpose, but why?

Note: this is just my opinion, if anyone has the exact reason, please share it with us.

Version history and operation: from SIFT and SURF.

1- For SIFT (Tested):

sift = cv2.sift_create() # work in:
# 3.4.11, 4.4.0. ==> Sift became free since March 2020
sift = cv2.xfeatures2D.SIFT_create () # work in:
# 3.2.x, 3.3.x, 3.4.0, 3.4.1, 3.4.2, 3.4.10, 4.3.0, 4.4.0
sift = cv2.xfeatures2D.SIFT_create () # ==> Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create' (the versions where the problem is present)
# 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 4.0.x, 4.1.x, 4.2.x

2- For SURF (Supposed (Not test all)):

SURF = cv2.xfeatures2D.SURF_create () # work in :
# 3.2.x, 3.3.x, 3.4.0, 3.4.1, 3.4.2
SURF = cv2.xfeatures2D.SURF_create () # ==> Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create' (the versions where the problem is present)
# 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 3.4.10, 3.4.11, 4.0.x, 4.1.x, 4.2.x, 4.3.0, 4.4.0.

SOLUTION:

1- The easiest solution as mentioned in a lot of forums (if you are looking for a little bit instead of posting the same problem each time) is to downgrade the openCV version to version 3.4.2.17 (if you need SIFT and SURF work just with pip install), because the problems start from version 3.4.3.

2- If you need a particular version knowing that it is a problem with SIFT or SURF, you can correct it, by installing OpenCV with enable opencv-contrib and NONFREE algorithms from source. here is a tutorial to follow:Tutorial

For compilation OpenCV With enable opencv-contrib and NONFREE algorithms you need this:

cmake -D CMAKE_BUILD_TYPE = RELEASE \ -D CMAKE_INSTALL_PREFIX = /usr/local \ -D INSTALL_PYTHON_EXAMPLES = ON \ -D INSTALL_C_EXAMPLES = OFF \ -D OPENCV_ENABLE_NONFREE = ON \ -D OPENCV_EXTRA_MODULES_PATH=(Path_to_opencv-contrib)/opencv_contrib/modules \-D PYTHON_EXECUTABLE=~/.virtualenvs/(Python_environement)/bin/python \-D BUILD_EXAMPLES=ON ..

Tested with opencv 3.4.9 under python 3.6.9 (Works fine for SIFT and SURF)

All existing releases of opencv 3 and 4 are here Releases

All versions of openCV3 >= 3.4.11 include the free version of SIFT

All versions of openCV4 >= 4.4.0 include the free version of SIFT

【转载】关于Opencv里SIFT和SURF是有专利算法的说明相关推荐

  1. Opencv实现Sift、Surf、ORB特征提取与匹配

    在opencv3中,这三个算子都转移到一个名为xfeature2d的第三方库中,而在opencv2中这三个算子在nonfree库中. 关于在vs下配置opencv可参考我转载的另外一篇文章.注意版本号 ...

  2. SIFT、SURF等关键点特征提取算法代码

    文章目录 1.关键点特征提取算法 2.SIFT代码(python+opencv) 2.SURF代码(python+opencv) 3.SIFT和SURF的比较 1.关键点特征提取算法 特征提取是提取出 ...

  3. SLAM前端 ---------特征提取之ORB(ORB与SIFT与SURF)

    ORB 论文翻译: 一种特征匹配替代方法:对比SIFT或SURF 1.ORB特征简介  ORB是Oriented FAST and Rotated BRIEF(oFAST and rBRIEF)的简称 ...

  4. 在OpenCV里实现扑克牌识别2

    要对扑克牌的识别,前面只是对每一个牌做了标记,这样提供了一个识别的基础,也就是识别的知识库.要把新拍摄进来的牌进行识别,比如像下图: 在这里看到一下子拍摄到四张牌,目标是把这四张牌识别出来,那么需要怎 ...

  5. 图像特征检测描述(一):SIFT、SURF、ORB、HOG、LBP特征的原理概述及OpenCV代码实现

    图像处理开发需求.图像处理接私活挣零花钱,请加微信/QQ 2487872782 图像处理开发资料.图像处理技术交流请加QQ群,群号 271891601 什么叫特征检测?就是检测图像中目标的特征呗,所谓 ...

  6. OpenCV3如何使用SIFT和SURF Where did SIFT and SURF go in OpenCV 3?

    If you've had a chance to play around with OpenCV 3 (and do a lot of work with keypoint If you've ha ...

  7. Python+OpenCV:ORB: An efficient alternative to SIFT or SURF

    Python+OpenCV:ORB: An efficient alternative to SIFT or SURF 理论 As an OpenCV enthusiast, the most imp ...

  8. OpenCV 尺度不变特征检测:SIFT、SURF、BRISK、ORB

    这个学期在上数字图像处理这门课.这门课没有考试,只有大作业,要求使用labwindows和NI Vision进行开发.我选的题目是全景图像的合成(图像拼接),其中要使用到一些特征点检测和匹配的算法.本 ...

  9. Opencv Sift和Surf特征实现图像无缝拼接生成全景图像

    Sift和Surf算法实现两幅图像拼接的过程是一样的,主要分为4大部分: 1. 特征点提取和描述 2. 特征点配对,找到两幅图像中匹配点的位置 3. 通过配对点,生成变换矩阵,并对图像1应用变换矩阵生 ...

最新文章

  1. 菜鸡记录-王爽-汇编语言-实验十(编写子程序-显示字符串)
  2. 数据库设计和管理规范
  3. timestamp(6) oracle计算差值_Oracle 计算两个时间的差值
  4. 【小代码讲解】独热编码(One-Hot编码)
  5. 20180105随笔
  6. java中随机数彩票练习_基于javascript实现彩票随机数生成(简单版)
  7. python简单代码恶搞-一个可以套路别人的python小程序实例代码
  8. 一些经久不衰的linux 视频教程列表
  9. 采用Xamarin进行ffmpeg调用视频编解码的方法
  10. mysql 中电话号码_类型-电话号码和地址的mysql数据类型
  11. 【bat命令-在for循环中赋值给局部变量后再输出变量时提示“ECHO 处于关闭状态。”或者“ECHO 处于打开状态。”】
  12. Spring实战(使用数据)
  13. led灯光衰怎么解决_解决LED灯具光衰办法大全
  14. 协议栈skb _buff
  15. 三维数据可视化软件html5,基于 HTML5 的 WebGL 自定义 3D 摄像头监控模型 | 3D组态|图扑软件|数据可视化|blog...
  16. R语言dbplyr包实现R与SQL语句无缝衔接
  17. ASP一个小型搜索引擎的设计与实现
  18. MySql版本号查看命令
  19. VMware运行虚拟机卡慢等解决办法
  20. 极简的wrk安装和使用教程

热门文章

  1. android个别手机问题排查,【原创】高德地图在个别机型手机上运行崩溃的问题...
  2. Shiro 安全(权限)框架。
  3. DxO PureRAW 3 - RAW 格式照片自动降噪锐化光学校正
  4. linux mint安装中文字体
  5. 12864液晶原理分析1
  6. 高情商、低情商与人际关系
  7. 解决iPhone连接Mac反复断开重连
  8. BTC/ETH历史行情数据/期权/合约成交数据分析工具
  9. 改画册相关注意事项及ai常用操作
  10. 关于Linux通配符,Linux通配符(转)