OpenCV implements SIFT→SURF algorithm key point detection implementation

Table of contents

1. SIFT algorithm principle

1.1, basic process

1.1.1 Scale space extreme value detection

1.1.2 Key point positioning

1.1.3 Determining the direction of key points

1.1.4 Description of key points

1.1.5 Summary

1.2 SURF principle

2 code implementation

3 Result display

4. You will definitely encounter errors.

cv2.error: OpenCV(3.4.8) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cp


1. SIFT algorithm principle

1.1, basic process

1.1.1 Scale space extreme value detection

1.1.2 Key point positioning

1.1.3 Determining the direction of key points

1.1.4 Description of key points

1.1.5 Summary

1.2 SURF principle

2 code implementation

import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
from  pylab import mpl

mpl.rcParams['font.sans-serif']  = ['SimHei']

#读取图像
img = cv.imread('aa.jpg')
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)

#2  sift关键点检测
#2.1  实例化sift对象
sift = cv.xfeatures2d.SIFT_create()

#2.2 关键点检测  :  kp关键点信息包括  方向、尺度、位置信息,des是关键点的描述符
kp , des = sift.detectAndCompute(gray , None)

#2.3  在图像上绘制关键点的检测结果
cv.drawKeypoints(img , kp , img , flags=cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

#图像的显示
plt.figure(figsize=(5,4),dpi=100)
plt.imshow(img[:,:,:-1]),plt.title("sift  关键点检测")
plt.xticks([]),plt.yticks([])
plt.show()

3 Result display

4. You will definitely encounter errors.

cv2.error: OpenCV(3.4.8) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cp

Solution (click):

Solution address

Guess you like

Origin blog.csdn.net/qq_53545309/article/details/133306998