-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_feature_descriptors.py
59 lines (39 loc) · 1.07 KB
/
get_feature_descriptors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import cv2
def orb_return_features_2(image):
'''
Takes some image object
and returns the list of ORB feature descriptors
inputs:
image: some image object..
'''
#generate the image
img = image
# Initiate ORB detector
orb = cv2.ORB_create()
# find the keypoints and feature descriptors with ORB
kp = orb.detect(img,None)
kp, des = orb.compute(img, kp)
return (kp,des)
def sift_return_features(image):
'''
Takes some image object
and returns the list of sift feature descriptors
inputs:
image: some image object..
'''
#generate the image
img = image
# Initiate SIFT detector
sift = cv2.SIFT_create()
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# find the keypoints and features and return them....
kp = sift.detect(gray, None)
des = sift.compute(gray, kp)[1]
return (kp,des)
if __name__ == "__main__":
#Testing to see if the algorithms work....
img1 = cv2.imread('training_fake/easy_100_1111.jpg')
print(
str(sift_return_features(img1)[0]) + '\n'*10 + str(sift_return_features(img1)[1])
)
print(len(sift_return_features(img1)[1]))