I have a small image patch (16 x 16) for which I want to get ORB descriptor. Following this answer for SIFT descriptor, I have analogously created a list of keypoints containing one keypoint in the centre of the patch, with diameter size of the patch.
orb = cv2.ORB_create()
keypoint = cv2.KeyPoint((patch_size - 1) / 2, (patch_size - 1) / 2, _size=patch_size)
keypoints = [keypoint]
keypoints_returned, desc = orb.compute(patch, keypoints)
print(desc)
print(keypoints_returned)
However, this doesn't work, I get None and [] as an output of this code snippet. How can I compute ORB descriptor for a single patch (and a keypoint in the centre as described)?
The
orb.compute()function doesn't expect a Python list of keypoints; rather, it expects a tuple of keypoints.You need to pack your singular keypoint into a tuple like this:
You have to add the comma after 'keypoint' inside the tuple to make it a tuple with only one item; otherwise, Python ignores your brackets and will evaluate it as just 'keypoint'.