@@ -82,8 +82,11 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
8282 Find all possible templates locations provided a list of template to search and an image
8383 Parameters
8484 ----------
85- - listTemplates : list of tuples (LabelString, Grayscale or RGB numpy array)
86- templates to search in each image, associated to a label
85+ - listTemplates : list of tuples (LabelString, template, mask (optional))
86+ templates to search in each image, associated to a label
87+ labelstring : string
88+ template : numpy array (grayscale or RGB)
89+ mask (optional): numpy array, should have the same dimensions and type than the template)
8790 - image : Grayscale or RGB numpy array
8891 image in which to perform the search, it should be the same bitDepth and number of channels than the templates
8992 - method : int
@@ -108,13 +111,17 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
108111 image = image [yOffset :yOffset + searchHeight , xOffset :xOffset + searchWidth ]
109112 else :
110113 xOffset = yOffset = 0
111-
114+
112115 listHit = []
113- for templateName , template in listTemplates : # put the mask as 3rd tuple member ? but then unwrap in the loop rather
116+ for tempTuple in listTemplates :
114117
118+ if len (tempTuple )== 3 and method in (0 ,3 ): templateName , template , mask = tempTuple
119+ else :
120+ templateName , template = tempTuple
121+ mask = None
115122 #print('\nSearch with template : ',templateName)
116123
117- corrMap = computeScoreMap (template , image , method )
124+ corrMap = computeScoreMap (template , image , method , mask = mask )
118125
119126 ## Find possible location of the object
120127 if N_object == 1 : # Detect global Min/Max
0 commit comments