|
4 | 4 | # Load the image
|
5 | 5 | path=input('Enter the path of the image')
|
6 | 6 | image = cv2.imread(path)
|
| 7 | +path2=input('Enter the path for testing image') |
| 8 | +test_image=cv2.imread(path2) |
| 9 | + |
7 | 10 | #Resizing the image
|
8 | 11 | image=cv2.resize(image,(600,600))
|
| 12 | +test_image=cv2.resize(test_image,(600,600)) |
| 13 | + |
9 | 14 | # Convert the image to gray scale
|
10 | 15 | gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
11 | | - |
12 | | -# Create test image by adding Scale Invariance and Rotational Invariance |
13 | | -test_image = cv2.pyrDown(image) |
14 | | -test_image = cv2.pyrDown(test_image) |
15 | | -num_rows, num_cols = test_image.shape[:2] |
16 | | -rotation_matrix = cv2.getRotationMatrix2D((num_cols/2, num_rows/2), 30, 1) |
17 | | -test_image = cv2.warpAffine(test_image, rotation_matrix, (num_cols, num_rows)) |
18 | 16 | test_gray = cv2.cvtColor(test_image, cv2.COLOR_RGB2GRAY)
|
19 | 17 |
|
20 | 18 | #Display the given and test image
|
|
45 | 43 | # The matches with shorter distance are the ones we want.
|
46 | 44 | matches = sorted(matches, key = lambda x : x.distance)
|
47 | 45 |
|
48 | | -result = cv2.drawMatches(image, train_keypoints, test_gray, test_keypoints, matches, test_gray, flags = 2) |
| 46 | +result = cv2.drawMatches(image, train_keypoints, test_image, test_keypoints, matches, test_gray, flags = 2) |
49 | 47 |
|
50 | 48 | # Display the best matching points
|
51 | 49 | cv2.imshow('result',result)
|
|
0 commit comments