From 4283309daaa8dfca1701a4b6d3ff884f3eae1bca Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 23 Jul 2018 18:17:51 +0300 Subject: [PATCH] dnn: update tests for OpenVINO models --- modules/dnn/test/test_ie_models.cpp | 56 ++++++++++++++++++++++++------------- modules/ts/include/opencv2/ts.hpp | 1 + 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/modules/dnn/test/test_ie_models.cpp b/modules/dnn/test/test_ie_models.cpp index 80c8ef3..9013ce9 100644 --- a/modules/dnn/test/test_ie_models.cpp +++ b/modules/dnn/test/test_ie_models.cpp @@ -13,15 +13,22 @@ #include #include -static std::string extraTestDataPath = -#ifdef WINRT - NULL; -#else - getenv("INTEL_CVSDK_DIR"); -#endif - namespace opencv_test { namespace { +static void initDLDTDataPath() +{ +#ifndef WINRT + static bool initialized = false; + if (!initialized) + { + const char* dldtTestDataPath = getenv("INTEL_CVSDK_DIR"); + if (dldtTestDataPath) + cvtest::addDataSearchPath(cv::utils::fs::join(dldtTestDataPath, "deployment_tools")); + initialized = true; + } +#endif +} + using namespace cv; using namespace cv::dnn; using namespace InferenceEngine; @@ -174,13 +181,11 @@ TEST_P(DNNTestOpenVINO, models) throw SkipTestException(""); std::string precision = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? "FP16" : "FP32"; - std::string prefix = utils::fs::join(extraTestDataPath, - utils::fs::join("deployment_tools", - utils::fs::join("intel_models", + std::string prefix = utils::fs::join("intel_models", utils::fs::join(modelName, - utils::fs::join(precision, modelName))))); - std::string xmlPath = prefix + ".xml"; - std::string binPath = prefix + ".bin"; + utils::fs::join(precision, modelName))); + std::string xmlPath = findDataFile(prefix + ".xml"); + std::string binPath = findDataFile(prefix + ".bin"); std::map inputsMap; std::map ieOutputsMap, cvOutputsMap; @@ -199,17 +204,30 @@ TEST_P(DNNTestOpenVINO, models) static testing::internal::ParamGenerator intelModels() { - String path = utils::fs::join(utils::fs::join(extraTestDataPath, "deployment_tools"), "intel_models"); - + initDLDTDataPath(); std::vector modelsNames; + + std::string path; + try + { + path = findDataDirectory("intel_models", false); + } + catch (...) + { + std::cerr << "ERROR: Can't find OpenVINO models. Check INTEL_CVSDK_DIR environment variable (run setup.sh)" << std::endl; + return ValuesIn(modelsNames); // empty list + } + cv::utils::fs::glob_relative(path, "", modelsNames, false, true); - std::vector::iterator end = + modelsNames.erase( std::remove_if(modelsNames.begin(), modelsNames.end(), - [&](const String& dir){ return !utils::fs::isDirectory(utils::fs::join(path, dir)); }); - modelsNames = std::vector(modelsNames.begin(), end); + [&](const String& dir){ return !utils::fs::isDirectory(utils::fs::join(path, dir)); }), + modelsNames.end() + ); + CV_Assert(!modelsNames.empty()); - return testing::ValuesIn(modelsNames); + return ValuesIn(modelsNames); } INSTANTIATE_TEST_CASE_P(/**/, DNNTestOpenVINO, Combine( diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index 5d88396..3fbea89 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -103,6 +103,7 @@ using std::pair; using std::make_pair; using testing::TestWithParam; using testing::Values; +using testing::ValuesIn; using testing::Combine; using cv::Mat; -- 2.7.4