Guest User

Untitled

a guest
Nov 13th, 2021
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import cv2
  2.  
  3. #TM_SQDIFF_NORMED
  4. method = cv2.TM_SQDIFF_NORMED
  5. small_image = cv2.imread('d2.png', 0) # что ищу
  6. large_image = cv2.imread('d1.png', 0) # где ищу
  7. result = cv2.matchTemplate(small_image, large_image, method)
  8. mn,_,mnLoc,_ = cv2.minMaxLoc(result)
  9. MPx,MPy = mnLoc
  10. trows,tcols = small_image.shape[:2]
  11. cv2.rectangle(large_image, (MPx,MPy),(MPx+tcols,MPy+trows),(0,0,255),10)
  12. res = cv2.resize(large_image, dsize=(2500,2500))
  13. cv2.namedWindow("Resized", cv2.WINDOW_NORMAL)
  14. cv2.imshow("Resized", res)
  15. cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment