I'm trying to manually set 22 keypoints on an image so i can extract their features. For this task, i create an array of keypoints with the coordinates i manually selected and pass the vector as a parameter in orb.compute and them draw the keypoints respectively.
My problem is that i set 22 points on different parts of an image, but it won't show more than 14 keypoints in the image.
Here's an example of what are the locations that i am expecting to draw 22 keypoints on:
What actually happens:
Points were changed a bit from one image to another, but it the coordinates in the code are what matters, the images are illustrative example of what im trying to do and what im getting.
Here's a reproducible version of my code:
import pandas as pd
import skimage
import cv2
imageList = skimage.io.imread("./a.png")
orb = cv2.ORB_create()
key_points = [cv2.KeyPoint(65, 9, 10), <---- missing
cv2.KeyPoint(66, 12, 10),
cv2.KeyPoint(62, 21, 10),
cv2.KeyPoint(60, 13, 10),
cv2.KeyPoint(67, 12, 10),
cv2.KeyPoint(107, 6, 10), <---- missing
cv2.KeyPoint(170, 10, 10),<---- missing
cv2.KeyPoint(25, 60, 10),
cv2.KeyPoint(60, 40, 10),
cv2.KeyPoint(110, 35, 10),
cv2.KeyPoint(170, 35, 10),
cv2.KeyPoint(190, 60, 1),
cv2.KeyPoint(30, 95, 10), <---- missing
cv2.KeyPoint(60, 80, 10),
cv2.KeyPoint(100, 105, 10),
cv2.KeyPoint(120, 105, 10),
cv2.KeyPoint(160, 180, 10),
cv2.KeyPoint(185, 95, 10),
cv2.KeyPoint(25, 160, 10), <---- missing
cv2.KeyPoint(55, 160, 10),
cv2.KeyPoint(155, 160, 10),
cv2.KeyPoint(185, 160, 10), <---- missing
cv2.KeyPoint(65, 200, 10), <----- missing
cv2.KeyPoint(83, 186, 10),
cv2.KeyPoint(128, 186, 10),
cv2.KeyPoint(157, 197, 10) <---- missing]
kp, des = orb.compute(imageList, key_points)
kparray = cv2.drawKeypoints(imageList, kp, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS);
cv2.imshow("Image", kparray)
cv2.waitKey(0)
So, for some reason i set all these 22 points that can be seen above, but when i run my code, it shows only 14, some are missing I even tried printing the kp parameter in cv2.drawKeyPoints to make sure, even so:
[<KeyPoint 000002DF9DE83B40>,
<KeyPoint 000002DF9DE83F90>,
<KeyPoint 000002DF9DE83FC0>,
<KeyPoint 000002DF9DE83F30>,
<KeyPoint 000002DF9DE83DB0>,
<KeyPoint 000002DFAB657030>,
<KeyPoint 000002DFAB657B40>,
<KeyPoint 000002DFAC1FED20>,
<KeyPoint 000002DFAC1FE480>,
<KeyPoint 000002DFAC1FEC90>,
<KeyPoint 000002DFAC1FEDE0>,
<KeyPoint 000002DFAC20D030>,
<KeyPoint 000002DFAC20D060>,
<KeyPoint 000002DFAC20D0C0>]
First of all, I had to drastically reduce the provided code in order to understand the issue. It may discourage people to help.
Additionally, you wrote :
when I run my code, it shows only 14, some are missing I even tried printing the kp parameter in cv2.drawKeyPoints to make sure, even so:
So, as I understand it, it's not an issue of what OpenCV shows, it's an issue about keypoints ORB is able to compute.
So let me rephrase your question:
In OpenCV why is ORB computation removing some keypoints. Here is minimal code to reproduce:
import skimage
import cv2
imageList = skimage.io.imread("./a.png")
orb = cv2.ORB_create()
key_points = [cv2.KeyPoint(65, 9, 10), cv2.KeyPoint(66, 40, 10)]
kp, des = orb.compute(imageList, key_points)
print(len(kp))
prints "1"
Therefore the answer may be found in some other StackOverflow questions
Changing the threshold, for instance, changed the results for me.
...
orb = cv2.ORB_create(edgeThreshold=1)
...
print(len(kp))
returns "2"
Unfortunately, I'm no ORB specialist, so you may have better results if rephrasing your question in order to drag ORB specialists attention instead of mine.
Good luck.