This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#%% Read and resize images | |
import numpy as np | |
import cv2 as cv | |
# Read images | |
train_img = cv.imread('train.png') | |
query_img = cv.imread('query.png') | |
# Resize images | |
train_img = cv.resize(train_img, dsize=(600, 950)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Select good matched keypoints | |
ref_matched_kpts = np.float32([kp1[m[0].queryIdx].pt for m in good_matches]) | |
sensed_matched_kpts = np.float32([kp2[m[0].trainIdx].pt for m in good_matches]) | |
# Compute homography | |
H, status = cv.findHomography(sensed_matched_kpts, ref_matched_kpts, cv.RANSAC,5.0) | |
# Warp image | |
warped_image = cv.warpPerspective(img2, H, (img2.shape[1], img2.shape[0])) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 as cv | |
import matplotlib.pyplot as plt | |
img1 = cv.imread('image1.jpg', cv.IMREAD_GRAYSCALE) # referenceImage | |
img2 = cv.imread('image2.jpg', cv.IMREAD_GRAYSCALE) # sensedImage | |
# Initiate AKAZE detector | |
akaze = cv.AKAZE_create() | |
# Find the keypoints and descriptors with SIFT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 as cv | |
img = cv.imread('image.jpg') | |
gray= cv.cvtColor(img, cv.COLOR_BGR2GRAY) | |
akaze = cv.AKAZE_create() | |
kp, descriptor = akaze.detectAndCompute(gray, None) | |
img=cv.drawKeypoints(gray, kp, img) |