AutoLidarPerception / kitti_ros

A ROS-based player to replay KiTTI dataset. http://www.cvlibs.net/datasets/kitti/
http://www.cvlibs.net/datasets/kitti/
29 stars 7 forks source link

[Evaluation][3D Object] 3D object detection performance evaluation #18

Open Durant35 opened 6 years ago

Durant35 commented 6 years ago

Refer

Durant35 commented 6 years ago

AP计算由来

image

Durant35 commented 6 years ago

AP 计算公式

image


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());
    }
Durant35 commented 6 years ago

借助Ground Truth's IoU Overlap计算TP、FP

For cars we require an 3D bounding box overlap of 70%, while for pedestrians and cyclists we require a 3D bounding box overlap of 50%.

Durant35 commented 6 years ago

image image