From: Vladislav Sovrasov Date: Tue, 17 Oct 2017 13:43:04 +0000 (+0300) Subject: dnn: add an accuracy test for NMS X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~471^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e3e9144de2037bc80b5b90928a5811a7e740775;p=platform%2Fupstream%2Fopencv.git dnn: add an accuracy test for NMS --- diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp index 970984b..2e381b2 100644 --- a/modules/dnn/src/layers/detection_output_layer.cpp +++ b/modules/dnn/src/layers/detection_output_layer.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include "../nms.inl.hpp" namespace cv { diff --git a/modules/dnn/src/nms.cpp b/modules/dnn/src/nms.cpp index af9e9c8..f56191f 100644 --- a/modules/dnn/src/nms.cpp +++ b/modules/dnn/src/nms.cpp @@ -6,7 +6,7 @@ // Third party copyrights are property of their respective owners. #include "precomp.hpp" -#include +#include namespace cv { diff --git a/modules/dnn/include/opencv2/dnn/nms.inl.hpp b/modules/dnn/src/nms.inl.hpp similarity index 100% rename from modules/dnn/include/opencv2/dnn/nms.inl.hpp rename to modules/dnn/src/nms.inl.hpp diff --git a/modules/dnn/test/test_nms.cpp b/modules/dnn/test/test_nms.cpp new file mode 100644 index 0000000..1359a77 --- /dev/null +++ b/modules/dnn/test/test_nms.cpp @@ -0,0 +1,41 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2017, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#include "test_precomp.hpp" + +namespace cvtest +{ + +TEST(NMS, Accuracy) +{ + //reference results obtained using tf.image.non_max_suppression with iou_threshold=0.5 + std::string dataPath = findDataFile("dnn/nms_reference.yml"); + FileStorage fs(dataPath, FileStorage::READ); + + std::vector bboxes; + std::vector scores; + std::vector ref_indices; + + fs["boxes"] >> bboxes; + fs["probs"] >> scores; + fs["output"] >> ref_indices; + + const float nms_thresh = .5f; + const float score_thresh = .01f; + std::vector indices; + cv::dnn::NMSBoxes(bboxes, scores, score_thresh, nms_thresh, indices); + + ASSERT_EQ(ref_indices.size(), indices.size()); + + std::sort(indices.begin(), indices.end()); + std::sort(ref_indices.begin(), ref_indices.end()); + + for(size_t i = 0; i < indices.size(); i++) + ASSERT_EQ(indices[i], ref_indices[i]); +} + +}//cvtest