Commit 872ecd47d4c632a584ac0402f8ba06edf4ba831f
1 parent
6298e600
commented eval detection for #138
Showing
1 changed file
with
8 additions
and
2 deletions
openbr/core/eval.cpp
| ... | ... | @@ -394,6 +394,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec |
| 394 | 394 | for (int i=0; i<detections.size(); i++) { |
| 395 | 395 | const ResolvedDetection &detection = detections[i]; |
| 396 | 396 | if (discrete) { |
| 397 | + // A 50% overlap is considered a true positive | |
| 397 | 398 | if (detection.overlap >= 0.5) TP++; |
| 398 | 399 | else FP++; |
| 399 | 400 | } else { |
| ... | ... | @@ -507,11 +508,13 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery |
| 507 | 508 | QMap<QString, Detections> allDetections = getDetections(predicted, truth); |
| 508 | 509 | |
| 509 | 510 | QList<ResolvedDetection> resolvedDetections, falseNegativeDetections; |
| 510 | - foreach (Detections detections, allDetections.values()) { | |
| 511 | + foreach (Detections detections, allDetections.values()) { // For every file | |
| 512 | + // Try to associate ground truth detections with predicted detections | |
| 511 | 513 | while (!detections.truth.isEmpty() && !detections.predicted.isEmpty()) { |
| 512 | - const Detection truth = detections.truth.takeFirst(); | |
| 514 | + const Detection truth = detections.truth.takeFirst(); // Take removes the detection | |
| 513 | 515 | int bestIndex = -1; |
| 514 | 516 | float bestOverlap = -std::numeric_limits<float>::max(); |
| 517 | + // Find the nearest predicted detection to this ground truth detection | |
| 515 | 518 | for (int i=0; i<detections.predicted.size(); i++) { |
| 516 | 519 | const float overlap = truth.overlap(detections.predicted[i]); |
| 517 | 520 | if (overlap > bestOverlap) { |
| ... | ... | @@ -519,6 +522,9 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery |
| 519 | 522 | bestIndex = i; |
| 520 | 523 | } |
| 521 | 524 | } |
| 525 | + // Removing the detection prevents us from considering it twice. | |
| 526 | + // We don't want to associate two ground truth detections with the | |
| 527 | + // same prediction, over vice versa. | |
| 522 | 528 | const Detection predicted = detections.predicted.takeAt(bestIndex); |
| 523 | 529 | resolvedDetections.append(ResolvedDetection(predicted.confidence, bestOverlap)); |
| 524 | 530 | } | ... | ... |