GitHub#465 Fix NonMaxSuppression
If visited flag set true, it should not be visited any more.
For example, if we put 10 boxes (ordered by score) into NonMaxSuppression:
* Step1: Suppose Box 2/3/6/8 are suppressed by Box 1. Box 4/5/7/9/10 survived.
* Step2: Correct way: We use Box 4 to suppress the survive boxes.
Prior to this commit: Box 4 may be suppressed by Box 2,
even Box 2 is already suppressed by Box 1...
Signed-off-by: Antkillerfarm <antkillerfarm@gmail.com>
Change-Id: I38d7a84287649827a16565748592fb562b4df5d5
diff --git a/src/backends/reference/workloads/DetectionPostProcess.cpp b/src/backends/reference/workloads/DetectionPostProcess.cpp
index f80f20a..2108efe 100644
--- a/src/backends/reference/workloads/DetectionPostProcess.cpp
+++ b/src/backends/reference/workloads/DetectionPostProcess.cpp
@@ -85,14 +85,14 @@
if (!visited[sortedIndices[i]])
{
outputIndices.push_back(indicesAboveThreshold[sortedIndices[i]]);
- }
- for (unsigned int j = i + 1; j < numAboveThreshold; ++j)
- {
- unsigned int iIndex = indicesAboveThreshold[sortedIndices[i]] * 4;
- unsigned int jIndex = indicesAboveThreshold[sortedIndices[j]] * 4;
- if (IntersectionOverUnion(&boxCorners[iIndex], &boxCorners[jIndex]) > nmsIouThreshold)
+ for (unsigned int j = i + 1; j < numAboveThreshold; ++j)
{
- visited[sortedIndices[j]] = true;
+ unsigned int iIndex = indicesAboveThreshold[sortedIndices[i]] * 4;
+ unsigned int jIndex = indicesAboveThreshold[sortedIndices[j]] * 4;
+ if (IntersectionOverUnion(&boxCorners[iIndex], &boxCorners[jIndex]) > nmsIouThreshold)
+ {
+ visited[sortedIndices[j]] = true;
+ }
}
}
}