728x90
๋ฐ์ํ
def isExistImage(a, b, c=0.65):
print("์ด๋ฏธ์ง ์กด์ฌ ์ฌ๋ถ")
img_rgb = cv2.imread(a)
template = cv2.imread(b)
h, w = template.shape[:-1]
res = cv2.matchTemplate(img_rgb, template, cv2.TM_CCOEFF_NORMED)
threshold = c
loc = np.where(res >= threshold)
return len( loc[0] ) != 0
print(isExistImage("screen.png", "target.png")) # True or False
def getMatchPosition(a, b, c=0.65):
print("์ด๋ฏธ์ง ์์น ๊ฐ์ ธ์ค๊ธฐ")
img_rgb = cv2.imread(a)
template = cv2.imread(b)
h, w = template.shape[:-1]
res = cv2.matchTemplate(img_rgb, template, cv2.TM_CCOEFF_NORMED)
threshold = c
loc = np.where(res >= threshold)
if len( loc[0] ) == 0:
return False
x, y = loc[1][0], loc[0][0]
return (x, y)
print(getMatchPosition("screen.png", "target.png")) # (x, y) or False
์ฐธ๊ณ :
https://iagreebut.tistory.com/77
[OpenCV] ์ด๋ฏธ์ง์์ ํน์ ์ด๋ฏธ์ง ์ฐพ์๋ด๊ธฐ
๋ต์ง์์ ํด๋น ๋ต์ ์์ญ๋ง์ ์ถ์ถํ๊ธฐ ์ํด์๋ ๋ค์๊ณผ ๊ฐ์ "๋ต"์ด๋ผ๋ ์ด๋ฏธ์ง๋ฅผ ๋ต์ง ํ์ด์ง๋ด์์ ์ฐพ์๋ธ ํ ํด๋น ์ด๋ฏธ์ง๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ทธ ์๋๋ฅผ ์๋ฅด๋ฉด ๋๋ค ๊ทธ๋์ ์ผ๋จ ์ด๋ฒ ๊ฒ์๊ธ์์
iagreebut.tistory.com
728x90
๋ฐ์ํ
'๐จ๐ผโ๐ป๊ฐ๋ฐ > OpenCV' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
OpenCV - pyinstaller ๋น๋ ํ cv2๊ฐ improt ์๋๋ ์ค๋ฅ ํด๊ฒฐ (0) | 2022.06.27 |
---|---|
OpenCV - ์ปค์คํ Cascade ๋ง๋ค๊ธฐ(CASCADE TRAINER GUI) ๋ฐ ๋ฌผ์ฒด ํ์ง (0) | 2022.05.19 |
OpenCV - ์บก์ฑ ๋ฌธ์ ๊ฒ์ถํ๊ธฐ (0) | 2022.05.18 |
OpenCV - ํ์ด์ฌ ์น์บ ๋, ์ผ๊ตด ์ธ์ (0) | 2022.02.02 |
OpenCV - ํ์ด์ฌ ์น์บ ์ผ๊ตด ์ธ์ (0) | 2022.02.02 |