From cb64fdabb5417b89dc8a141e9f4ee12e88db935f Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Wed, 15 Jan 2020 16:22:00 +0300 Subject: [PATCH] Different way to reset Myriad device --- modules/dnn/src/dnn.cpp | 2 +- modules/dnn/src/op_inf_engine.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 2abdbdd90f..f29d10de86 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -109,7 +109,7 @@ public: #ifdef HAVE_INF_ENGINE static inline bool checkIETarget(Target target) { -#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2019R3) +#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2019R3) // Lightweight detection const std::vector devices = getCore().GetAvailableDevices(); for (std::vector::const_iterator i = devices.begin(); i != devices.end(); ++i) diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 2dd66121bf..2036d3aa03 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -574,7 +574,7 @@ InferenceEngine::Core& getCore() #if !defined(OPENCV_DNN_IE_VPU_TYPE_DEFAULT) static bool detectMyriadX_() { -#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2019R3) +#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2019R3) // Lightweight detection InferenceEngine::Core& ie = getCore(); const std::vector devices = ie.GetAvailableDevices(); @@ -1075,8 +1075,14 @@ void resetMyriadDevice() #if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) getSharedPlugins().erase("MYRIAD"); #else - // To unregister both "MYRIAD" and "HETERO:MYRIAD,CPU" plugins - getCore() = InferenceEngine::Core(); + // Unregister both "MYRIAD" and "HETERO:MYRIAD,CPU" plugins + InferenceEngine::Core& ie = getCore(); + try + { + ie.UnregisterPlugin("MYRIAD"); + ie.UnregisterPlugin("HETERO"); + } + catch (...) {} #endif #endif // HAVE_INF_ENGINE }