Skip to content

Commit 2de5314

Browse files
committed
better parse tempTuple
1 parent 8340e9f commit 2de5314

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

MTM/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
122122
if not isinstance(tempTuple, tuple) or len(tempTuple)==1:
123123
raise ValueError("listTemplates should be a list of tuples as ('name','array') or ('name', 'array', 'mask')")
124124

125-
elif len(tempTuple)>=3 and method in (0,3):
126-
templateName, template, mask = tempTuple[:3]
125+
templateName, template = tempTuple[:2]
126+
mask = None
127127

128-
else:
129-
templateName, template = tempTuple[:2]
130-
mask = None
128+
if len(tempTuple)>=3:
129+
if method in (0,3):
130+
mask = tempTuple[3]
131+
else:
132+
warnings.warn("Template matching method not supporting the use of Mask. Use 0/TM_SQDIFF or 3/TM_CCORR_NORMED.")
131133

132134
#print('\nSearch with template : ',templateName)
133135
corrMap = computeScoreMap(template, image, method, mask=mask)

0 commit comments

Comments
 (0)