Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- #TM_SQDIFF_NORMED
- method = cv2.TM_SQDIFF_NORMED
- small_image = cv2.imread('d2.png', 0) # что ищу
- large_image = cv2.imread('d1.png', 0) # где ищу
- result = cv2.matchTemplate(small_image, large_image, method)
- mn,_,mnLoc,_ = cv2.minMaxLoc(result)
- MPx,MPy = mnLoc
- trows,tcols = small_image.shape[:2]
- cv2.rectangle(large_image, (MPx,MPy),(MPx+tcols,MPy+trows),(0,0,255),10)
- res = cv2.resize(large_image, dsize=(2500,2500))
- cv2.namedWindow("Resized", cv2.WINDOW_NORMAL)
- cv2.imshow("Resized", res)
- cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment