-
Notifications
You must be signed in to change notification settings - Fork 0
/
briefRotTest.py
45 lines (27 loc) · 978 Bytes
/
briefRotTest.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
import numpy as np
import cv2
from matchPics import matchPics
from opts import get_opts
import scipy
import matplotlib.pyplot as plt
# Q2.1.6
def rotTest(opts):
# Read the image and convert to grayscale, if necessary
img= cv2.imread(('../data/cv_cover.jpg'))
matchlen_arr=[]
for i in range(36):
# Rotate Image
img_rot=scipy.ndimage.rotate(img, i*10)
# Compute features, descriptors and Match features
matches, locs1, locs2 = matchPics(img, img_rot, opts)
# Update histogram
matchlen_arr.append(len(matches))
#Display histogram
plt.bar(np.arange(36), matchlen_arr)
plt.xlabel("Rotation angles divided by ten")
plt.ylabel("Length of matches")
plt.title("Number of Matches vs rotation angles")
plt.show
if __name__ == "__main__":
opts = get_opts()
rotTest(opts)