Skip to content

Commit

Permalink
Merge pull request #91 from LuGuangguang/master
Browse files Browse the repository at this point in the history
Update PaddleDetector.cs
  • Loading branch information
sdcb authored Apr 30, 2024
2 parents 46328a7 + b1ac945 commit f0cf603
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Sdcb.PaddleDetection/PaddleDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public DetectionResult[] Run(Mat src)
if (isRbox)
{
int classId = (int)MathUtil.Round(outputData[0 + j * 10]);
if (classId > Config.LabelList.Length - 1)
{
continue;
}
float score = outputData[1 + j * 10];
int x1 = (int)(outputData[2 + j * 10] * r.Width);
int y1 = (int)(outputData[3 + j * 10] * r.Height);
Expand All @@ -186,6 +190,10 @@ public DetectionResult[] Run(Mat src)
else
{
int classId = (int)MathUtil.Round(outputData[0 + j * 6]);
if (classId > Config.LabelList.Length - 1)
{
continue;
}
float score = outputData[1 + j * 6];
int xmin = (int)(outputData[2 + j * 6] * r.Width);
int ymin = (int)(outputData[3 + j * 6] * r.Height);
Expand All @@ -194,6 +202,7 @@ public DetectionResult[] Run(Mat src)
result[j] = new DetectionResult(new[] { xmin, ymin, xmax, ymax }, classId, Config.LabelList[classId], score);
}
}
result = result.Where(r => r != null).ToArray();
return result;
}
}
Expand Down Expand Up @@ -406,4 +415,4 @@ static IEnumerable<Scalar> GenerateColorMapToScalar()
}
}
}
}
}

0 comments on commit f0cf603

Please sign in to comment.