From 5c70a2015f3c5bb3cbf6ddd09c5f3ca33575cd89 Mon Sep 17 00:00:00 2001 From: Dale Phurrough Date: Tue, 26 Jan 2021 18:32:20 +0100 Subject: [PATCH 1/7] fix python test runner wildcard handling * fix opencv/opencv#19402 --- modules/python/test/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/python/test/test.py b/modules/python/test/test.py index 97c2144303..a40c6c5d7e 100755 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -34,8 +34,8 @@ def load_tests(loader, tests, pattern): else: print('WARNING: OpenCV tests config file ({}) is missing, running subset of tests'.format(config_file)) - tests_pattern = os.environ.get('OPENCV_PYTEST_FILTER', 'test_') + '*.py' - if tests_pattern != 'test_*py': + tests_pattern = os.environ.get('OPENCV_PYTEST_FILTER', 'test_*') + '.py' + if tests_pattern != 'test_*.py': print('Tests filter: {}'.format(tests_pattern)) processed = set() From 3f14341629c59c7fbd08e29df5e93edbe6f34a11 Mon Sep 17 00:00:00 2001 From: Ixarias Date: Mon, 25 Jan 2021 13:34:57 -0600 Subject: [PATCH 2/7] Change Keymap wording for gray image in curve mode Instead of being a copy of line 76, line 79 instead correctly indicates that it will show a histogram for a gray image in curve mode, as given by the code block at line 103 referencing image "gray" instead of image "im". --- samples/python/hist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/python/hist.py b/samples/python/hist.py index 4e73f0bc65..4c2c1ad395 100755 --- a/samples/python/hist.py +++ b/samples/python/hist.py @@ -76,7 +76,7 @@ def main(): a - show histogram for color image in curve mode \n b - show histogram in bin mode \n c - show equalized histogram (always in bin mode) \n - d - show histogram for color image in curve mode \n + d - show histogram for gray image in curve mode \n e - show histogram for a normalized image in curve mode \n Esc - exit \n ''') From 449ebc1b704886bfe7e1e7204060c626278497a0 Mon Sep 17 00:00:00 2001 From: Anastasia Murzova Date: Wed, 27 Jan 2021 00:59:10 +0300 Subject: [PATCH 3/7] Corrected SSD text graph generation --- samples/dnn/tf_text_graph_ssd.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/dnn/tf_text_graph_ssd.py b/samples/dnn/tf_text_graph_ssd.py index 46a9064738..dbdee6ea9f 100644 --- a/samples/dnn/tf_text_graph_ssd.py +++ b/samples/dnn/tf_text_graph_ssd.py @@ -122,7 +122,6 @@ def createSSDGraph(modelPath, configPath, outputPath): print('Input image size: %dx%d' % (image_width, image_height)) # Read the graph. - _inpNames = ['image_tensor'] outNames = ['num_detections', 'detection_scores', 'detection_boxes', 'detection_classes'] writeTextGraph(modelPath, outputPath, outNames) @@ -247,6 +246,15 @@ def createSSDGraph(modelPath, configPath, outputPath): graph_def.node[1].input.append(graph_def.node[0].name) graph_def.node[1].input.append(weights) + # check and correct the case when preprocessing block is after input + preproc_id = "Preprocessor/" + if graph_def.node[2].name.startswith(preproc_id) and \ + graph_def.node[2].input[0].startswith(preproc_id): + + if not any(preproc_id in inp for inp in graph_def.node[3].input): + graph_def.node[3].input.insert(0, graph_def.node[2].name) + + # Create SSD postprocessing head ############################################### # Concatenate predictions of classes, predictions of bounding boxes and proposals. From e448f4f6efe23069a47b853b9f62f77cd4482996 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 29 Jan 2021 16:59:13 +0000 Subject: [PATCH 4/7] cmake: fix pylint/flake8 detection, update flake8 exclude --- CMakeLists.txt | 9 ++++++++- cmake/FindFlake8.cmake | 13 +++++++++---- cmake/FindPylint.cmake | 13 +++++++++---- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a15a7eb16..65933cdeef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -727,8 +727,15 @@ if(ENABLE_FLAKE8 AND PYTHON_DEFAULT_AVAILABLE) include("${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlake8.cmake") endif() if(FLAKE8_FOUND) + list(APPEND OPENCV_FLAKE8_EXCLUDES ".git" "__pycache__" "config.py" "*.config.py" "config-*.py") + list(APPEND OPENCV_FLAKE8_EXCLUDES "svgfig.py") # 3rdparty + if(NOT PYTHON3_VERSION_STRING VERSION_GREATER 3.6) + # Python 3.6+ (PEP 526): variable annotations (type hints) + list(APPEND OPENCV_FLAKE8_EXCLUDES "samples/dnn/dnn_model_runner/dnn_conversion/common/test/configs") + endif() + string(REPLACE ";" "," OPENCV_FLAKE8_EXCLUDES_STR "${OPENCV_FLAKE8_EXCLUDES}") add_custom_target(check_flake8 - COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='.git,__pycache__,*.config.py,svgfig.py' + COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='${OPENCV_FLAKE8_EXCLUDES_STR}' WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}" COMMENT "Running flake8" ) diff --git a/cmake/FindFlake8.cmake b/cmake/FindFlake8.cmake index b18225a011..8063571393 100644 --- a/cmake/FindFlake8.cmake +++ b/cmake/FindFlake8.cmake @@ -12,9 +12,11 @@ find_host_program(FLAKE8_EXECUTABLE flake8 PATHS /usr/bin) -if(FLAKE8_EXECUTABLE) - execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version OUTPUT_VARIABLE FLAKE8_VERSION_RAW ERROR_QUIET) - if(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])") +if(FLAKE8_EXECUTABLE AND NOT DEFINED FLAKE8_VERSION) + execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE FLAKE8_VERSION_RAW) + if(NOT _result EQUAL 0) + ocv_clear_vars(FLAKE8_EXECUTABLE FLAKE8_VERSION) + elseif(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])") set(FLAKE8_VERSION "${CMAKE_MATCH_1}") else() set(FLAKE8_VERSION "unknown") @@ -22,6 +24,9 @@ if(FLAKE8_EXECUTABLE) endif() include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8 DEFAULT_MSG FLAKE8_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8 + REQUIRED_VARS FLAKE8_EXECUTABLE + VERSION_VAR FLAKE8_VERSION +) mark_as_advanced(FLAKE8_EXECUTABLE FLAKE8_VERSION) diff --git a/cmake/FindPylint.cmake b/cmake/FindPylint.cmake index 7e26fe246e..5731ba493a 100644 --- a/cmake/FindPylint.cmake +++ b/cmake/FindPylint.cmake @@ -12,9 +12,11 @@ find_host_program(PYLINT_EXECUTABLE pylint PATHS /usr/bin) -if(PYLINT_EXECUTABLE) - execute_process(COMMAND ${PYLINT_EXECUTABLE} --version OUTPUT_VARIABLE PYLINT_VERSION_RAW ERROR_QUIET) - if(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])") +if(PYLINT_EXECUTABLE AND NOT DEFINED PYLINT_VERSION) + execute_process(COMMAND ${PYLINT_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE PYLINT_VERSION_RAW) + if(NOT _result EQUAL 0) + ocv_clear_vars(PYLINT_EXECUTABLE PYLINT_VERSION) + elseif(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])") set(PYLINT_VERSION "${CMAKE_MATCH_2}") else() set(PYLINT_VERSION "unknown") @@ -22,6 +24,9 @@ if(PYLINT_EXECUTABLE) endif() include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint DEFAULT_MSG PYLINT_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint + REQUIRED_VARS PYLINT_EXECUTABLE + VERSION_VAR PYLINT_VERSION +) mark_as_advanced(PYLINT_EXECUTABLE PYLINT_VERSION) From e2949c7d0ab982c045755fe695f744b85d7c1c28 Mon Sep 17 00:00:00 2001 From: Sergey Slashchinin Date: Tue, 8 Dec 2020 21:28:04 +0300 Subject: [PATCH 5/7] Align 3.4 branch with master --- modules/dnn/src/layers/convolution_layer.cpp | 3 +++ modules/dnn/src/layers/pooling_layer.cpp | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp index f131c023ab..ef1dc8f29a 100644 --- a/modules/dnn/src/layers/convolution_layer.cpp +++ b/modules/dnn/src/layers/convolution_layer.cpp @@ -117,6 +117,9 @@ public: { kernel_size.assign(1, kernel_size[0]); strides.assign(1, strides[0]); + dilations.assign(1, dilations[0]); + pads_begin.assign(1, pads_begin[0]); + pads_end.assign(1, pads_end[0]); } CV_Assert(weightShape.dims() == kernel_size.size() + 2); for (int i = 0; i < kernel_size.size(); i++) { diff --git a/modules/dnn/src/layers/pooling_layer.cpp b/modules/dnn/src/layers/pooling_layer.cpp index dbe2332b89..834493966f 100644 --- a/modules/dnn/src/layers/pooling_layer.cpp +++ b/modules/dnn/src/layers/pooling_layer.cpp @@ -167,14 +167,13 @@ public: if (inputs[0].dims == 3) { - //Pool1D - kernel_size.erase(kernel_size.begin() + 1); - strides.erase(strides.begin() + 1); - pads_begin.erase(pads_begin.begin() + 1); - pads_end.erase(pads_end.begin() + 1); + // Pool1D + kernel_size.assign(1, kernel_size[0]); + strides.assign(1, strides[0]); + pads_begin.assign(1, pads_begin[0]); + pads_end.assign(1, pads_end[0]); } - #ifdef HAVE_OPENCL poolOp.release(); #endif From c5bf15e009c79cf1470c3d99a1059220a2938d05 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sat, 30 Jan 2021 11:32:27 +0000 Subject: [PATCH 6/7] build: fix cv2.cpp compilation --- modules/core/include/opencv2/core/utils/tls.hpp | 4 +++- modules/python/src2/cv2.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/utils/tls.hpp b/modules/core/include/opencv2/core/utils/tls.hpp index b5f1138593..c0d2962cb8 100644 --- a/modules/core/include/opencv2/core/utils/tls.hpp +++ b/modules/core/include/opencv2/core/utils/tls.hpp @@ -5,7 +5,9 @@ #ifndef OPENCV_UTILS_TLS_HPP #define OPENCV_UTILS_TLS_HPP -#include +#ifndef OPENCV_CORE_UTILITY_H +#error "tls.hpp must be included after opencv2/core/utility.hpp or opencv2/core.hpp" +#endif namespace cv { diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 0a986c1a44..f0dcc38d0f 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -31,13 +31,14 @@ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include +#include "opencv2/opencv_modules.hpp" +#include "opencv2/core.hpp" #include "opencv2/core/utils/configuration.private.hpp" #include "opencv2/core/utils/logger.hpp" #include "opencv2/core/utils/tls.hpp" #include "pyopencv_generated_include.h" #include "opencv2/core/types_c.h" -#include "opencv2/opencv_modules.hpp" #include "pycompat.hpp" #include From 30bef20e228c3e0cae559150c03b93c735d2bfea Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 31 Jan 2021 00:12:51 +0000 Subject: [PATCH 7/7] js: fix SIMD build --- .../include/opencv2/core/hal/intrin_wasm.hpp | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/modules/core/include/opencv2/core/hal/intrin_wasm.hpp b/modules/core/include/opencv2/core/hal/intrin_wasm.hpp index 2f835bb9f8..b4178af8b7 100644 --- a/modules/core/include/opencv2/core/hal/intrin_wasm.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_wasm.hpp @@ -1266,8 +1266,9 @@ OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_sub_wrap, wasm_i8x16_sub) OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_sub_wrap, wasm_i8x16_sub) OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_sub_wrap, wasm_i16x8_sub) OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_sub_wrap, wasm_i16x8_sub) -#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) >= (2000000) +#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) >= (1039012) // details: https://github.com/opencv/opencv/issues/18097 ( https://github.com/emscripten-core/emscripten/issues/12018 ) +// 1.39.12: https://github.com/emscripten-core/emscripten/commit/cd801d0f110facfd694212a3c8b2ed2ffcd630e2 inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b) { uchar a_[16], b_[16]; @@ -1275,7 +1276,7 @@ inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b) wasm_v128_store(b_, b.val); for (int i = 0; i < 16; i++) a_[i] = (uchar)(a_[i] * b_[i]); - return wasm_v128_load(a_); + return v_uint8x16(wasm_v128_load(a_)); } inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b) { @@ -1284,7 +1285,7 @@ inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b) wasm_v128_store(b_, b.val); for (int i = 0; i < 16; i++) a_[i] = (schar)(a_[i] * b_[i]); - return wasm_v128_load(a_); + return v_int8x16(wasm_v128_load(a_)); } #else OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_mul_wrap, wasm_i8x16_mul) @@ -1757,8 +1758,8 @@ inline v_uint64x2 v_popcount(const v_uint64x2& a) uint64 a_[2], b_[2] = { 0 }; wasm_v128_store(a_, a.val); for (int i = 0; i < 16; i++) - b_[i / 8] += popCountTable[((uint8*)a_)[i]]; - return wasm_v128_load(b_); + b_[i / 8] += popCountTable[((uint8_t*)a_)[i]]; + return v_uint64x2(wasm_v128_load(b_)); } inline v_uint8x16 v_popcount(const v_int8x16& a) { return v_popcount(v_reinterpret_as_u8(a)); } @@ -1938,11 +1939,11 @@ inline v_int32x4 func(const v_float64x2& a) \ double a_[2]; \ wasm_v128_store(a_, a.val); \ int c_[4]; \ - c_[0] = cfunc(a_[i]); \ - c_[1] = cfunc(a_[i]); \ + c_[0] = cfunc(a_[0]); \ + c_[1] = cfunc(a_[1]); \ c_[2] = 0; \ c_[3] = 0; \ - return wasm_v128_load(c_); \ + return v_int32x4(wasm_v128_load(c_)); \ } OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_round, cvRound) @@ -1960,7 +1961,7 @@ inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) c_[1] = cvRound(a_[1]); c_[2] = cvRound(b_[0]); c_[3] = cvRound(b_[1]); - return wasm_v128_load(c_); + return v_int32x4(wasm_v128_load(c_)); } #define OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(_Tpvec, suffix) \ @@ -2461,7 +2462,7 @@ inline v_float32x4 v_cvt_f32(const v_float64x2& a) c_[1] = (float)(a_[1]); c_[2] = 0; c_[3] = 0; - return wasm_v128_load(c_); + return v_float32x4(wasm_v128_load(c_)); } inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) @@ -2474,7 +2475,7 @@ inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) c_[1] = (float)(a_[1]); c_[2] = (float)(b_[0]); c_[3] = (float)(b_[1]); - return wasm_v128_load(c_); + return v_float32x4(wasm_v128_load(c_)); } inline v_float64x2 v_cvt_f64(const v_int32x4& a) @@ -2488,7 +2489,7 @@ inline v_float64x2 v_cvt_f64(const v_int32x4& a) double c_[2]; c_[0] = (double)(a_[0]); c_[1] = (double)(a_[1]); - return wasm_v128_load(c_); + return v_float64x2(wasm_v128_load(c_)); #endif } @@ -2503,7 +2504,7 @@ inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) double c_[2]; c_[0] = (double)(a_[2]); c_[1] = (double)(a_[3]); - return wasm_v128_load(c_); + return v_float64x2(wasm_v128_load(c_)); #endif } @@ -2514,7 +2515,7 @@ inline v_float64x2 v_cvt_f64(const v_float32x4& a) double c_[2]; c_[0] = (double)(a_[0]); c_[1] = (double)(a_[1]); - return wasm_v128_load(c_); + return v_float64x2(wasm_v128_load(c_)); } inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) @@ -2524,7 +2525,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) double c_[2]; c_[0] = (double)(a_[2]); c_[1] = (double)(a_[3]); - return wasm_v128_load(c_); + return v_float64x2(wasm_v128_load(c_)); } inline v_float64x2 v_cvt_f64(const v_int64x2& a) @@ -2537,7 +2538,7 @@ inline v_float64x2 v_cvt_f64(const v_int64x2& a) double c_[2]; c_[0] = (double)(a_[0]); c_[1] = (double)(a_[1]); - return wasm_v128_load(c_); + return v_float64x2(wasm_v128_load(c_)); #endif } @@ -2757,7 +2758,7 @@ inline v_float32x4 v_load_expand(const float16_t* ptr) float a[4]; for (int i = 0; i < 4; i++) a[i] = ptr[i]; - return wasm_v128_load(a); + return v_float32x4(wasm_v128_load(a)); } inline void v_pack_store(float16_t* ptr, const v_float32x4& v)