Skip to content

Commit 2b787eb

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents e250bae + 5ab4623 commit 2b787eb

File tree

9 files changed

+61
-32
lines changed

9 files changed

+61
-32
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,15 @@ if(ENABLE_FLAKE8 AND PYTHON_DEFAULT_AVAILABLE)
736736
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlake8.cmake")
737737
endif()
738738
if(FLAKE8_FOUND)
739+
list(APPEND OPENCV_FLAKE8_EXCLUDES ".git" "__pycache__" "config.py" "*.config.py" "config-*.py")
740+
list(APPEND OPENCV_FLAKE8_EXCLUDES "svgfig.py") # 3rdparty
741+
if(NOT PYTHON3_VERSION_STRING VERSION_GREATER 3.6)
742+
# Python 3.6+ (PEP 526): variable annotations (type hints)
743+
list(APPEND OPENCV_FLAKE8_EXCLUDES "samples/dnn/dnn_model_runner/dnn_conversion/common/test/configs")
744+
endif()
745+
string(REPLACE ";" "," OPENCV_FLAKE8_EXCLUDES_STR "${OPENCV_FLAKE8_EXCLUDES}")
739746
add_custom_target(check_flake8
740-
COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='.git,__pycache__,*.config.py,svgfig.py'
747+
COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='${OPENCV_FLAKE8_EXCLUDES_STR}'
741748
WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}"
742749
COMMENT "Running flake8"
743750
)

cmake/FindFlake8.cmake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212

1313
find_host_program(FLAKE8_EXECUTABLE flake8 PATHS /usr/bin)
1414

15-
if(FLAKE8_EXECUTABLE)
16-
execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version OUTPUT_VARIABLE FLAKE8_VERSION_RAW ERROR_QUIET)
17-
if(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])")
15+
if(FLAKE8_EXECUTABLE AND NOT DEFINED FLAKE8_VERSION)
16+
execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE FLAKE8_VERSION_RAW)
17+
if(NOT _result EQUAL 0)
18+
ocv_clear_vars(FLAKE8_EXECUTABLE FLAKE8_VERSION)
19+
elseif(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])")
1820
set(FLAKE8_VERSION "${CMAKE_MATCH_1}")
1921
else()
2022
set(FLAKE8_VERSION "unknown")
2123
endif()
2224
endif()
2325

2426
include(FindPackageHandleStandardArgs)
25-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8 DEFAULT_MSG FLAKE8_EXECUTABLE)
27+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8
28+
REQUIRED_VARS FLAKE8_EXECUTABLE
29+
VERSION_VAR FLAKE8_VERSION
30+
)
2631

2732
mark_as_advanced(FLAKE8_EXECUTABLE FLAKE8_VERSION)

cmake/FindPylint.cmake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212

1313
find_host_program(PYLINT_EXECUTABLE pylint PATHS /usr/bin)
1414

15-
if(PYLINT_EXECUTABLE)
16-
execute_process(COMMAND ${PYLINT_EXECUTABLE} --version OUTPUT_VARIABLE PYLINT_VERSION_RAW ERROR_QUIET)
17-
if(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])")
15+
if(PYLINT_EXECUTABLE AND NOT DEFINED PYLINT_VERSION)
16+
execute_process(COMMAND ${PYLINT_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE PYLINT_VERSION_RAW)
17+
if(NOT _result EQUAL 0)
18+
ocv_clear_vars(PYLINT_EXECUTABLE PYLINT_VERSION)
19+
elseif(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])")
1820
set(PYLINT_VERSION "${CMAKE_MATCH_2}")
1921
else()
2022
set(PYLINT_VERSION "unknown")
2123
endif()
2224
endif()
2325

2426
include(FindPackageHandleStandardArgs)
25-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint DEFAULT_MSG PYLINT_EXECUTABLE)
27+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint
28+
REQUIRED_VARS PYLINT_EXECUTABLE
29+
VERSION_VAR PYLINT_VERSION
30+
)
2631

2732
mark_as_advanced(PYLINT_EXECUTABLE PYLINT_VERSION)

