Skip to content

Commit 67e83d6

Browse files
committed
Quick fix NMS
1 parent 9c973d4 commit 67e83d6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

MTM/NMS.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ def NMS(tableHit, scoreThreshold=0, sortAscending=False, N_object=-1, maxOverlap
4949
listScores = [1-score for score in listScores] # NMS expect high-score for good predictions
5050
scoreThreshold = 1-scoreThreshold
5151

52-
indexes = cv2.dnn.NMSBoxes(listBoxes, listScores, scoreThreshold, maxOverlap, top_k=N_object)
52+
#indexes = cv2.dnn.NMSBoxes(listBoxes, listScores, scoreThreshold, maxOverlap, top_k=N_object) # weird result when top_k=N
53+
indexes = cv2.dnn.NMSBoxes(listBoxes, listScores, scoreThreshold, maxOverlap)
54+
55+
if N_object>0: indexes = indexes[:N_object] # alternative to keep the N best detections (ie after the actual NMS)
5356

54-
indexes = [index[0] for index in indexes]
55-
outTable = tableHit[tableHit.index.isin(indexes)]
57+
indexes = [index[0] for index in indexes] # ordered by score
58+
outTable = tableHit[tableHit.index.isin(indexes)].sort_values(by=['Score'], ascending=False)
5659

5760
return outTable
5861

0 commit comments

Comments
 (0)