MCPcopy Create free account
hub / github.com/JimmyHHua/opencv_tutorials / template_demo

Function template_demo

python/code_039/opencv_039.py:5–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4
5def template_demo():
6 src = cv.imread("./test.png")
7 tpl = cv.imread("./test01.png")
8 cv.imshow("input", src)
9 cv.imshow("tpl", tpl)
10 th, tw = tpl.shape[:2]
11 result = cv.matchTemplate(src, tpl, cv.TM_CCORR_NORMED)
12 cv.imshow("result", result)
13 cv.imwrite("D:/039_003.png", np.uint8(result*255))
14 t = 0.98
15 loc = np.where(result > t)
16
17 for pt in zip(*loc[::-1]):
18 cv.rectangle(src, pt, (pt[0] + tw, pt[1] + th), (255, 0, 0), 1, 8, 0)
19 cv.imshow("llk-demo", src)
20 cv.imwrite("D:/039_004.png", src)
21
22
23template_demo()

Callers 1

opencv_039.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected