def detect(self, image):
# convert image to grayscale
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply template matching
result = cv2.matchTemplate(image_gray, self.template, cv2.TM_CCOEFF_NORMED)
# obtain locations, where threshold met
locations = np.where(result >= self.THRESHOLD)
for item in locations:
if len(item) == 0:
return None
return locations
评论列表
文章目录