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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| import cv2 from matplotlib import pyplot as plt
img = cv2.imread('images/fly.png', 0)
sift = cv2.xfeatures2d.SIFT_create() print('sift: ', sift) surf = cv2.xfeatures2d.SURF_create(400) print('surf: ', surf, ' \ndefaultParameter\thessianThreshold: ', surf.getHessianThreshold(), ' upright: ', surf.getUpright(), ' extended: ', surf.getExtended(), ' descriptors: ',surf.descriptorSize())
kp, des = surf.detectAndCompute(img, None)
img2 = cv2.drawKeypoints(img, kp, None, (255, 0, 0), 4) plt.imshow(img2), plt.xticks([]), plt.yticks([]), plt.title('more keypoints'), plt.show()
print('keypoints: ', len(kp))
surf.setHessianThreshold(50000) print(' parameters\thessianThreshold: ', surf.getHessianThreshold(), ' upright: ', surf.getUpright(), ' extended: ', surf.getExtended(), ' descriptors: ',surf.descriptorSize())
kp, des = surf.detectAndCompute(img, None)
print('keypoints: ', len(kp))
img2 = cv2.drawKeypoints(img, kp, None, (255, 0, 0), 4)
plt.imshow(img2), plt.xticks([]), plt.yticks([]), plt.title('less than 50 keypoints'), plt.show()
surf.setUpright(True) print(' parameters\thessianThreshold: ', surf.getHessianThreshold(), ' upright: ', surf.getUpright(), ' extended: ', surf.getExtended(), ' descriptors: ',surf.descriptorSize())
kp = surf.detect(img, None) print('keypoints: ', len(kp)) img2 = cv2.drawKeypoints(img, kp, None, (255, 0, 0), 4)
plt.imshow(img2), plt.xticks([]), plt.yticks([]), plt.title('U-SURF'), plt.show()
surf.setExtended(True) print(' parameters\thessianThreshold: ', surf.getHessianThreshold(), ' upright: ', surf.getUpright(), ' extended: ', surf.getExtended(), ' descriptors: ',surf.descriptorSize())
kp, des = surf.detectAndCompute(img, None) print('keypoints: ',len(kp)) img2 = cv2.drawKeypoints(img, kp, None, (255, 0, 0), 4)
plt.imshow(img2), plt.xticks([]), plt.yticks([]), plt.title('128D res'), plt.show()
|