官方文档:https://docs.opencv.org/4.10.0/d1/d89/tutorial_py_orb.html
SIFT/SURF/ORB对比
ORB代码
python
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
gray = cv.imread('12.png', cv.IMREAD_GRAYSCALE)
# https://docs.opencv.org/4.10.0/d1/d89/tutorial_py_orb.html
# Initiate ORB detector
orb = cv.ORB.create()
# find the keypoints with ORB
kp = orb.detect(gray, None)
# compute the descriptors with ORB
kp, des = orb.compute(gray, kp)
print(type(kp))
print(des.shape)
print(len(kp))
print(len(des))
print(des[0])
# draw only keypoints location,not size and orientation
img2 = cv.drawKeypoints(gray, kp, None, flags=cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS)
cv.imshow('orb', img2)
cv.waitKey(0)
cv.destroyAllWindows()
python
<class 'tuple'>
(79, 32)
79
79
[ 96 32 25 96 4 77 65 0 104 32 32 8 151 19 0 16 128 148
72 8 8 96 208 0 193 136 1 48 64 0 71 34]