-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_FAST.py
42 lines (31 loc) · 1.13 KB
/
04_FAST.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
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('b.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Initiate FAST object with default values
fast = cv2.FastFeatureDetector_create(40)
# find and draw the keypoints
kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, kp, color=(255,0,0), outImage = None)
cv2.imshow('Fast true', img2)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite('fast_true.png',img2)
# Print all default params
print("Threshold: ", fast.getThreshold)
print("nonmaxSuppression: ", fast.getNonmaxSuppression())
print("neighborhood: ", fast.getType())
print("Total Keypoints with nonmaxSuppression: ", len(kp))
# Nonmax Suppression : It detects the object only once with the highest probability and removes the other ones.
cv2.imshow('Fast true', img2)
cv2.waitKey(0)
cv2.destroyAllWindows()
# Disable nonmaxSuppression
fast.setNonmaxSuppression(False)
kp = fast.detect(img,None)
print("Total Keypoints without nonmaxSuppression: ", len(kp))
img3 = cv2.drawKeypoints(img, kp, color=(255,0,0), outImage = None)
cv2.imshow('fast_false', img3)
cv2.waitKey(0)
cv2.destroyAllWindows()