Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- img_rgb = cv2.imread('big_img.png') # https://prnt.sc/pw2ltm
- template = cv2.imread('small_img.png') # https://prnt.sc/pw2m9t
- #template = cv2.imread('img2.png') # картинка которой нет в img_rbg
- w, h = template.shape[:-1]
- res = cv2.matchTemplate(img_rgb, template, cv2.TM_CCOEFF_NORMED)
- # проверка нахождения
- if str(res[0]) != '[1. 1. 1. ... 1. 1. 1.]':
- threshold = .8
- loc = np.where(res >= threshold)
- for pt in zip(*loc[::-1]):
- x = int(pt[0])
- y = int(pt[1])
- print(x, y) # координаты совпадения
- else:
- print('совпадений не найдено')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement