Commit 6816495b authored by Alexander Alekhin's avatar Alexander Alekhin

dnn(test): reuse test/test_common.hpp, eliminate dead code warning

parent b2cff440
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "opencv2/dnn/shape_utils.hpp" #include "opencv2/dnn/shape_utils.hpp"
#include "../test/test_common.hpp"
namespace opencv_test { namespace opencv_test {
CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE) CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE)
...@@ -29,28 +31,6 @@ public: ...@@ -29,28 +31,6 @@ public:
target = (dnn::Target)(int)get<1>(GetParam()); 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, void processNet(std::string weights, std::string proto, std::string halide_scheduler,
const Mat& input, const std::string& outputLayer = "") const Mat& input, const std::string& outputLayer = "")
{ {
......
...@@ -42,12 +42,12 @@ ...@@ -42,12 +42,12 @@
#ifndef __OPENCV_TEST_COMMON_HPP__ #ifndef __OPENCV_TEST_COMMON_HPP__
#define __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(); 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 l1 = 0.00001, double lInf = 0.0001)
{ {
double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total(); double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total();
...@@ -74,7 +74,7 @@ static std::vector<cv::Rect2d> matToBoxes(const cv::Mat& m) ...@@ -74,7 +74,7 @@ static std::vector<cv::Rect2d> matToBoxes(const cv::Mat& m)
return boxes; return boxes;
} }
inline void normAssertDetections(const std::vector<int>& refClassIds, static inline void normAssertDetections(const std::vector<int>& refClassIds,
const std::vector<float>& refScores, const std::vector<float>& refScores,
const std::vector<cv::Rect2d>& refBoxes, const std::vector<cv::Rect2d>& refBoxes,
const std::vector<int>& testClassIds, const std::vector<int>& testClassIds,
...@@ -128,7 +128,7 @@ inline void normAssertDetections(const std::vector<int>& refClassIds, ...@@ -128,7 +128,7 @@ inline void normAssertDetections(const std::vector<int>& refClassIds,
// For SSD-based object detection networks which produce output of shape 1x1xNx7 // 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 // where N is a number of detections and an every detection is represented by
// a vector [batchId, classId, confidence, left, top, right, bottom]. // 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 confThreshold = 0.0, double scores_diff = 1e-5,
double boxes_iou_diff = 1e-4) double boxes_iou_diff = 1e-4)
{ {
...@@ -147,11 +147,11 @@ inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *comment = ...@@ -147,11 +147,11 @@ inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *comment =
testBoxes, comment, confThreshold, scores_diff, boxes_iou_diff); testBoxes, comment, confThreshold, scores_diff, boxes_iou_diff);
} }
inline bool checkMyriadTarget() static inline bool checkMyriadTarget()
{ {
#ifndef HAVE_INF_ENGINE #ifndef HAVE_INF_ENGINE
return false; return false;
#endif #else
cv::dnn::Net net; cv::dnn::Net net;
cv::dnn::LayerParams lp; cv::dnn::LayerParams lp;
net.addLayerToPrev("testLayer", "Identity", lp); net.addLayerToPrev("testLayer", "Identity", lp);
...@@ -167,9 +167,10 @@ inline bool checkMyriadTarget() ...@@ -167,9 +167,10 @@ inline bool checkMyriadTarget()
return false; return false;
} }
return true; 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::ios::openmode mode = std::ios::in | std::ios::binary;
std::ifstream ifs(filename.c_str(), mode); std::ifstream ifs(filename.c_str(), mode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment