From 7c741f54fae3a2ad8420245e9cafa1050508bbe0 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Wed, 15 Jan 2020 15:10:17 +0300 Subject: [PATCH] Wrap custom OpenCV layers to try-catch --- modules/dnn/src/ie_ngraph.cpp | 9 ++++++++- modules/dnn/src/op_inf_engine.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/dnn/src/ie_ngraph.cpp b/modules/dnn/src/ie_ngraph.cpp index 97085cc12f..2a00880c42 100644 --- a/modules/dnn/src/ie_ngraph.cpp +++ b/modules/dnn/src/ie_ngraph.cpp @@ -323,7 +323,14 @@ void InfEngineNgraphNet::initPlugin(InferenceEngine::CNNNetwork& net) } // Some of networks can work without a library of extra layers. // OpenCV fallbacks as extensions. - ie.AddExtension(std::make_shared(), "CPU"); + try + { + ie.AddExtension(std::make_shared(), "CPU"); + } + catch(const std::exception& e) + { + CV_LOG_INFO(NULL, "DNN-IE: Can't register OpenCV custom layers extension: " << e.what()); + } #ifndef _WIN32 // Limit the number of CPU threads. if (device_name == "CPU") diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 013989312b..7d8232d887 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -738,7 +738,14 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::CNNNetwork& net) // Some of networks can work without a library of extra layers. #if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2019R1) // OpenCV fallbacks as extensions. - ie.AddExtension(std::make_shared(), "CPU"); + try + { + ie.AddExtension(std::make_shared(), "CPU"); + } + catch(const std::exception& e) + { + CV_LOG_INFO(NULL, "DNN-IE: Can't register OpenCV custom layers extension: " << e.what()); + } #endif #ifndef _WIN32 // Limit the number of CPU threads.