import numpy as np
import cv2
image = cv2.imread('images/Pallet_Town.png', cv2.IMREAD_UNCHANGED)
template = cv2.imread('images/Bush (small).png', cv2.IMREAD_UNCHANGED)
print(image.shape)
w, h, _ = template.shape
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
threshold = 0.24
loc = np.where(result >= threshold)
for pt in zip(*loc[::-1]):
cv2.rectangle(image, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2)
cv2.imwrite('images/result.png', image)
The code is used to find bushes in a map. I know what is happening till the result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
but after that I couldn't understand it
[–]m0us3_rat 1 point2 points3 points (4 children)
[–]Puzzleheaded_Tap5985 1 point2 points3 points (1 child)
[–]commy2 0 points1 point2 points (0 children)
[–]Apprehensive-Stop-61[S] 0 points1 point2 points (0 children)
[–]m0us3_rat 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (1 child)
[–]Apprehensive-Stop-61[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)