MCPcopy Create free account
hub / github.com/PyImageSearch/imutils / RootSIFT

Class RootSIFT

imutils/feature/rootsift.py:7–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5from ..convenience import is_cv2
6
7class RootSIFT:
8 def __init__(self):
9 # initialize the SIFT feature extractor for OpenCV 2.4
10 if is_cv2():
11 self.extractor = cv2.DescriptorExtractor_create("SIFT")
12
13 # otherwise initialize the SIFT feature extractor for OpenCV 3+
14 else:
15 self.extractor = cv2.xfeatures2d.SIFT_create()
16
17 def compute(self, image, kps, eps=1e-7):
18 # compute SIFT descriptors
19 (kps, descs) = self.extractor.compute(image, kps)
20
21 # if there are no keypoints or descriptors, return an empty tuple
22 if len(kps) == 0:
23 return ([], None)
24
25 # apply the Hellinger kernel by first L1-normalizing and taking the
26 # square-root
27 descs /= (descs.sum(axis=1, keepdims=True) + eps)
28 descs = np.sqrt(descs)
29
30 # return a tuple of the keypoints and descriptors
31 return (kps, descs)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…