Skip to content

Commit d555c67

Browse files
committed
preformat dataframe when no hit detected
1 parent 653514c commit d555c67

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

MTM/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
137137
# append to list of potential hit before Non maxima suppression
138138
listHit.append(newHit)
139139

140-
return pd.DataFrame(listHit) # All possible hits before Non-Maxima Supression
141-
140+
if listHit:
141+
return pd.DataFrame(listHit) # All possible hits before Non-Maxima Supression
142+
else:
143+
return pd.DataFrame(columns=["TemplateName", "BBox", "Score"]) # empty df with correct column header
144+
142145

143146
def matchTemplates(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=float("inf"), score_threshold=0.5, maxOverlap=0.25, searchBox=None):
144147
'''

0 commit comments

Comments
 (0)