Skip to content

Commit

Permalink
Merge pull request #607 from biometrics/evalBackground
Browse files Browse the repository at this point in the history
Add the ability for evalDetection to handle background images (images…
  • Loading branch information
bhklein authored Apr 15, 2024
2 parents 9840a08 + ade33ff commit 10007dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 19 additions & 0 deletions openbr/core/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,25 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery
// Organized by file, QMap used to preserve order
QMap<QString, Detections> allDetections = getDetections(predictedGallery, truthGallery);

// Ensure there is at least some overlap between truth and pred, otherwise we expect a path issue
int truthOnly = 0, predOnly = 0, bothTruthAndPred = 0;
foreach (QString key, allDetections.keys()) {
if (allDetections[key].truth.isEmpty())
predOnly += 1;
else if (allDetections[key].predicted.isEmpty())
truthOnly += 1;
else
bothTruthAndPred += 1;
}

if (bothTruthAndPred == 0)
qFatal("No files have both truth and predicted detections. Check your file paths and try again");

qDebug() << "File count -> Total:" << allDetections.size();
qDebug() << " Truth only:" << truthOnly;
qDebug() << " Predicted only:" << predOnly;
qDebug() << " Both:" << bothTruthAndPred;

// Remove any bounding boxes with a side smaller than minSize
if (minSize > 0 || relativeMinSize > 0) {
if (Globals->verbose)
Expand Down
3 changes: 1 addition & 2 deletions openbr/core/evalutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ QMap<QString, Detections> EvalUtils::getDetections(const File &predictedGallery,
allDetections[f.name].imageSize = QSize(image.cols, image.rows);
}
foreach (const File &f, predicted)
if (allDetections.contains(f.name))
allDetections[f.name].predicted.append(getDetections(predictedDetectKey, f, false));
allDetections[f.name].predicted.append(getDetections(predictedDetectKey, f, false));
return allDetections;
}

Expand Down

0 comments on commit 10007dc

Please sign in to comment.