(解决!)cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.

  在运行一个利用opencv库中的SIFT算法的图像拼接程序时,出现了如下错误

C:\Users\syzim\anaconda3\envs\ethan\python.exe C:/Users/syzim/Desktop/代码/ch3/stitcher/ImageStiching.py
Traceback (most recent call last):
  File "C:/Users/syzim/Desktop/代码/ch3/stitcher/ImageStiching.py", line 10, in 
    (result, vis) = stitcher.stitch([imageA, imageB], showMatches=True)
  File "C:\Users\syzim\Desktop\代码\ch3\stitcher\Stitcher.py", line 11, in stitch
    (kpsA, featuresA) = self.detectAndDescribe(imageA)
  File "C:\Users\syzim\Desktop\代码\ch3\stitcher\Stitcher.py", line 44, in detectAndDescribe
    descriptor = cv2.xfeatures2d.SIFT_create()
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cpp:1210: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'cv::xfeatures2d::SIFT::create'

  在查阅了一番资料后解决问题,只需opencv版本退到3.4.2即可解决
  PS:可能会出现python某些版本不支持opencv某些版本的情况,本人python版本是3.6,已经亲测有效的opencv版本是:3.4.2.173.4.2.163.4.1.153.4.0.143.4.0.12
  我是用的anaconda创建的虚拟环境
  卸载原来的opencv

pip uninstall opencv-python
pip uninstall opencv-contrib-python

  重装opencv

pip install opencv-python==3.4.2.16
pip install opencv-contrib-python==3.4.2.16

  然后运行程序,成功!顺便贴一张结果图


个人网站

你可能感兴趣的:(OpenCv)