I need to count the occurrence of the stars at the right bottom corner in the image, I read this article Template Matching and used the following code to find the stars but My code doesn't work for detecting the stars in the image.
What changes should I make in the code?
import cv2 as cv import numpy as np from matplotlib import pyplot as plt img_rgb = cv.imread('page.png') img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY) template = cv.imread('star_temp.png', 0) w, h = template.shape[::-1] res = cv.matchTemplate(img_gray, template, cv.TM_CCOEFF_NORMED) threshold = 0.8 loc = np.where(res >= threshold) print(res) for pt in zip(*loc[::-1]): cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2) cv.imwrite('res.png', img_rgb) star_temp.png
page.png