modules/core/include/opencv2/core/hal/intrin_wasm.hpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,16 +1266,17 @@ OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_sub_wrap, wasm_i8x16_sub)
12661266
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_sub_wrap, wasm_i8x16_sub)
12671267
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_sub_wrap, wasm_i16x8_sub)
12681268
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_sub_wrap, wasm_i16x8_sub)
1269-
#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) >= (2000000)
1269+
#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) >= (1039012)
12701270
// details: https://github.com/opencv/opencv/issues/18097 ( https://github.com/emscripten-core/emscripten/issues/12018 )
1271+
// 1.39.12: https://github.com/emscripten-core/emscripten/commit/cd801d0f110facfd694212a3c8b2ed2ffcd630e2
12711272
inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b)
12721273
{
12731274
uchar a_[16], b_[16];
12741275
wasm_v128_store(a_, a.val);
12751276
wasm_v128_store(b_, b.val);
12761277
for (int i = 0; i < 16; i++)
12771278
a_[i] = (uchar)(a_[i] * b_[i]);
1278-
return wasm_v128_load(a_);
1279+
return v_uint8x16(wasm_v128_load(a_));
12791280
}
12801281
inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b)
12811282
{
@@ -1284,7 +1285,7 @@ inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b)
12841285
wasm_v128_store(b_, b.val);
12851286
for (int i = 0; i < 16; i++)
12861287
a_[i] = (schar)(a_[i] * b_[i]);
1287-
return wasm_v128_load(a_);
1288+
return v_int8x16(wasm_v128_load(a_));
12881289
}
12891290
#else
12901291
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)
17571758
uint64 a_[2], b_[2] = { 0 };
17581759
wasm_v128_store(a_, a.val);
17591760
for (int i = 0; i < 16; i++)
1760-
b_[i / 8] += popCountTable[((uint8*)a_)[i]];
1761-
return wasm_v128_load(b_);
1761+
b_[i / 8] += popCountTable[((uint8_t*)a_)[i]];
1762+
return v_uint64x2(wasm_v128_load(b_));
17621763
}
17631764
inline v_uint8x16 v_popcount(const v_int8x16& a)
17641765
{ return v_popcount(v_reinterpret_as_u8(a)); }
@@ -1938,11 +1939,11 @@ inline v_int32x4 func(const v_float64x2& a) \
19381939
double a_[2]; \
19391940
wasm_v128_store(a_, a.val); \
19401941
int c_[4]; \
1941-
c_[0] = cfunc(a_[i]); \
1942-
c_[1] = cfunc(a_[i]); \
1942+
c_[0] = cfunc(a_[0]); \
1943+
c_[1] = cfunc(a_[1]); \
19431944
c_[2] = 0; \
19441945
c_[3] = 0; \
1945-
return wasm_v128_load(c_); \
1946+
return v_int32x4(wasm_v128_load(c_)); \
19461947
}
19471948

19481949
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)
19601961
c_[1] = cvRound(a_[1]);
19611962
c_[2] = cvRound(b_[0]);
19621963
c_[3] = cvRound(b_[1]);
1963-
return wasm_v128_load(c_);
1964+
return v_int32x4(wasm_v128_load(c_));
19641965
}
19651966

19661967
#define OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(_Tpvec, suffix) \
@@ -2461,7 +2462,7 @@ inline v_float32x4 v_cvt_f32(const v_float64x2& a)
24612462
c_[1] = (float)(a_[1]);
24622463
c_[2] = 0;
24632464
c_[3] = 0;
2464-
return wasm_v128_load(c_);
2465+
return v_float32x4(wasm_v128_load(c_));
24652466
}
24662467

24672468
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)
24742475
c_[1] = (float)(a_[1]);
24752476
c_[2] = (float)(b_[0]);
24762477
c_[3] = (float)(b_[1]);
2477-
return wasm_v128_load(c_);
2478+
return v_float32x4(wasm_v128_load(c_));
24782479
}
24792480

24802481
inline v_float64x2 v_cvt_f64(const v_int32x4& a)
@@ -2488,7 +2489,7 @@ inline v_float64x2 v_cvt_f64(const v_int32x4& a)
24882489
double c_[2];
24892490
c_[0] = (double)(a_[0]);
24902491
c_[1] = (double)(a_[1]);
2491-
return wasm_v128_load(c_);
2492+
return v_float64x2(wasm_v128_load(c_));
24922493
#endif
24932494
}
24942495

@@ -2503,7 +2504,7 @@ inline v_float64x2 v_cvt_f64_high(const v_int32x4& a)
25032504
double c_[2];
25042505
c_[0] = (double)(a_[2]);
25052506
c_[1] = (double)(a_[3]);
2506-
return wasm_v128_load(c_);
2507+
return v_float64x2(wasm_v128_load(c_));
25072508
#endif
25082509
}
25092510

@@ -2514,7 +2515,7 @@ inline v_float64x2 v_cvt_f64(const v_float32x4& a)
25142515
double c_[2];
25152516
c_[0] = (double)(a_[0]);
25162517
c_[1] = (double)(a_[1]);
2517-
return wasm_v128_load(c_);
2518+
return v_float64x2(wasm_v128_load(c_));
25182519
}
25192520

