I want to find 2d images of bush inside a 2d map. According to their website I used this code
image = cv2.imread('images/Pallet_Town.png', cv2.IMREAD_UNCHANGED)
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
template = cv2.imread('images/Bush (small).png', cv2.IMREAD_UNCHANGED)
template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2RGB)
print(image.shape)
w, h, _ = template.shape
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where(result >= threshold)
print(*loc[::-1])
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 doesn't work and is not able to find any bush. The result image has no rectangles. What else function should I use to find the bush inside the image (Be it an opencv function or any other package) or is it my code problem.
Using these images (Bush is under the map)