I am trying to use OpenCV(2.4.6.0) to retrieve descriptors from key points that I have provided.
So far, I have not been successful...
l, des = surf.detectAndCompute(self.gray,None,useProvidedKeypoints = True)
where l
is an array of feature points. I am not sure where to input the key points I already have...
Would anyone know how I can go about doing this with either SIFT or SURF?
Thank you for your help!
This looks like a problem with the Python bindings for detectAndCompute()
, since the C++ equivalent does allow inputting of keypoints. Fortunately, there is a workaround. If you already have detected keypoints and stored them in l
, then you can create a DescriptorExtractor
object and compute descriptors for the provided keypoints.
An example generating FAST keypoints and then computing SURF descriptors follows:
im = cv2.imread(path_to_image)
fast = cv2.FeatureDetector_create('FAST')
l = fast.detect(im)
surf = cv2.DescriptorExtractor_create('SURF')
l, des = surf.compute(im, l)
This works equally well for SIFT features. Just pass 'SIFT'
as an argument to cv2.DescriptorExtractor_create()
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.