minor fixes

This commit is contained in:
2022-06-13 16:42:41 +02:00
parent 2930eb04b1
commit 5e25b8303f
5 changed files with 10 additions and 5 deletions

View File

@@ -92,13 +92,14 @@ class Vision:
needle_w = needle_img.shape[1]
needle_h = needle_img.shape[0]
if normalize:
if mask is not None:
result = cv.matchTemplate(haystack_img, needle_img, cv.TM_CCORR_NORMED, None, mask)
_minVal, _maxVal, minLoc, maxLoc = cv.minMaxLoc(result, None)
cv.normalize(result, result, 0, 1, cv.NORM_MINMAX, -1)
#_minVal, _maxVal, minLoc, maxLoc = cv.minMaxLoc(result, None)
else:
result = cv.matchTemplate(haystack_img, needle_img, self.method)
if normalize:
cv.normalize(result, result, 0, 1, cv.NORM_MINMAX, -1)
# Get the all the positions from the match result that exceed our threshold
locations = np.where(result >= threshold)
locations = list(zip(*locations[::-1]))