import cv2
import numpy as np
img = cv2.imread(“yinhua2.png”,)
template = cv2.imread(“yinhua.png”)
result = cv2.matchTemplate(img,template,cv2.TM_SQDIFF_NORMED)
threshold = 0.01
loc = np.where(result <= threshold)
print(*loc[::-1])
for pt in zip(*loc[::-1]):
right_bottom = (pt[0] + w, pt[1] + h)
cv2.rectangle(img, pt, right_bottom,(0, 0,255),2)
cv2.imshow(“img”,img)
cv2.imshow(“template”,template)
cv2.waitKey(0)
cv2.destroyAllWindows()
实现匹配多个印花
最新推荐文章于 2021-06-30 15:54:52 发布