From ccb89a889a322f60c8fe73400a8f3dc929bcc6c7 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 31 Mar 2019 10:43:30 +0000 Subject: [PATCH 1/6] imgcodecs(bmp): limit size of processed images 2Gb+ images can't be handled properly by current implementation backporting of commit: 50a6f9d251bfe9c3aec6c977391f38a7b790fe4c --- modules/imgcodecs/src/grfmt_bmp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/imgcodecs/src/grfmt_bmp.cpp b/modules/imgcodecs/src/grfmt_bmp.cpp index 7018f8a16b..d626de1a54 100644 --- a/modules/imgcodecs/src/grfmt_bmp.cpp +++ b/modules/imgcodecs/src/grfmt_bmp.cpp @@ -203,6 +203,9 @@ bool BmpDecoder::readData( Mat& img ) int nch = color ? 3 : 1; int y, width3 = m_width*nch; + // FIXIT: use safe pointer arithmetic (avoid 'int'), use size_t, intptr_t, etc + CV_Assert(((uint64)m_height * m_width * nch < (CV_BIG_UINT(1) << 30)) && "BMP reader implementation doesn't support large images >= 1Gb"); + if( m_offset < 0 || !m_strm.isOpened()) return false; From a34c02a0019c8799cf817d160c5f6aed5bfc8a67 Mon Sep 17 00:00:00 2001 From: zuoshaobo Date: Tue, 2 Apr 2019 03:20:53 -0400 Subject: [PATCH 2/6] add support for tf.add_n operation --- modules/dnn/src/tensorflow/tf_importer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp index 480e8c7d29..9cca9e9b64 100644 --- a/modules/dnn/src/tensorflow/tf_importer.cpp +++ b/modules/dnn/src/tensorflow/tf_importer.cpp @@ -942,7 +942,7 @@ void TFImporter::populateNet(Net dstNet) if (getDataLayout(name, data_layouts) == DATA_LAYOUT_UNKNOWN) data_layouts[name] = DATA_LAYOUT_NHWC; } - else if (type == "BiasAdd" || type == "Add" || type == "Sub") + else if (type == "BiasAdd" || type == "Add" || type == "Sub" || type=="AddN") { bool haveConst = false; for(int ii = 0; !haveConst && ii < layer.input_size(); ++ii) From 07655c2b4de4e87e100d60cb9555ed2057e66372 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Tue, 2 Apr 2019 11:54:50 +0300 Subject: [PATCH 3/6] Fix build with IE > 2018R5 --- modules/dnn/test/test_ie_models.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/dnn/test/test_ie_models.cpp b/modules/dnn/test/test_ie_models.cpp index 77259d8b23..49262a5a32 100644 --- a/modules/dnn/test/test_ie_models.cpp +++ b/modules/dnn/test/test_ie_models.cpp @@ -178,12 +178,13 @@ TEST_P(DNNTestOpenVINO, models) Target target = (dnn::Target)(int)get<0>(GetParam()); std::string modelName = get<1>(GetParam()); std::string precision = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? "FP16" : "FP32"; + std::string prefix; #ifdef INF_ENGINE_RELEASE #if INF_ENGINE_RELEASE <= 2018050000 - std::string prefix = utils::fs::join("intel_models", - utils::fs::join(modelName, - utils::fs::join(precision, modelName))); + prefix = utils::fs::join("intel_models", + utils::fs::join(modelName, + utils::fs::join(precision, modelName))); #endif #endif From 2a2d195240b97fdcb603e4c4b82d6ef2c2bfba82 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 1 Apr 2019 17:30:10 +0300 Subject: [PATCH 4/6] cmake: don't add tests dirs as include directories - use relative paths for includes - fix PCH generation with GCC (dummy file has been used) --- cmake/OpenCVModule.cmake | 4 ++-- cmake/OpenCVPCHSupport.cmake | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 3c45d774cc..c2fda8fad6 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -1145,7 +1145,7 @@ function(ocv_add_perf_tests) source_group("Src" FILES "${${the_target}_pch}") ocv_add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch}) - ocv_target_include_modules(${the_target} ${perf_deps} "${perf_path}") + ocv_target_include_modules(${the_target} ${perf_deps}) ocv_target_link_libraries(${the_target} LINK_PRIVATE ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} ${OPENCV_PERF_${the_module}_DEPS}) add_dependencies(opencv_perf_tests ${the_target}) @@ -1227,7 +1227,7 @@ function(ocv_add_accuracy_tests) source_group("Src" FILES "${${the_target}_pch}") ocv_add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch}) - ocv_target_include_modules(${the_target} ${test_deps} "${test_path}") + ocv_target_include_modules(${the_target} ${test_deps}) if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test") ocv_target_include_directories(${the_target} "${CMAKE_CURRENT_BINARY_DIR}/test") endif() diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index f9b1b48b65..59bc826ed0 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -261,6 +261,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input) ) _PCH_GET_COMPILE_FLAGS(_compile_FLAGS) + list(APPEND _compile_FLAGS "${_PCH_include_prefix}\"${_path}\"") get_target_property(type ${_targetName} TYPE) if(type STREQUAL "SHARED_LIBRARY") From e3286c90551ec454770aa1813f165eded0a31a4c Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Tue, 2 Apr 2019 14:05:17 +0300 Subject: [PATCH 5/6] Enable 1x1 convolution optimization --- modules/dnn/src/layers/convolution_layer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp index b872130ccd..7aaa8bc989 100644 --- a/modules/dnn/src/layers/convolution_layer.cpp +++ b/modules/dnn/src/layers/convolution_layer.cpp @@ -606,7 +606,7 @@ public: int inpCnAll = input.size[1], width = input.size[3], height = input.size[2]; int inpCn = inpCnAll / ngroups; - p.is1x1_ = kernel == Size(0,0) && pad == Size(0, 0); + p.is1x1_ = kernel == Size(1,1) && pad == Size(0, 0); p.useAVX = checkHardwareSupport(CPU_AVX); p.useAVX2 = checkHardwareSupport(CPU_AVX2); p.useAVX512 = CV_CPU_HAS_SUPPORT_AVX512_SKX; From c4ec46c1954add1c8bb339f81dc185d69971ed25 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 31 Mar 2019 12:14:42 +0000 Subject: [PATCH 6/6] imgcodecs(sunras): avoid undefined shift backporting of commit: f2803aba07c1c522b409cce5390e757f54d7794d --- modules/imgcodecs/src/grfmt_sunras.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgcodecs/src/grfmt_sunras.cpp b/modules/imgcodecs/src/grfmt_sunras.cpp index 069566665a..487c99831a 100644 --- a/modules/imgcodecs/src/grfmt_sunras.cpp +++ b/modules/imgcodecs/src/grfmt_sunras.cpp @@ -90,7 +90,7 @@ bool SunRasterDecoder::readHeader() m_width = m_strm.getDWord(); m_height = m_strm.getDWord(); m_bpp = m_strm.getDWord(); - int palSize = 3*(1 << m_bpp); + int palSize = (m_bpp > 0 && m_bpp <= 8) ? (3*(1 << m_bpp)) : 0; m_strm.skip( 4 ); m_encoding = (SunRasType)m_strm.getDWord();