Merge remote-tracking branch 'upstream/3.4' into merge-3.4

pull/19431/head
Alexander Alekhin 4 years ago
commit 2b787eb4b8
  1. 9
      CMakeLists.txt
  2. 13
      cmake/FindFlake8.cmake
  3. 13
      cmake/FindPylint.cmake
  4. 35
      modules/core/include/opencv2/core/hal/intrin_wasm.hpp
  5. 4
      modules/core/include/opencv2/core/utils/tls.hpp
  6. 3
      modules/python/src2/cv2.cpp
  7. 4
      modules/python/test/test.py
  8. 10
      samples/dnn/tf_text_graph_ssd.py
  9. 2
      samples/python/hist.py

@ -736,8 +736,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"
)

@ -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)

@ -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)

@ -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)

@ -5,7 +5,9 @@
#ifndef OPENCV_UTILS_TLS_HPP
#define OPENCV_UTILS_TLS_HPP
#include <opencv2/core/utility.hpp>
#ifndef OPENCV_CORE_UTILITY_H
#error "tls.hpp must be included after opencv2/core/utility.hpp or opencv2/core.hpp"
#endif
namespace cv {

@ -32,13 +32,14 @@
#include <numpy/ndarrayobject.h>
#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 <map>

@ -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()

@ -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.

@ -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
''')

Loading…
Cancel
Save