OpenCV4入门117:Brisk特征提取与描述子匹配

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import cv2 as cv

box = cv.imread("../images/box.png");
box_in_sence = cv.imread("../images/box_in_scene.png");
cv.imshow("box", box)
cv.imshow("box_in_sence", box_in_sence)

# 创建BRISK特征检测器
brisk = cv.BRISK_create()
kp1, des1 = brisk.detectAndCompute(box,None)
kp2, des2 = brisk.detectAndCompute(box_in_sence,None)

# 暴力匹配
bf = cv.BFMatcher(cv.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1,des2)

# 绘制匹配
result = cv.drawMatches(box, kp1, box_in_sence, kp2, matches, None)
cv.imshow("orb-match", result)
cv.waitKey(0)
cv.destroyAllWindows()

BRISK(Binary robust invariant scalable keypoints)是一种基于尺度空间不变性类似ORB特征描述子的特征提取算法。BRISK主要步骤可以分为如下两步:

  • 构建尺度空间金字塔实现关键点定位
  • 根据关键点生成描述子