Commit c7d69e725ae2c62fa309b8da6afff5fcb8195d06
1 parent
6dea1280
evalDetection bug fix
Showing
1 changed file
with
7 additions
and
4 deletions
openbr/core/eval.cpp
| @@ -387,7 +387,7 @@ struct DetectionOperatingPoint | @@ -387,7 +387,7 @@ struct DetectionOperatingPoint | ||
| 387 | : Recall(TP/totalPositives), FalsePositives(FP), Precision(TP/(TP+FP)) {} | 387 | : Recall(TP/totalPositives), FalsePositives(FP), Precision(TP/(TP+FP)) {} |
| 388 | }; | 388 | }; |
| 389 | 389 | ||
| 390 | -static QStringList computeDetectionResults(const QList<ResolvedDetection> &detections, int totalPositives, bool discrete) | 390 | +static QStringList computeDetectionResults(const QList<ResolvedDetection> &detections, int totalTrueDetections, bool discrete) |
| 391 | { | 391 | { |
| 392 | QList<DetectionOperatingPoint> points; | 392 | QList<DetectionOperatingPoint> points; |
| 393 | float TP = 0, FP = 0, prevFP = -1; | 393 | float TP = 0, FP = 0, prevFP = -1; |
| @@ -403,7 +403,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec | @@ -403,7 +403,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec | ||
| 403 | } | 403 | } |
| 404 | if ((i == detections.size()-1) || (detection.confidence > detections[i+1].confidence)) { | 404 | if ((i == detections.size()-1) || (detection.confidence > detections[i+1].confidence)) { |
| 405 | if (FP > prevFP || (i == detections.size()-1)) { | 405 | if (FP > prevFP || (i == detections.size()-1)) { |
| 406 | - points.append(DetectionOperatingPoint(TP, FP, totalPositives)); | 406 | + points.append(DetectionOperatingPoint(TP, FP, totalTrueDetections)); |
| 407 | prevFP = FP; | 407 | prevFP = FP; |
| 408 | } | 408 | } |
| 409 | } | 409 | } |
| @@ -508,7 +508,10 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery | @@ -508,7 +508,10 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery | ||
| 508 | QMap<QString, Detections> allDetections = getDetections(predicted, truth); | 508 | QMap<QString, Detections> allDetections = getDetections(predicted, truth); |
| 509 | 509 | ||
| 510 | QList<ResolvedDetection> resolvedDetections, falseNegativeDetections; | 510 | QList<ResolvedDetection> resolvedDetections, falseNegativeDetections; |
| 511 | + int totalTrueDetections = 0; | ||
| 511 | foreach (Detections detections, allDetections.values()) { // For every file | 512 | foreach (Detections detections, allDetections.values()) { // For every file |
| 513 | + totalTrueDetections += detections.truth.size(); | ||
| 514 | + | ||
| 512 | // Try to associate ground truth detections with predicted detections | 515 | // Try to associate ground truth detections with predicted detections |
| 513 | while (!detections.truth.isEmpty() && !detections.predicted.isEmpty()) { | 516 | while (!detections.truth.isEmpty() && !detections.predicted.isEmpty()) { |
| 514 | const Detection truth = detections.truth.takeFirst(); // Take removes the detection | 517 | const Detection truth = detections.truth.takeFirst(); // Take removes the detection |
| @@ -539,8 +542,8 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery | @@ -539,8 +542,8 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery | ||
| 539 | 542 | ||
| 540 | QStringList lines; | 543 | QStringList lines; |
| 541 | lines.append("Plot, X, Y"); | 544 | lines.append("Plot, X, Y"); |
| 542 | - lines.append(computeDetectionResults(resolvedDetections, truth.size(), true)); | ||
| 543 | - lines.append(computeDetectionResults(resolvedDetections, truth.size(), false)); | 545 | + lines.append(computeDetectionResults(resolvedDetections, totalTrueDetections, true)); |
| 546 | + lines.append(computeDetectionResults(resolvedDetections, totalTrueDetections, false)); | ||
| 544 | 547 | ||
| 545 | float averageOverlap; | 548 | float averageOverlap; |
| 546 | { // Overlap Density | 549 | { // Overlap Density |