Open Durant35 opened 6 years ago
vector<double> getThresholds(vector<double>& v, double n_groundtruth)
{
// holds scores needed to compute N_SAMPLE_PTS recall values
vector<double> t;
// sort scores in descending order
// (highest score is assumed to give best/most confident detections)
sort(v.begin(), v.end(), greater<double>());
// get scores for linearly spaced recall
double current_recall = 0;
for (int32_t i = 0; i < v.size(); i++) {
// check if right-hand-side recall with respect to current recall is close than left-hand-side one
// in this case, skip the current detection score
double l_recall, r_recall, recall;
l_recall = (double) (i + 1) / n_groundtruth;
if (i < (v.size() - 1))
r_recall = (double) (i + 2) / n_groundtruth;
else
r_recall = l_recall;
if ((r_recall - current_recall) < (current_recall - l_recall) && i < (v.size() - 1))
continue;
// left recall is the best approximation, so use this and goto next recall step for approximation
recall = l_recall;
// the next recall step was reached
t.push_back(v[i]);
current_recall += 1.0 / (N_SAMPLE_PTS - 1.0);
}
return t;
}
...
// get scores that must be evaluated for recall discretization
thresholds = getThresholds(v, n_gt);
...
// iterate on every frame of data
for (int32_t i = 0; i < groundtruth.size(); i++) {
// for all scores/recall thresholds do:
for (int32_t t = 0; t < thresholds.size(); t++) {
tPrData tmp = tPrData();
tmp = computeStatistics(current_class, groundtruth[i], detections[i], dontcare[i],
ignored_gt[i], ignored_det[i], true, boxoverlap, metric,
compute_aos, thresholds[t], t == 38);
// add no. of TP, FP, FN, AOS for current frame to total evaluation for current threshold
pr[t].tp += tmp.tp;
pr[t].fp += tmp.fp;
pr[t].fn += tmp.fn;
if (tmp.similarity != -1)
pr[t].similarity += tmp.similarity;
}
}
// compute recall, precision and AOS
vector<double> recall;
precision.assign(N_SAMPLE_PTS, 0);
if (compute_aos)
aos.assign(N_SAMPLE_PTS, 0);
double r = 0;
for (int32_t i = 0; i < thresholds.size(); i++) {
r = pr[i].tp / (double) (pr[i].tp + pr[i].fn);
recall.push_back(r);
precision[i] = pr[i].tp / (double) (pr[i].tp + pr[i].fp);
if (compute_aos)
aos[i] = pr[i].similarity / (double) (pr[i].tp + pr[i].fp);
}
// filter precision and AOS using max_{i..end}(precision)
for (int32_t i = 0; i < thresholds.size(); i++) {
precision[i] = *max_element(precision.begin() + i, precision.end());
if (compute_aos)
aos[i] = *max_element(aos.begin() + i, aos.end());
}
For
cars
we require an 3D bounding box overlap of 70%, while forpedestrians
andcyclists
we require a 3D bounding box overlap of 50%.
Refer