I have a set of 2D points corresponding to the location of pixels in an image. I would like to compute SIFT keypoints and descriptors only for these points but I don’t find the appropriate methods in the online documentation.
How should I proceed?
I have a set of 2D points corresponding to the location of pixels in an image. I would like to compute SIFT keypoints and descriptors only for these points but I don’t find the appropriate methods in the online documentation.
How should I proceed?
there is a (static) convert() function here, you probably missed it:
https://docs.opencv.org/4.x/d2/d29/classcv_1_1KeyPoint.html#ab6a67a0ab17d65a1b28502eba424bfde
however, please tell, WHY you want to do this ?
arbitrary points rarely make good keypoints, and you dont have information to fill angle, octave, etc
(also, detecting SIFT kps already does 50% of the job to get descriptors, so detectAndCompute() should be used here…)
In my image I have local neighborhoods of interest (e.g., patches of 10x10) in which I would like to compute all possible descriptors and compare them with each other and then compare them between patches. In the detectAndCompute() function I don’t have control of where the keypoints are detected.
again, to achieve what ? please explain
at least, make a short exp., and try to detect kps in your patches – if you cant find any, you already have a hint, that this is a bad idea (10x10 might also be too small to get a single kp/desc, iirc, there’s a minimal patch size, but idk for SIFT)
also be aware, that compute() may reject ‘bad’ kp’s, so you may end up with less or even zero descriptors here !
a keypoint isn’t just a position. it also contains other info that is quite relevant to the descriptor computation, such as the octave
/scale and the angle. the descriptor computation does not “fill that in”.
im = cv.imread(cv.samples.findFile("lena.jpg"))
sift = cv.SIFT.create()
kps = cv.KeyPoint.convert([ (128,128) ])
(kps, desc) = sift.compute(im, kps)