在用SIFT时一直报以下错误,带解决中。。。。
代码:
# -*- coding: utf-8 -*- # !/usr/bin/env python # @Time : 2018/10/31 16:26 # @Author : xhh # @Desc : SITF检测特征点 # @File : opencv_SITF.py # @Software: PyCharm import numpy as np import cv2 # 读取图片 input_file = '../cat1/cat.1.jpg' img = cv2.imread(input_file) img_gray = cv2.cvtColor(img, cv2.IMREAD_GRAYSCALE) # 提取特征点 sift = cv2.xfeatures2d.SURF_create() keypoints = sift.detect(img_gray, None) img_sift = np.copy(img_gray) cv2.drawKeypoints(img, keypoints, img_sift, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) cv2.imshow('input_image',img_gray) cv2.imshow('img_sift', img_sift) cv2.waitKey(0)
报以下错误:
D:\python36\python.exe E:/pycharm/image_opencv/opencv_test/opencv_SITF.py
Traceback (most recent call last):
File "E:/pycharm/image_opencv/opencv_test/opencv_SITF.py", line 16, in <module>
sift = cv2.xfeatures2d.SURF_create()
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\surf.cpp:1016: 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::SURF::create'