25202521
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)
25242525
double c_[2];
25252526
c_[0] = (double)(a_[2]);
25262527
c_[1] = (double)(a_[3]);
2527-
return wasm_v128_load(c_);
2528+
return v_float64x2(wasm_v128_load(c_));
25282529
}
25292530

25302531
inline v_float64x2 v_cvt_f64(const v_int64x2& a)
@@ -2537,7 +2538,7 @@ inline v_float64x2 v_cvt_f64(const v_int64x2& a)
25372538
double c_[2];
25382539
c_[0] = (double)(a_[0]);
25392540
c_[1] = (double)(a_[1]);
2540-
return wasm_v128_load(c_);
2541+
return v_float64x2(wasm_v128_load(c_));
25412542
#endif
25422543
}
25432544

@@ -2757,7 +2758,7 @@ inline v_float32x4 v_load_expand(const float16_t* ptr)
27572758
float a[4];
27582759
for (int i = 0; i < 4; i++)
27592760
a[i] = ptr[i];
2760-
return wasm_v128_load(a);
2761+
return v_float32x4(wasm_v128_load(a));
27612762
}
27622763

27632764
inline void v_pack_store(float16_t* ptr, const v_float32x4& v)

modules/core/include/opencv2/core/utils/tls.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#ifndef OPENCV_UTILS_TLS_HPP
66
#define OPENCV_UTILS_TLS_HPP
77

8-
#include <opencv2/core/utility.hpp>
8+
#ifndef OPENCV_CORE_UTILITY_H
9+
#error "tls.hpp must be included after opencv2/core/utility.hpp or opencv2/core.hpp"
10+
#endif
911

1012
namespace cv {
1113

modules/python/src2/cv2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232

3333
#include <numpy/ndarrayobject.h>
3434

35+
#include "opencv2/opencv_modules.hpp"
36+
#include "opencv2/core.hpp"
3537
#include "opencv2/core/utils/configuration.private.hpp"
3638
#include "opencv2/core/utils/logger.hpp"
3739
#include "opencv2/core/utils/tls.hpp"
3840

3941
#include "pyopencv_generated_include.h"
4042
#include "opencv2/core/types_c.h"
41-
#include "opencv2/opencv_modules.hpp"
4243
#include "pycompat.hpp"
4344
#include <map>
4445

modules/python/test/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def load_tests(loader, tests, pattern):
3434
else:
3535
print('WARNING: OpenCV tests config file ({}) is missing, running subset of tests'.format(config_file))
3636

37-
tests_pattern = os.environ.get('OPENCV_PYTEST_FILTER', 'test_') + '*.py'
38-
if tests_pattern != 'test_*py':
37+
tests_pattern = os.environ.get('OPENCV_PYTEST_FILTER', 'test_*') + '.py'
38+
if tests_pattern != 'test_*.py':
3939
print('Tests filter: {}'.format(tests_pattern))
4040

4141
processed = set()

samples/dnn/tf_text_graph_ssd.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def createSSDGraph(modelPath, configPath, outputPath):
122122
print('Input image size: %dx%d' % (image_width, image_height))
123123

124124
# Read the graph.
125-
_inpNames = ['image_tensor']
126125
outNames = ['num_detections', 'detection_scores', 'detection_boxes', 'detection_classes']
127126

128127
writeTextGraph(modelPath, outputPath, outNames)
@@ -247,6 +246,15 @@ def to_remove(name, op):
247246
graph_def.node[1].input.append(graph_def.node[0].name)
248247
graph_def.node[1].input.append(weights)
249248

249+
# check and correct the case when preprocessing block is after input
250+
preproc_id = "Preprocessor/"
251+
if graph_def.node[2].name.startswith(preproc_id) and \
252+
graph_def.node[2].input[0].startswith(preproc_id):
253+
254+
if not any(preproc_id in inp for inp in graph_def.node[3].input):
255+
graph_def.node[3].input.insert(0, graph_def.node[2].name)
256+
257+
250258
# Create SSD postprocessing head ###############################################
251259

252260
# Concatenate predictions of classes, predictions of bounding boxes and proposals.

samples/python/hist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def main():
7676
a - show histogram for color image in curve mode \n
7777
b - show histogram in bin mode \n
7878
c - show equalized histogram (always in bin mode) \n
79-
d - show histogram for color image in curve mode \n
79+
d - show histogram for gray image in curve mode \n
8080
e - show histogram for a normalized image in curve mode \n
8181
Esc - exit \n
8282
''')

0 commit comments

Comments
 (0)