20 lines
642 B
Python
20 lines
642 B
Python
import os
|
|
import sys
|
|
import cv2
|
|
import numpy as np
|
|
|
|
img1 = cv2.imread('D:\MicroSAR\C-SAR\Ortho\Ortho\Temporary\dem_rcs.jpg', 0)
|
|
img2 = cv2.imread('D:\MicroSAR\C-SAR\Ortho\Ortho\Temporary\sar_rcs.jpg', 0)
|
|
def cv_show(name,img):
|
|
cv2.imshow(name, img)
|
|
cv2.waitKey(0)
|
|
cv2.destroyAllWindows()
|
|
sift = cv2.xfeatures2d.SIFT_create()
|
|
kp1, des1 = sift.detectAndCompute(img1, None)
|
|
kp2, des2 = sift.detectAndCompute(img2, None)
|
|
bf = cv2.BFMatcher(crossCheck=True)
|
|
matches = bf.match(des1, des2)
|
|
matches = sorted(matches, key=lambda x: x.distance)
|
|
img3 = cv2.drawMatches(img1, kp1, img2, kp2, matches[:10], None,flags=2)
|
|
cv_show('img3',img3)
|