Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/dnn/test/test_nms.cpp
16354 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
//
5
// Copyright (C) 2017, Intel Corporation, all rights reserved.
6
// Third party copyrights are property of their respective owners.
7
8
#include "test_precomp.hpp"
9
10
namespace opencv_test { namespace {
11
12
TEST(NMS, Accuracy)
13
{
14
//reference results obtained using tf.image.non_max_suppression with iou_threshold=0.5
15
std::string dataPath = findDataFile("dnn/nms_reference.yml");
16
FileStorage fs(dataPath, FileStorage::READ);
17
18
std::vector<Rect> bboxes;
19
std::vector<float> scores;
20
std::vector<int> ref_indices;
21
22
fs["boxes"] >> bboxes;
23
fs["probs"] >> scores;
24
fs["output"] >> ref_indices;
25
26
const float nms_thresh = .5f;
27
const float score_thresh = .01f;
28
std::vector<int> indices;
29
cv::dnn::NMSBoxes(bboxes, scores, score_thresh, nms_thresh, indices);
30
31
ASSERT_EQ(ref_indices.size(), indices.size());
32
33
std::sort(indices.begin(), indices.end());
34
std::sort(ref_indices.begin(), ref_indices.end());
35
36
for(size_t i = 0; i < indices.size(); i++)
37
ASSERT_EQ(indices[i], ref_indices[i]);
38
}
39
40
}} // namespace
41
42