컴퓨터 비전

숨은그림 찾기

도그사운드 2023. 9. 26. 17:15

숨은 그림(너무 뻔하지만)

위에서 그림을 찾는다

찾을 그림은 바로 

요놈

import cv2
import matplotlib.pyplot as plt

img=cv2.imread('./images/img.jpg')

plt.figure(figsize=(16, 12))
plt.imshow(img)

 

이제 찾을 이미지를 불러들인다.

look01=cv2.imread('./images/look01.png')

plt.imshow(look01)

 

찾는다

result=cv2.matchTemplate(img, look01, cv2.TM_CCOEFF)

min_val, max_val, min_loc, max_loc=cv2.minMaxLoc(result)

 

이제 바운딩 박스를 그릴 준비를 한다.

top_left=max_loc

bottom_right=(top_left[0] + 50, top_left[1]+50)

cv2.rectangle(img, top_left, bottom_right, (0,0,255), 5)

 

결과는 어떻게 됐을까?

plt.imshow(img)

파란색 바운딩 박스가 찾은 이미지

 

참고로 OpenCV에서 가져온 패러미터 

'컴퓨터 비전' 카테고리의 다른 글

Image Segmentation 코딩  (1) 2023.10.18
Vehicle Counting  (0) 2023.10.15
YOLO 트레이닝, roboflow  (0) 2023.10.09
YOLOv8 실행  (1) 2023.10.09
Jaccard index  (0) 2023.10.08