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.
5 // Copyright (C) 2017, Intel Corporation, all rights reserved.
6 // Third party copyrights are property of their respective owners.
8 #include "test_precomp.hpp"
10 namespace opencv_test { namespace {
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);
18 std::vector<Rect> bboxes;
19 std::vector<float> scores;
20 std::vector<int> ref_indices;
22 fs["boxes"] >> bboxes;
23 fs["probs"] >> scores;
24 fs["output"] >> ref_indices;
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);
31 ASSERT_EQ(ref_indices.size(), indices.size());
33 std::sort(indices.begin(), indices.end());
34 std::sort(ref_indices.begin(), ref_indices.end());
36 for(size_t i = 0; i < indices.size(); i++)
37 ASSERT_EQ(indices[i], ref_indices[i]);