Skip to content

Commit 98cfe1a

Browse files
committed
add better check for tempTuple
1 parent 941916f commit 98cfe1a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

MTM/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,17 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
119119
listHit = []
120120
for tempTuple in listTemplates:
121121

122-
if len(tempTuple)==3 and method in (0,3): templateName, template, mask = tempTuple[:3]
122+
if not isinstance(tempTuple, tuple) or len(tempTuple)==1:
123+
raise ValueError("listTemplates should be a list of tuples as ('name','array') or ('name', 'array', 'mask')")
124+
125+
elif len(tempTuple)>=3 and method in (0,3):
126+
templateName, template, mask = tempTuple[:3]
127+
123128
else:
124129
templateName, template = tempTuple[:2]
125130
mask = None
126-
#print('\nSearch with template : ',templateName)
127131

132+
#print('\nSearch with template : ',templateName)
128133
corrMap = computeScoreMap(template, image, method, mask=mask)
129134

130135
## Find possible location of the object

0 commit comments

Comments
 (0)