@@ -110,18 +110,18 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
110110 if N_object == 1 : # Detect global Min/Max
111111 minVal , maxVal , minLoc , maxLoc = cv2 .minMaxLoc (corrMap )
112112
113- if method == 1 :
113+ if method in ( 0 , 1 ) :
114114 Peaks = [minLoc [::- 1 ]] # opposite sorting than in the multiple detection
115115
116- elif method in ( 3 , 5 ) :
116+ else :
117117 Peaks = [maxLoc [::- 1 ]]
118118
119119
120120 else :# Detect local max or min
121- if method == 1 : # Difference => look for local minima
121+ if method in ( 0 , 1 ) : # Difference => look for local minima
122122 Peaks = _findLocalMin_ (corrMap , score_threshold )
123123
124- elif method in ( 3 , 5 ) :
124+ else :
125125 Peaks = _findLocalMax_ (corrMap , score_threshold )
126126
127127
@@ -156,7 +156,8 @@ def matchTemplates(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=f
156156 - image : Grayscale or RGB numpy array
157157 image in which to perform the search, it should be the same bitDepth and number of channels than the templates
158158 - method : int
159- one of OpenCV template matching method (0 to 5), default 5=0-mean cross-correlation
159+ one of OpenCV template matching method (1 to 5), default 5=0-mean cross-correlation
160+ method 0 is not supported, use method 1 instead
160161 - N_object: int
161162 expected number of objects in the image
162163 - score_threshold: float in range [0,1]
@@ -179,7 +180,9 @@ def matchTemplates(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=f
179180
180181 tableHit = findMatches (listTemplates , image , method , N_object , score_threshold , searchBox )
181182
182- if method in (0 ,1 ):
183+ if method == 0 :
184+ raise ValueError ("Method 0/TM_SQDIFF is not supported, Use 1/TM_SQDIFF_NORMED instead." )
185+ elif method == 1 :
183186 sortAscending = True
184187 else :
185188 sortAscending = False
0 commit comments