在OpenCV Python中从ORB生成的关键点提取像素值
我使用OpenCV查找图像中的关键点,这些关键点以向量形式存储在名为在OpenCV Python中从ORB生成的关键点提取像素值,python,opencv,Python,Opencv,我使用OpenCV查找图像中的关键点,这些关键点以向量形式存储在名为kp的变量中。用于此操作的代码: #Read image and convert to greyscale img = cv2.imread(DIR + i,0) #Resize image to 100 x 100 r_g_img = cv2.resize(img, (100,100)) #Feature extraction orb = cv2.ORB_create(scaleFactor=2, edgeThreshold=
kp
的变量中。用于此操作的代码:
#Read image and convert to greyscale
img = cv2.imread(DIR + i,0)
#Resize image to 100 x 100
r_g_img = cv2.resize(img, (100,100))
#Feature extraction
orb = cv2.ORB_create(scaleFactor=2, edgeThreshold=0)
kp = orb.detect(r_g_img,None)
kp,des = orb.compute(r_g_img,kp)
现在,当我查看kp
和des
的存储值时,我看到:
>>> kp
[<KeyPoint 05DA9318>, <KeyPoint 02F7A0C0>, <KeyPoint 02F7A098>, <KeyPoint 02F7ABB0>,...
>>> des
array([[ 89, 4, 163, ..., 14, 116, 98],
[ 17, 93, 81, ..., 184, 112, 173],
[184, 85, 50, ..., 63, 52, 67],
...,
[ 3, 216, 229, ..., 29, 88, 220],
[163, 29, 71, ..., 124, 124, 86],
[102, 92, 166, ..., 126, 244, 124]], dtype=uint8)
>>kp
[, ,...
>>>des
数组([[89,4163,…,14116,98],
[ 17, 93, 81, ..., 184, 112, 173],
[184, 85, 50, ..., 63, 52, 67],
...,
[ 3, 216, 229, ..., 29, 88, 220],
[163, 29, 71, ..., 124, 124, 86],
[102,92,166,…,126,244,124]],dtype=uint8)
我甚至不能完全确定des所指的是什么,但我所追求的是关键点的像素位置(x,y)。当我在调试器监视窗口(见下图)中拉起kp时,我看到我所追求的像素值被列为pt。我可以用什么代码来获取这些值
从中,我了解到您的des
变量包含关键点的描述符。这些描述符的灵感来自简短算法()
至于获取关键点的属性,只需像对待任何Python对象一样:
for keypoint in kp:
print(keypoint.angle)
print(keypoint.class_id)
# ...
谢谢。Python新手,所以很高兴知道。我也很想知道描述符到底是什么。不客气,如果您想了解更多关于ORB逻辑的信息,我已经编辑了我的答案,并提供了作者论文的链接(我搜索了opencv文档页面中的参考资料)。