1 | initial version |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend. image of 1.jpeg. And template too: And output:
2 | No.2 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend.
image of 1.jpeg.
1.jpeg:
image description And template too: And output:
3 | No.3 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend. image of 1.jpeg:
image description
And template too:
And output:
4 | No.4 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend.
image of 1.jpeg:happend:
image of 1.jpeg: And template too: And output:
5 | No.5 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend:
I also removed threshold too. Here is code: import cv2 import numpy as np
img = cv2.imread("simpsons.jpg") gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) template = cv2.imread("barts_face.jpg", 0) w, h = template.shape[::-1]
result = cv2.matchTemplate(gray_img, template, cv2.TM_CCOEFF_NORMED) loc = np.where(result >= 0.4)
for pt in zip(*loc[::-1]): cv2.rectangle(img, pt, (pt[0] + w, pt[1] + h), (0, 255, 0), 3)
cv2.imwrite('Result1.jpg', img) cv2.imshow("img", img)
cv2.waitKey(0) cv2.destroyAllWindows()
image of 1.jpeg: And template too: And output:
6 | No.6 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend:
I also removed threshold too. Here is code:
code:
import cv2
import numpy as npnp
img = cv2.imread("simpsons.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
template = cv2.imread("barts_face.jpg", 0)
w, h = template.shape[::-1]template.shape[::-1]
result = cv2.matchTemplate(gray_img, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(result >= 0.4)0.4)
for pt in zip(*loc[::-1]):
cv2.rectangle(img, pt, (pt[0] + w, pt[1] + h), (0, 255, 0), 3)3)
cv2.imwrite('Result1.jpg', img)
cv2.imshow("img", img)img)
cv2.waitKey(0)
cv2.destroyAllWindows()cv2.destroyAllWindows()
image of 1.jpeg: And template too: And output:
7 | No.7 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend:
I also removed threshold threshold too. Here is code:
import cv2
import numpy as np
img = cv2.imread("simpsons.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
template = cv2.imread("barts_face.jpg", 0)
w, h = template.shape[::-1]
result = cv2.matchTemplate(gray_img, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(result >= 0.4)
for pt in zip(*loc[::-1]):
cv2.rectangle(img, pt, (pt[0] + w, pt[1] + h), (0, 255, 0), 3)
cv2.imwrite('Result1.jpg', img)
cv2.imshow("img", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
image of 1.jpeg: And template too: And output:
8 | No.8 Revision |
Don't used output of 1.jpeg. Use original w/out rectangle. Try this with images and see what happend:
I also removed threshold too. Here is code:
import cv2
import numpy as np
img = cv2.imread("simpsons.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
template = cv2.imread("barts_face.jpg", 0)
w, h = template.shape[::-1]
result = cv2.matchTemplate(gray_img, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(result >= 0.4)
for pt in zip(*loc[::-1]):
cv2.rectangle(img, pt, (pt[0] + w, pt[1] + h), (0, 255, 0), 3)
cv2.imwrite('Result1.jpg', img)
cv2.imshow("img", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
image of 1.jpeg:
And template too: And output: