From 6816495bee17381b55db2227f9c9be084486fef3 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 5 Jun 2018 12:48:35 +0300 Subject: [PATCH] dnn(test): reuse test/test_common.hpp, eliminate dead code warning --- modules/dnn/perf/perf_net.cpp | 24 ++---------------------- modules/dnn/test/test_common.hpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/modules/dnn/perf/perf_net.cpp b/modules/dnn/perf/perf_net.cpp index aa4ac05881..1386f47656 100644 --- a/modules/dnn/perf/perf_net.cpp +++ b/modules/dnn/perf/perf_net.cpp @@ -10,6 +10,8 @@ #include "opencv2/dnn/shape_utils.hpp" +#include "../test/test_common.hpp" + namespace opencv_test { CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE) @@ -29,28 +31,6 @@ public: target = (dnn::Target)(int)get<1>(GetParam()); } - static bool checkMyriadTarget() - { -#ifndef HAVE_INF_ENGINE - return false; -#endif - cv::dnn::Net net; - cv::dnn::LayerParams lp; - net.addLayerToPrev("testLayer", "Identity", lp); - net.setPreferableBackend(cv::dnn::DNN_BACKEND_INFERENCE_ENGINE); - net.setPreferableTarget(cv::dnn::DNN_TARGET_MYRIAD); - net.setInput(cv::Mat::zeros(1, 1, CV_32FC1)); - try - { - net.forward(); - } - catch(...) - { - return false; - } - return true; - } - void processNet(std::string weights, std::string proto, std::string halide_scheduler, const Mat& input, const std::string& outputLayer = "") { diff --git a/modules/dnn/test/test_common.hpp b/modules/dnn/test/test_common.hpp index 8e8ea74d83..519bf7131c 100644 --- a/modules/dnn/test/test_common.hpp +++ b/modules/dnn/test/test_common.hpp @@ -42,12 +42,12 @@ #ifndef __OPENCV_TEST_COMMON_HPP__ #define __OPENCV_TEST_COMMON_HPP__ -inline const std::string &getOpenCVExtraDir() +static inline const std::string &getOpenCVExtraDir() { return cvtest::TS::ptr()->get_data_path(); } -inline void normAssert(cv::InputArray ref, cv::InputArray test, const char *comment = "", +static inline void normAssert(cv::InputArray ref, cv::InputArray test, const char *comment = "", double l1 = 0.00001, double lInf = 0.0001) { double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total(); @@ -74,7 +74,7 @@ static std::vector matToBoxes(const cv::Mat& m) return boxes; } -inline void normAssertDetections(const std::vector& refClassIds, +static inline void normAssertDetections(const std::vector& refClassIds, const std::vector& refScores, const std::vector& refBoxes, const std::vector& testClassIds, @@ -128,7 +128,7 @@ inline void normAssertDetections(const std::vector& refClassIds, // For SSD-based object detection networks which produce output of shape 1x1xNx7 // where N is a number of detections and an every detection is represented by // a vector [batchId, classId, confidence, left, top, right, bottom]. -inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *comment = "", +static inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *comment = "", double confThreshold = 0.0, double scores_diff = 1e-5, double boxes_iou_diff = 1e-4) { @@ -147,11 +147,11 @@ inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *comment = testBoxes, comment, confThreshold, scores_diff, boxes_iou_diff); } -inline bool checkMyriadTarget() +static inline bool checkMyriadTarget() { #ifndef HAVE_INF_ENGINE return false; -#endif +#else cv::dnn::Net net; cv::dnn::LayerParams lp; net.addLayerToPrev("testLayer", "Identity", lp); @@ -167,9 +167,10 @@ inline bool checkMyriadTarget() return false; } return true; +#endif } -inline bool readFileInMemory(const std::string& filename, std::string& content) +static inline bool readFileInMemory(const std::string& filename, std::string& content) { std::ios::openmode mode = std::ios::in | std::ios::binary; std::ifstream ifs(filename.c_str(), mode);