从 OpenCV 中 ORB 生成的关键点中提取像素值 Python

Extracting pixel values from keypoints generated by ORB in OpenCV Python

我使用 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=0)
kp = orb.detect(r_g_img,None)
kp,des = orb.compute(r_g_img,kp) 

现在,当我查看 kpdes 的存储值时,我看到了:

>>> 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) 

我什至不完全确定 des 指的是什么,但我所追求的是关键点的像素位置 (x,y)。当我在调试器手表 window 中拉起 kp 时(见下图),我看到我之后列出的像素值是 pt。我可以使用什么代码来获取这些值?

来自doc, I understand your des variable contains the descriptors of the keypoints. These descriptors are inspired from the BRIEF algorithm (ORB paper).

至于获取 KeyPoint 的属性,就像获取任何 Python 对象一样:

for keypoint in kp:
    print(keypoint.angle)
    print(keypoint.class_id)
    # ...