From f2f600f80741bb6e99179dbb5189eade2aa0f598 Mon Sep 17 00:00:00 2001 From: Rostislav Vasilikhin Date: Thu, 27 Jun 2019 01:17:26 +0300 Subject: [PATCH 1/6] fixed multi instrumentations --- modules/core/include/opencv2/core/private.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index dad897e271..5e66801b51 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -716,10 +716,10 @@ CV_EXPORTS InstrNode* getCurrentNode(); #endif // Instrument region -#define CV_INSTRUMENT_REGION_META(NAME, ALWAYS_EXPAND, TYPE, IMPL) ::cv::instr::IntrumentationRegion __instr_region__(NAME, __FILE__, __LINE__, CV_INSTRUMENT_GET_RETURN_ADDRESS, ALWAYS_EXPAND, TYPE, IMPL); +#define CV_INSTRUMENT_REGION_META(NAME, ALWAYS_EXPAND, TYPE, IMPL) ::cv::instr::IntrumentationRegion CVAUX_CONCAT(__instr_region__, __LINE__) (NAME, __FILE__, __LINE__, CV_INSTRUMENT_GET_RETURN_ADDRESS, ALWAYS_EXPAND, TYPE, IMPL); #define CV_INSTRUMENT_REGION_CUSTOM_META(NAME, ALWAYS_EXPAND, TYPE, IMPL)\ - void *__curr_address__ = [&]() {return CV_INSTRUMENT_GET_RETURN_ADDRESS;}();\ - ::cv::instr::IntrumentationRegion __instr_region__(NAME, __FILE__, __LINE__, __curr_address__, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN); + void *CVAUX_CONCAT(__curr_address__, __LINE__) = [&]() {return CV_INSTRUMENT_GET_RETURN_ADDRESS;}();\ + ::cv::instr::IntrumentationRegion CVAUX_CONCAT(__instr_region__, __LINE__) (NAME, __FILE__, __LINE__, CVAUX_CONCAT(__curr_address__, __LINE__), false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN); // Instrument functions with non-void return type #define CV_INSTRUMENT_FUN_RT_META(TYPE, IMPL, ERROR_COND, FUN, ...) ([&]()\ {\ From 96a2f80bf28a7ad8b7c8973b581f67bc2c143640 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Mon, 24 Jun 2019 22:41:30 +0300 Subject: [PATCH 2/6] Limit number of threads in CPU plugin of IE by OpenCV's getNumThreads --- modules/dnn/src/op_inf_engine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 3f96a1db37..ab9bdc38fe 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -460,6 +460,12 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net) CV_LOG_WARNING(NULL, "DNN-IE: Can't load extension plugin (extra layers for some networks). Specify path via OPENCV_DNN_IE_EXTRA_PLUGIN_PATH parameter"); } // Some of networks can work without a library of extra layers. +#ifndef _WIN32 + // Limit the number of CPU threads. + enginePtr->SetConfig({{ + InferenceEngine::PluginConfigParams::KEY_CPU_THREADS_NUM, format("%d", getNumThreads()), + }}, 0); +#endif } plugin = InferenceEngine::InferencePlugin(enginePtr); From 031e57b3598c85e321aa790bdc8985f22a465f35 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Thu, 27 Jun 2019 13:13:48 +0300 Subject: [PATCH 3/6] Fixed names conflict with dldt --- modules/dnn/src/op_inf_engine.cpp | 2 +- modules/dnn/src/op_inf_engine.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 3f96a1db37..d728b89d67 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -476,7 +476,7 @@ bool InfEngineBackendNet::isInitialized() return (bool)enginePtr; } -void InfEngineBackendNet::addBlobs(const std::vector >& ptrs) +void InfEngineBackendNet::addBlobs(const std::vector >& ptrs) { auto wrappers = infEngineWrappers(ptrs); for (const auto& wrapper : wrappers) diff --git a/modules/dnn/src/op_inf_engine.hpp b/modules/dnn/src/op_inf_engine.hpp index 37bc5cc587..b9abfd3fcc 100644 --- a/modules/dnn/src/op_inf_engine.hpp +++ b/modules/dnn/src/op_inf_engine.hpp @@ -84,7 +84,7 @@ public: void initPlugin(InferenceEngine::ICNNNetwork& net); - void addBlobs(const std::vector >& ptrs); + void addBlobs(const std::vector >& ptrs); private: InferenceEngine::Builder::Network netBuilder; From a743de0e245fa0291e8bd68ea1e9b237a8c6e32e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 27 Jun 2019 17:04:10 +0300 Subject: [PATCH 4/6] dnn: adjust compilation options --- modules/dnn/src/op_inf_engine.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/dnn/src/op_inf_engine.hpp b/modules/dnn/src/op_inf_engine.hpp index b9abfd3fcc..c183cd0e81 100644 --- a/modules/dnn/src/op_inf_engine.hpp +++ b/modules/dnn/src/op_inf_engine.hpp @@ -38,7 +38,16 @@ #pragma GCC diagnostic ignored "-Wsuggest-override" #endif -#if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) +//#define INFERENCE_ENGINE_DEPRECATED // turn off deprecation warnings from IE +//there is no way to suppress warnigns from IE only at this moment, so we are forced to suppress warnings globally +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif +#ifdef _MSC_VER +#pragma warning(disable: 4996) // was declared deprecated +#endif + +#if defined(__GNUC__) #pragma GCC visibility push(default) #endif @@ -46,7 +55,7 @@ #include -#if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) +#if defined(__GNUC__) #pragma GCC visibility pop #endif From e10c01047c854dbb86bfe6d6bcacddbe238e555a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 28 Jun 2019 00:17:26 +0200 Subject: [PATCH 5/6] Fix detection of 32bit ARM builds on Aarch64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is perfectly possible to compile ARM binaries on Aarch64. Generalize the code to no only swap X86 with X86_64, but also ARM and AARCH64. Signed-off-by: Stefan BrĂ¼ns --- cmake/OpenCVDetectCXXCompiler.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake index d7fb4f9a80..b17895ae16 100644 --- a/cmake/OpenCVDetectCXXCompiler.cmake +++ b/cmake/OpenCVDetectCXXCompiler.cmake @@ -83,6 +83,7 @@ if(WIN32 AND CV_GCC) endif() endif() +message(STATUS "Detected processor: ${CMAKE_SYSTEM_PROCESSOR}") if(MSVC64 OR MINGW64) set(X86_64 1) elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING)) @@ -101,11 +102,17 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") set(PPC64 1) endif() -# Workaround for 32-bit operating systems on 64-bit x86_64 processor -if(X86_64 AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT FORCE_X86_64) - message(STATUS "sizeof(void) = 4 on x86 / x86_64 processor. Assume 32-bit compilation mode (X86=1)") - unset(X86_64) - set(X86 1) +# Workaround for 32-bit operating systems on x86_64/aarch64 processor +if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT FORCE_X86_64) + message(STATUS "sizeof(void) = 4 on 64 bit processor. Assume 32-bit compilation mode") + if (X86_64) + unset(X86_64) + set(X86 1) + endif() + if (AARCH64) + unset(AARCH64) + set(ARM 1) + endif() endif() # Similar code exists in OpenCVConfig.cmake From a04ab2298b9fc9b3b621faac8ab18c15e51682d4 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Sat, 29 Jun 2019 19:21:14 +0300 Subject: [PATCH 6/6] Fix JS sample of dnn --- samples/dnn/js_face_recognition.html | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/samples/dnn/js_face_recognition.html b/samples/dnn/js_face_recognition.html index daf47b82fe..ded3550c59 100644 --- a/samples/dnn/js_face_recognition.html +++ b/samples/dnn/js_face_recognition.html @@ -12,7 +12,7 @@ var persons = {}; //! [Run face detection model] function detectFaces(img) { - var blob = cv.blobFromImage(img, 1, {width: 128, height: 96}, [104, 177, 123, 0], false, false); + var blob = cv.blobFromImage(img, 1, {width: 192, height: 144}, [104, 117, 123, 0], false, false); netDet.setInput(blob); var out = netDet.forward(); @@ -186,16 +186,11 @@ function main() { document.getElementById('startStopButton').disabled = false; }; - -// Load opencv.js -cv['onRuntimeInitialized']=()=>{ - main(); -}; - +