|
- import cv2
-
- if __name__ == "__main__":
- # 先把图片灰度处理。
- img = cv2.imread('image/AI6.jpg')
- img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
-
- template = cv2.imread('image/AI.jpg')
- template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)
- h, w = template.shape[:2]
-
- # 匹配
- result = cv2.matchTemplate(img_gray, template_gray, cv2.TM_CCOEFF_NORMED)
-
- min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
- print(min_val, max_val, min_loc, max_loc)
-
-
|