From ed9bca969ce5930e38122c8ea22d28e29d517471 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 26 Sep 2019 20:00:30 +0300 Subject: [PATCH 1/9] core: fix UBSAN in softfloat --- modules/core/src/softfloat.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/core/src/softfloat.cpp b/modules/core/src/softfloat.cpp index 27a247a444..a876ee14e2 100644 --- a/modules/core/src/softfloat.cpp +++ b/modules/core/src/softfloat.cpp @@ -2065,13 +2065,17 @@ static int_fast64_t f64_to_i64(float64_t a, uint_fast8_t roundingMode, bool exac if (exp) sig |= UINT64_C(0x0010000000000000); shiftDist = 0x433 - exp; if (shiftDist <= 0) { - uint_fast64_t z = sig << -shiftDist; - if ((shiftDist < -11) || (z & UINT64_C(0x8000000000000000))) + bool isValid = shiftDist >= -11; + if (isValid) { - raiseFlags(flag_invalid); - return sign ? i64_fromNegOverflow : i64_fromPosOverflow; + uint_fast64_t z = sig << -shiftDist; + if (0 == (z & UINT64_C(0x8000000000000000))) + { + return sign ? -(int_fast64_t)z : (int_fast64_t)z; + } } - return sign ? -(int_fast64_t)z : (int_fast64_t)z; + raiseFlags(flag_invalid); + return sign ? i64_fromNegOverflow : i64_fromPosOverflow; } else { if (shiftDist < 64) From 2b66495a9db0b7512655225b30fdb01152acca1d Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 2 Sep 2019 15:35:35 +0300 Subject: [PATCH 2/9] dnn: use OpenVINO 2019R3 defines --- cmake/OpenCVDetectInferenceEngine.cmake | 4 ++-- modules/dnn/src/op_inf_engine.hpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/OpenCVDetectInferenceEngine.cmake b/cmake/OpenCVDetectInferenceEngine.cmake index fb49ee6ff4..1302489c20 100644 --- a/cmake/OpenCVDetectInferenceEngine.cmake +++ b/cmake/OpenCVDetectInferenceEngine.cmake @@ -87,9 +87,9 @@ endif() if(INF_ENGINE_TARGET) if(NOT INF_ENGINE_RELEASE) - message(WARNING "InferenceEngine version have not been set, 2019R2 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.") + message(WARNING "InferenceEngine version have not been set, 2019R3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.") endif() - set(INF_ENGINE_RELEASE "2019020000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)") + set(INF_ENGINE_RELEASE "2019030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)") set_target_properties(${INF_ENGINE_TARGET} PROPERTIES INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}" ) diff --git a/modules/dnn/src/op_inf_engine.hpp b/modules/dnn/src/op_inf_engine.hpp index 68d0546f06..b025ab05bf 100644 --- a/modules/dnn/src/op_inf_engine.hpp +++ b/modules/dnn/src/op_inf_engine.hpp @@ -22,10 +22,11 @@ #define INF_ENGINE_RELEASE_2018R5 2018050000 #define INF_ENGINE_RELEASE_2019R1 2019010000 #define INF_ENGINE_RELEASE_2019R2 2019020000 +#define INF_ENGINE_RELEASE_2019R3 2019030000 #ifndef INF_ENGINE_RELEASE -#warning("IE version have not been provided via command-line. Using 2019R2 by default") -#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R2 +#warning("IE version have not been provided via command-line. Using 2019R3 by default") +#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R3 #endif #define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000)) From c69245da1f4f37097fe22501023552ac3eb686f5 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 3 Oct 2019 20:45:43 +0000 Subject: [PATCH 3/9] imgproc: fix fitLine() implementation - update optimal solutions on each iteration --- .../imgproc/misc/java/test/ImgprocTest.java | 2 +- modules/imgproc/src/linefit.cpp | 19 +++++++--- modules/imgproc/test/test_convhull.cpp | 35 +++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/modules/imgproc/misc/java/test/ImgprocTest.java b/modules/imgproc/misc/java/test/ImgprocTest.java index ca23ee35b3..52da455993 100644 --- a/modules/imgproc/misc/java/test/ImgprocTest.java +++ b/modules/imgproc/misc/java/test/ImgprocTest.java @@ -807,7 +807,7 @@ public class ImgprocTest extends OpenCVTestCase { points.put(0, 0, 0, 0, 2, 3, 3, 4, 5, 8); Mat linePoints = new Mat(4, 1, CvType.CV_32FC1); - linePoints.put(0, 0, 0.53196341, 0.84676737, 2.496531, 3.7467217); + linePoints.put(0, 0, 0.53198653, 0.84675282, 2.5, 3.75); Imgproc.fitLine(points, dst, Imgproc.CV_DIST_L12, 0, 0.01, 0.01); diff --git a/modules/imgproc/src/linefit.cpp b/modules/imgproc/src/linefit.cpp index 1abde1e0d1..97e0d2961a 100644 --- a/modules/imgproc/src/linefit.cpp +++ b/modules/imgproc/src/linefit.cpp @@ -408,8 +408,14 @@ static void fitLine2D( const Point2f * points, int count, int dist, } /* calculate distances */ err = calcDist2D( points, count, _line, r ); - if( err < EPS ) - break; + + if (err < min_err) + { + min_err = err; + memcpy(line, _line, 4 * sizeof(line[0])); + if (err < EPS) + break; + } /* calculate weights */ if( calc_weights ) @@ -550,8 +556,13 @@ static void fitLine3D( Point3f * points, int count, int dist, } /* calculate distances */ err = calcDist3D( points, count, _line, r ); - //if( err < FLT_EPSILON*count ) - // break; + if (err < min_err) + { + min_err = err; + memcpy(line, _line, 6 * sizeof(line[0])); + if (err < EPS) + break; + } /* calculate weights */ if( calc_weights ) diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index 3f82e04524..3f12140328 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -1609,6 +1609,8 @@ int CV_FitLineTest::validate_test_results( int test_case_idx ) int k, max_k = 0; double vec_diff = 0, t; + //std::cout << dims << " " << Mat(1, dims*2, CV_32FC1, line.data()) << " " << Mat(1, dims, CV_32FC1, line0.data()) << std::endl; + for( k = 0; k < dims*2; k++ ) { if( cvIsNaN(line[k]) || cvIsInf(line[k]) ) @@ -2038,5 +2040,38 @@ INSTANTIATE_TEST_CASE_P(Imgproc, ConvexityDefects_regression_5908, testing::Values(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) )); +TEST(Imgproc_FitLine, regression_15083) +{ + int points2i_[] = { + 432, 654, + 370, 656, + 390, 656, + 410, 656, + 348, 658 + }; + Mat points(5, 1, CV_32SC2, points2i_); + + Vec4f lineParam; + fitLine(points, lineParam, DIST_L1, 0, 0.01, 0.01); + EXPECT_GE(fabs(lineParam[0]), fabs(lineParam[1]) * 4) << lineParam; +} + +TEST(Imgproc_FitLine, regression_4903) +{ + float points2f_[] = { + 1224.0, 576.0, + 1234.0, 683.0, + 1215.0, 471.0, + 1184.0, 137.0, + 1079.0, 377.0, + 1239.0, 788.0, + }; + Mat points(6, 1, CV_32FC2, points2f_); + + Vec4f lineParam; + fitLine(points, lineParam, DIST_WELSCH, 0, 0.01, 0.01); + EXPECT_GE(fabs(lineParam[1]), fabs(lineParam[0]) * 4) << lineParam; +} + }} // namespace /* End of file. */ From c99db2b9db2b0a26535401a5131c4d5b7034534b Mon Sep 17 00:00:00 2001 From: APrigarina Date: Fri, 4 Oct 2019 11:47:56 +0300 Subject: [PATCH 4/9] bug fix --- modules/objdetect/src/qrcode.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/modules/objdetect/src/qrcode.cpp b/modules/objdetect/src/qrcode.cpp index 4c52e9de17..88929b0820 100644 --- a/modules/objdetect/src/qrcode.cpp +++ b/modules/objdetect/src/qrcode.cpp @@ -359,22 +359,26 @@ bool QRDetect::localization() bool suare_flag = false, local_points_flag = false; double triangle_sides[3]; - triangle_sides[0] = norm(localization_points[0] - localization_points[1]); - triangle_sides[1] = norm(localization_points[1] - localization_points[2]); - triangle_sides[2] = norm(localization_points[2] - localization_points[0]); - - double triangle_perim = (triangle_sides[0] + triangle_sides[1] + triangle_sides[2]) / 2; - - double square_area = sqrt((triangle_perim * (triangle_perim - triangle_sides[0]) - * (triangle_perim - triangle_sides[1]) - * (triangle_perim - triangle_sides[2]))) * 2; - double img_square_area = bin_barcode.cols * bin_barcode.rows; - - if (square_area > (img_square_area * 0.2)) + double triangle_perim, square_area, img_square_area; + if (localization_points.size() == 3) { - suare_flag = true; + triangle_sides[0] = norm(localization_points[0] - localization_points[1]); + triangle_sides[1] = norm(localization_points[1] - localization_points[2]); + triangle_sides[2] = norm(localization_points[2] - localization_points[0]); + + triangle_perim = (triangle_sides[0] + triangle_sides[1] + triangle_sides[2]) / 2; + + square_area = sqrt((triangle_perim * (triangle_perim - triangle_sides[0]) + * (triangle_perim - triangle_sides[1]) + * (triangle_perim - triangle_sides[2]))) * 2; + img_square_area = bin_barcode.cols * bin_barcode.rows; + + if (square_area > (img_square_area * 0.2)) + { + suare_flag = true; + } } - if (localization_points.size() != 3) + else { local_points_flag = true; } From fd11e3a81d6347e8dfe5b04f41dee315327f8005 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 4 Oct 2019 07:29:27 +0000 Subject: [PATCH 5/9] dnn: update IE tests --- modules/dnn/test/test_common.hpp | 1 + modules/dnn/test/test_common.impl.hpp | 2 ++ modules/dnn/test/test_halide_layers.cpp | 4 ++-- modules/dnn/test/test_onnx_importer.cpp | 11 ++++++++++- modules/dnn/test/test_tf_importer.cpp | 6 +++--- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/dnn/test/test_common.hpp b/modules/dnn/test/test_common.hpp index d504a316b5..3842d64be0 100644 --- a/modules/dnn/test/test_common.hpp +++ b/modules/dnn/test/test_common.hpp @@ -19,6 +19,7 @@ #define CV_TEST_TAG_DNN_SKIP_IE_2019R1 "dnn_skip_ie_2019r1" #define CV_TEST_TAG_DNN_SKIP_IE_2019R1_1 "dnn_skip_ie_2019r1_1" #define CV_TEST_TAG_DNN_SKIP_IE_2019R2 "dnn_skip_ie_2019r2" +#define CV_TEST_TAG_DNN_SKIP_IE_2019R3 "dnn_skip_ie_2019r3" #define CV_TEST_TAG_DNN_SKIP_IE_OPENCL "dnn_skip_ie_ocl" #define CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16 "dnn_skip_ie_ocl_fp16" #define CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_2 "dnn_skip_ie_myriad2" diff --git a/modules/dnn/test/test_common.impl.hpp b/modules/dnn/test/test_common.impl.hpp index 4b19a6a025..fee39cce68 100644 --- a/modules/dnn/test/test_common.impl.hpp +++ b/modules/dnn/test/test_common.impl.hpp @@ -315,6 +315,8 @@ void initDNNTests() # endif #elif INF_ENGINE_VER_MAJOR_EQ(2019020000) CV_TEST_TAG_DNN_SKIP_IE_2019R2, +#elif INF_ENGINE_VER_MAJOR_EQ(2019030000) + CV_TEST_TAG_DNN_SKIP_IE_2019R3, #endif CV_TEST_TAG_DNN_SKIP_IE ); diff --git a/modules/dnn/test/test_halide_layers.cpp b/modules/dnn/test/test_halide_layers.cpp index 6c21be3cde..0cee157b15 100644 --- a/modules/dnn/test/test_halide_layers.cpp +++ b/modules/dnn/test/test_halide_layers.cpp @@ -554,9 +554,9 @@ TEST_P(ReLU, Accuracy) Backend backendId = get<0>(get<1>(GetParam())); Target targetId = get<1>(get<1>(GetParam())); -#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000) +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019020000) if (backendId == DNN_BACKEND_INFERENCE_ENGINE && targetId == DNN_TARGET_MYRIAD && negativeSlope < 0) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2); + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_2019R3, CV_TEST_TAG_DNN_SKIP_IE_2019R2, CV_TEST_TAG_DNN_SKIP_IE); #endif LayerParams lp; diff --git a/modules/dnn/test/test_onnx_importer.cpp b/modules/dnn/test/test_onnx_importer.cpp index e71a4d6d31..248f61751a 100644 --- a/modules/dnn/test/test_onnx_importer.cpp +++ b/modules/dnn/test/test_onnx_importer.cpp @@ -422,13 +422,22 @@ TEST_P(Test_ONNX_nets, Googlenet) TEST_P(Test_ONNX_nets, CaffeNet) { applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB); +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000) + if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD + && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_2019R3); +#endif testONNXModels("caffenet", pb); } TEST_P(Test_ONNX_nets, RCNN_ILSVRC13) { applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB); - +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000) + if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD + && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_2019R3); +#endif // Reference output values are in range [-4.992, -1.161] testONNXModels("rcnn_ilsvrc13", pb, 0.0045); } diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index 436256f991..ea8cd15659 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -146,13 +146,13 @@ TEST_P(Test_TensorFlow_layers, padding) runTensorFlowNet("padding_valid"); runTensorFlowNet("spatial_padding"); runTensorFlowNet("mirror_pad"); -#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000) +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019020000) if (backend == DNN_BACKEND_INFERENCE_ENGINE) { if (target == DNN_TARGET_MYRIAD) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_2019R2); + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_2019R3, CV_TEST_TAG_DNN_SKIP_IE_2019R2); if (target == DNN_TARGET_OPENCL_FP16) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_2019R2); + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_2019R3, CV_TEST_TAG_DNN_SKIP_IE_2019R2); } #endif runTensorFlowNet("keras_pad_concat"); From e35fd463e71a0cc6c517a27d15d7ec7530d51e5f Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Wed, 2 Oct 2019 14:05:41 +0300 Subject: [PATCH 6/9] Enable ENet with Inference Engine backend on CPU --- modules/dnn/src/layers/pooling_layer.cpp | 2 ++ modules/dnn/test/test_onnx_importer.cpp | 6 +++--- modules/dnn/test/test_torch_importer.cpp | 12 +++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/dnn/src/layers/pooling_layer.cpp b/modules/dnn/src/layers/pooling_layer.cpp index 060bf9674e..380178d576 100644 --- a/modules/dnn/src/layers/pooling_layer.cpp +++ b/modules/dnn/src/layers/pooling_layer.cpp @@ -162,6 +162,8 @@ public: { if (backendId == DNN_BACKEND_INFERENCE_ENGINE) { + if (computeMaxIdx) + return false; #ifdef HAVE_INF_ENGINE if (kernel_size.size() == 3) return preferableTarget == DNN_TARGET_CPU; diff --git a/modules/dnn/test/test_onnx_importer.cpp b/modules/dnn/test/test_onnx_importer.cpp index e71a4d6d31..0d92c8d75c 100644 --- a/modules/dnn/test/test_onnx_importer.cpp +++ b/modules/dnn/test/test_onnx_importer.cpp @@ -86,8 +86,8 @@ TEST_P(Test_ONNX_layers, InstanceNorm) TEST_P(Test_ONNX_layers, MaxPooling) { - testONNXModels("maxpooling"); - testONNXModels("two_maxpooling"); + testONNXModels("maxpooling", npy, 0, 0, false, false); + testONNXModels("two_maxpooling", npy, 0, 0, false, false); } TEST_P(Test_ONNX_layers, Convolution) @@ -212,7 +212,7 @@ TEST_P(Test_ONNX_layers, MaxPooling3D) #endif if (target != DNN_TARGET_CPU) throw SkipTestException("Only CPU is supported"); - testONNXModels("max_pool3d"); + testONNXModels("max_pool3d", npy, 0, 0, false, false); } TEST_P(Test_ONNX_layers, AvePooling3D) diff --git a/modules/dnn/test/test_torch_importer.cpp b/modules/dnn/test/test_torch_importer.cpp index de81093d8d..3e0ab75bee 100644 --- a/modules/dnn/test/test_torch_importer.cpp +++ b/modules/dnn/test/test_torch_importer.cpp @@ -337,9 +337,15 @@ TEST_P(Test_Torch_nets, ENet_accuracy) { applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB); checkBackend(); - if (backend == DNN_BACKEND_INFERENCE_ENGINE || - (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)) - applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16); + if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) + throw SkipTestException(""); + if (backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU) + { + if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16); + if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL); + if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD); + throw SkipTestException(""); + } Net net; { From ab5252c18e778bd65b0e608618d8e498381ef13d Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 4 Oct 2019 18:35:11 +0300 Subject: [PATCH 7/9] dnn(pytest): backport changes from master, update test setUp() --- modules/dnn/misc/python/test/test_dnn.py | 44 +++++++++++++++--------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/modules/dnn/misc/python/test/test_dnn.py b/modules/dnn/misc/python/test/test_dnn.py index c07f8b9591..8346297c39 100644 --- a/modules/dnn/misc/python/test/test_dnn.py +++ b/modules/dnn/misc/python/test/test_dnn.py @@ -21,15 +21,11 @@ def box2str(box): width, height = box[2] - left, box[3] - top return '[%f x %f from (%f, %f)]' % (width, height, left, top) -def normAssertDetections(test, ref, out, confThreshold=0.0, scores_diff=1e-5, boxes_iou_diff=1e-4): - ref = np.array(ref, np.float32) - refClassIds, testClassIds = ref[:, 1], out[:, 1] - refScores, testScores = ref[:, 2], out[:, 2] - refBoxes, testBoxes = ref[:, 3:], out[:, 3:] - +def normAssertDetections(test, refClassIds, refScores, refBoxes, testClassIds, testScores, testBoxes, + confThreshold=0.0, scores_diff=1e-5, boxes_iou_diff=1e-4): matchedRefBoxes = [False] * len(refBoxes) errMsg = '' - for i in range(len(refBoxes)): + for i in range(len(testBoxes)): testScore = testScores[i] if testScore < confThreshold: continue @@ -66,12 +62,21 @@ def printParams(backend, target): } print('%s/%s' % (backendNames[backend], targetNames[target])) +testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) + +g_dnnBackendsAndTargets = None class dnn_test(NewOpenCVTests): def setUp(self): super(dnn_test, self).setUp() + global g_dnnBackendsAndTargets + if g_dnnBackendsAndTargets is None: + g_dnnBackendsAndTargets = self.initBackendsAndTargets() + self.dnnBackendsAndTargets = g_dnnBackendsAndTargets + + def initBackendsAndTargets(self): self.dnnBackendsAndTargets = [ [cv.dnn.DNN_BACKEND_OPENCV, cv.dnn.DNN_TARGET_CPU], ] @@ -89,15 +94,18 @@ class dnn_test(NewOpenCVTests): self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL]) if self.checkIETarget(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16): self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16]) + return self.dnnBackendsAndTargets def find_dnn_file(self, filename, required=True): + if not required: + required = testdata_required return self.find_file(filename, [os.environ.get('OPENCV_DNN_TEST_DATA_PATH', os.getcwd()), os.environ['OPENCV_TEST_DATA_PATH']], required=required) def checkIETarget(self, backend, target): - proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt', required=True) - model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel', required=True) + proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt') + model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel') net = cv.dnn.readNet(proto, model) net.setPreferableBackend(backend) net.setPreferableTarget(target) @@ -137,9 +145,8 @@ class dnn_test(NewOpenCVTests): def test_face_detection(self): - testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) - proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt', required=testdata_required) - model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=testdata_required) + proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt') + model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False) if proto is None or model is None: raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") @@ -166,13 +173,18 @@ class dnn_test(NewOpenCVTests): scoresDiff = 4e-3 if target in [cv.dnn.DNN_TARGET_OPENCL_FP16, cv.dnn.DNN_TARGET_MYRIAD] else 1e-5 iouDiff = 2e-2 if target in [cv.dnn.DNN_TARGET_OPENCL_FP16, cv.dnn.DNN_TARGET_MYRIAD] else 1e-4 - normAssertDetections(self, ref, out, 0.5, scoresDiff, iouDiff) + ref = np.array(ref, np.float32) + refClassIds, testClassIds = ref[:, 1], out[:, 1] + refScores, testScores = ref[:, 2], out[:, 2] + refBoxes, testBoxes = ref[:, 3:], out[:, 3:] + + normAssertDetections(self, refClassIds, refScores, refBoxes, testClassIds, + testScores, testBoxes, 0.5, scoresDiff, iouDiff) def test_async(self): timeout = 10*1000*10**6 # in nanoseconds (10 sec) - testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) - proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt', required=testdata_required) - model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel', required=testdata_required) + proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt') + model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel') if proto is None or model is None: raise unittest.SkipTest("Missing DNN test files (dnn/layers/layer_convolution.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") From bdc097495a133caf3131da429861d8ffcf758c9b Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sat, 5 Oct 2019 10:39:35 +0000 Subject: [PATCH 8/9] fix avx512 detection - renamed Cascade Lake AVX512_CEL => AVX512_CLX (align with Intel SDE tool) - fixed CLX instruction sets (no IFMA/VBMI) - added flag to bypass CPU baseline check: OPENCV_SKIP_CPU_BASELINE_CHECK --- cmake/OpenCVCompilerOptimizations.cmake | 20 ++++++----- .../{cpu_avx512cel.cpp => cpu_avx512clx.cpp} | 6 ++-- cmake/checks/cpu_avx512icl.cpp | 7 ++-- .../include/opencv2/core/cv_cpu_dispatch.h | 14 +++++--- .../core/include/opencv2/core/cv_cpu_helper.h | 36 +++++++++---------- modules/core/include/opencv2/core/cvdef.h | 4 +-- modules/core/src/system.cpp | 27 +++++++++----- 7 files changed, 67 insertions(+), 47 deletions(-) rename cmake/checks/{cpu_avx512cel.cpp => cpu_avx512clx.cpp} (50%) diff --git a/cmake/OpenCVCompilerOptimizations.cmake b/cmake/OpenCVCompilerOptimizations.cmake index 28867f8608..6389b19894 100644 --- a/cmake/OpenCVCompilerOptimizations.cmake +++ b/cmake/OpenCVCompilerOptimizations.cmake @@ -5,13 +5,15 @@ # AVX / AVX2 / AVX_512F # FMA3 # +# AVX512 details: https://en.wikipedia.org/wiki/AVX-512#CPUs_with_AVX-512 +# # CPU features groups: # AVX512_COMMON (Common instructions AVX-512F/CD for all CPUs that support AVX-512) # AVX512_KNL (Knights Landing with AVX-512F/CD/ER/PF) # AVX512_KNM (Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ) # AVX512_SKX (Skylake-X with AVX-512F/CD/BW/DQ/VL) # AVX512_CNL (Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI) -# AVX512_CEL (Cascade Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI) +# AVX512_CLX (Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI) # AVX512_ICL (Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ/VPCLMULQDQ*/GFNI*/VAES*) # ppc64le arch: @@ -43,7 +45,7 @@ # CPU_{opt}_ENABLED_DEFAULT=ON/OFF - has compiler support without additional flag (CPU_BASELINE_DETECT=ON only) set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F") -list(APPEND CPU_ALL_OPTIMIZATIONS "AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CEL;AVX512_ICL") +list(APPEND CPU_ALL_OPTIMIZATIONS "AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CLX;AVX512_ICL") list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16) list(APPEND CPU_ALL_OPTIMIZATIONS MSA) list(APPEND CPU_ALL_OPTIMIZATIONS VSX VSX3) @@ -163,15 +165,15 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ") endif() if(X86 OR X86_64) - ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F;AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CEL;AVX512_ICL") + ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F;AVX512_COMMON;AVX512_KNL;AVX512_KNM;AVX512_SKX;AVX512_CNL;AVX512_CLX;AVX512_ICL") ocv_update(CPU_AVX512_COMMON_GROUP "AVX_512F;AVX_512CD") ocv_update(CPU_AVX512_KNL_GROUP "AVX512_COMMON;AVX512_KNL_EXTRA") ocv_update(CPU_AVX512_KNM_GROUP "AVX512_KNL;AVX512_KNM_EXTRA;AVX_512VPOPCNTDQ") ocv_update(CPU_AVX512_SKX_GROUP "AVX512_COMMON;AVX_512VL;AVX_512BW;AVX_512DQ") ocv_update(CPU_AVX512_CNL_GROUP "AVX512_SKX;AVX_512IFMA;AVX_512VBMI") - ocv_update(CPU_AVX512_CEL_GROUP "AVX512_CNL;AVX_512VNNI") - ocv_update(CPU_AVX512_ICL_GROUP "AVX512_CEL;AVX_512VBMI2;AVX_512BITALG;AVX_512VPOPCNTDQ") # ? VPCLMULQDQ, GFNI, VAES + ocv_update(CPU_AVX512_CLX_GROUP "AVX512_SKX;AVX_512VNNI") + ocv_update(CPU_AVX512_ICL_GROUP "AVX512_SKX;AVX_512IFMA;AVX_512VBMI;AVX_512VNNI;AVX_512VBMI2;AVX_512BITALG;AVX_512VPOPCNTDQ") # ? VPCLMULQDQ, GFNI, VAES ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp") ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp") @@ -189,12 +191,12 @@ if(X86 OR X86_64) ocv_update(CPU_AVX512_KNM_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512knm.cpp") ocv_update(CPU_AVX512_SKX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512skx.cpp") ocv_update(CPU_AVX512_CNL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512cnl.cpp") - ocv_update(CPU_AVX512_CEL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512cel.cpp") + ocv_update(CPU_AVX512_CLX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512clx.cpp") ocv_update(CPU_AVX512_ICL_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512icl.cpp") if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE) - ocv_update(CPU_AVX512_ICL_IMPLIES "AVX512_CEL") - ocv_update(CPU_AVX512_CEL_IMPLIES "AVX512_CNL") + ocv_update(CPU_AVX512_ICL_IMPLIES "AVX512_SKX") + ocv_update(CPU_AVX512_CLX_IMPLIES "AVX512_SKX") ocv_update(CPU_AVX512_CNL_IMPLIES "AVX512_SKX") ocv_update(CPU_AVX512_SKX_IMPLIES "AVX512_COMMON") ocv_update(CPU_AVX512_KNM_IMPLIES "AVX512_KNL") @@ -251,7 +253,7 @@ if(X86 OR X86_64) ocv_intel_compiler_optimization_option(AVX512_KNM "-xKNM" "/Qx:KNM") ocv_intel_compiler_optimization_option(AVX512_SKX "-xSKYLAKE-AVX512" "/Qx:SKYLAKE-AVX512") ocv_intel_compiler_optimization_option(AVX512_CNL "-xCANNONLAKE" "/Qx:CANNONLAKE") - ocv_intel_compiler_optimization_option(AVX512_CEL "-xCASCADELAKE" "/Qx:CASCADELAKE") + ocv_intel_compiler_optimization_option(AVX512_CLX "-xCASCADELAKE" "/Qx:CASCADELAKE") ocv_intel_compiler_optimization_option(AVX512_ICL "-xICELAKE-CLIENT" "/Qx:ICELAKE-CLIENT") elseif(CV_GCC OR CV_CLANG) ocv_update(CPU_AVX2_FLAGS_ON "-mavx2") diff --git a/cmake/checks/cpu_avx512cel.cpp b/cmake/checks/cpu_avx512clx.cpp similarity index 50% rename from cmake/checks/cpu_avx512cel.cpp rename to cmake/checks/cpu_avx512clx.cpp index e372cf9a45..0d0b2aaee0 100644 --- a/cmake/checks/cpu_avx512cel.cpp +++ b/cmake/checks/cpu_avx512clx.cpp @@ -3,9 +3,9 @@ void test() { __m512i a, b, c; - a = _mm512_dpwssd_epi32(a, b, c); + a = _mm512_dpwssd_epi32(a, b, c); // VNNI } #else -#error "AVX512-CEL is not supported" +#error "AVX512-CLX is not supported" #endif -int main() { return 0; } \ No newline at end of file +int main() { return 0; } diff --git a/cmake/checks/cpu_avx512icl.cpp b/cmake/checks/cpu_avx512icl.cpp index a67f5f35d4..551f624d08 100644 --- a/cmake/checks/cpu_avx512icl.cpp +++ b/cmake/checks/cpu_avx512icl.cpp @@ -3,9 +3,10 @@ void test() { __m512i a, b, c; - a = _mm512_popcnt_epi8(a); - a = _mm512_shrdv_epi64(a, b, c); - a = _mm512_popcnt_epi64(a); + a = _mm512_popcnt_epi8(a); // BITALG + a = _mm512_shrdv_epi64(a, b, c); // VBMI2 + a = _mm512_popcnt_epi64(a); // VPOPCNTDQ + a = _mm512_dpwssd_epi32(a, b, c); // VNNI } #else #error "AVX512-ICL is not supported" diff --git a/modules/core/include/opencv2/core/cv_cpu_dispatch.h b/modules/core/include/opencv2/core/cv_cpu_dispatch.h index 0248d5f98f..c00f569f12 100644 --- a/modules/core/include/opencv2/core/cv_cpu_dispatch.h +++ b/modules/core/include/opencv2/core/cv_cpu_dispatch.h @@ -113,12 +113,18 @@ # define CV_AVX_512IFMA 1 # define CV_AVX_512VBMI 1 #endif -#ifdef CV_CPU_COMPILE_AVX512_CEL -# define CV_AVX512_CEL 1 +#ifdef CV_CPU_COMPILE_AVX512_CLX +# define CV_AVX512_CLX 1 # define CV_AVX_512VNNI 1 #endif #ifdef CV_CPU_COMPILE_AVX512_ICL # define CV_AVX512_ICL 1 +# undef CV_AVX_512IFMA +# define CV_AVX_512IFMA 1 +# undef CV_AVX_512VBMI +# define CV_AVX_512VBMI 1 +# undef CV_AVX_512VNNI +# define CV_AVX_512VNNI 1 # define CV_AVX_512VBMI2 1 # define CV_AVX_512BITALG 1 # define CV_AVX_512VPOPCNTDQ 1 @@ -311,8 +317,8 @@ struct VZeroUpperGuard { #ifndef CV_AVX512_CNL # define CV_AVX512_CNL 0 #endif -#ifndef CV_AVX512_CEL -# define CV_AVX512_CEL 0 +#ifndef CV_AVX512_CLX +# define CV_AVX512_CLX 0 #endif #ifndef CV_AVX512_ICL # define CV_AVX512_ICL 0 diff --git a/modules/core/include/opencv2/core/cv_cpu_helper.h b/modules/core/include/opencv2/core/cv_cpu_helper.h index 2c82282b40..aaa89ed415 100644 --- a/modules/core/include/opencv2/core/cv_cpu_helper.h +++ b/modules/core/include/opencv2/core/cv_cpu_helper.h @@ -357,26 +357,26 @@ #endif #define __CV_CPU_DISPATCH_CHAIN_AVX512_CNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) -#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CEL -# define CV_TRY_AVX512_CEL 1 -# define CV_CPU_FORCE_AVX512_CEL 1 -# define CV_CPU_HAS_SUPPORT_AVX512_CEL 1 -# define CV_CPU_CALL_AVX512_CEL(fn, args) return (cpu_baseline::fn args) -# define CV_CPU_CALL_AVX512_CEL_(fn, args) return (opt_AVX512_CEL::fn args) -#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CEL -# define CV_TRY_AVX512_CEL 1 -# define CV_CPU_FORCE_AVX512_CEL 0 -# define CV_CPU_HAS_SUPPORT_AVX512_CEL (cv::checkHardwareSupport(CV_CPU_AVX512_CEL)) -# define CV_CPU_CALL_AVX512_CEL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CEL) return (opt_AVX512_CEL::fn args) -# define CV_CPU_CALL_AVX512_CEL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CEL) return (opt_AVX512_CEL::fn args) +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CLX +# define CV_TRY_AVX512_CLX 1 +# define CV_CPU_FORCE_AVX512_CLX 1 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX 1 +# define CV_CPU_CALL_AVX512_CLX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) return (opt_AVX512_CLX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CLX +# define CV_TRY_AVX512_CLX 1 +# define CV_CPU_FORCE_AVX512_CLX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX (cv::checkHardwareSupport(CV_CPU_AVX512_CLX)) +# define CV_CPU_CALL_AVX512_CLX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args) #else -# define CV_TRY_AVX512_CEL 0 -# define CV_CPU_FORCE_AVX512_CEL 0 -# define CV_CPU_HAS_SUPPORT_AVX512_CEL 0 -# define CV_CPU_CALL_AVX512_CEL(fn, args) -# define CV_CPU_CALL_AVX512_CEL_(fn, args) +# define CV_TRY_AVX512_CLX 0 +# define CV_CPU_FORCE_AVX512_CLX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX 0 +# define CV_CPU_CALL_AVX512_CLX(fn, args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) #endif -#define __CV_CPU_DISPATCH_CHAIN_AVX512_CEL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CEL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) +#define __CV_CPU_DISPATCH_CHAIN_AVX512_CLX(fn, args, mode, ...) CV_CPU_CALL_AVX512_CLX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) #if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_ICL # define CV_TRY_AVX512_ICL 1 diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 49390ec8d6..ea446b3fcb 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -269,7 +269,7 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard #define CV_CPU_AVX512_KNL 258 #define CV_CPU_AVX512_KNM 259 #define CV_CPU_AVX512_CNL 260 -#define CV_CPU_AVX512_CEL 261 +#define CV_CPU_AVX512_CLX 261 #define CV_CPU_AVX512_ICL 262 // when adding to this list remember to update the following enum @@ -320,7 +320,7 @@ enum CpuFeatures { CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF CPU_AVX512_KNM = 259, //!< Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ CPU_AVX512_CNL = 260, //!< Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI - CPU_AVX512_CEL = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI + CPU_AVX512_CLX = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI CPU_AVX512_ICL = 262, //!< Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ CPU_MAX_FEATURE = 512 // see CV_HARDWARE_MAX_FEATURE diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 8d7ccf7119..1b6777561a 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -370,11 +370,12 @@ struct HWFeatures g_hwFeatureNames[CPU_MSA] = "CPU_MSA"; + g_hwFeatureNames[CPU_AVX512_COMMON] = "AVX512-COMMON"; g_hwFeatureNames[CPU_AVX512_SKX] = "AVX512-SKX"; g_hwFeatureNames[CPU_AVX512_KNL] = "AVX512-KNL"; g_hwFeatureNames[CPU_AVX512_KNM] = "AVX512-KNM"; g_hwFeatureNames[CPU_AVX512_CNL] = "AVX512-CNL"; - g_hwFeatureNames[CPU_AVX512_CEL] = "AVX512-CEL"; + g_hwFeatureNames[CPU_AVX512_CLX] = "AVX512-CLX"; g_hwFeatureNames[CPU_AVX512_ICL] = "AVX512-ICL"; } @@ -485,9 +486,11 @@ struct HWFeatures have[CV_CPU_AVX_5124VNNIW] && have[CV_CPU_AVX_512VPOPCNTDQ]; have[CV_CPU_AVX512_SKX] = have[CV_CPU_AVX_512BW] && have[CV_CPU_AVX_512DQ] && have[CV_CPU_AVX_512VL]; have[CV_CPU_AVX512_CNL] = have[CV_CPU_AVX512_SKX] && have[CV_CPU_AVX_512IFMA] && have[CV_CPU_AVX_512VBMI]; - have[CV_CPU_AVX512_CEL] = have[CV_CPU_AVX512_CNL] && have[CV_CPU_AVX_512VNNI]; - have[CV_CPU_AVX512_ICL] = have[CV_CPU_AVX512_CEL] && have[CV_CPU_AVX_512VBMI2] && - have[CV_CPU_AVX_512BITALG] && have[CV_CPU_AVX_512VPOPCNTDQ]; + have[CV_CPU_AVX512_CLX] = have[CV_CPU_AVX512_SKX] && have[CV_CPU_AVX_512VNNI]; + have[CV_CPU_AVX512_ICL] = have[CV_CPU_AVX512_SKX] && + have[CV_CPU_AVX_512IFMA] && have[CV_CPU_AVX_512VBMI] && + have[CV_CPU_AVX_512VNNI] && + have[CV_CPU_AVX_512VBMI2] && have[CV_CPU_AVX_512BITALG] && have[CV_CPU_AVX_512VPOPCNTDQ]; } else { @@ -495,7 +498,7 @@ struct HWFeatures have[CV_CPU_AVX512_KNM] = false; have[CV_CPU_AVX512_SKX] = false; have[CV_CPU_AVX512_CNL] = false; - have[CV_CPU_AVX512_CEL] = false; + have[CV_CPU_AVX512_CLX] = false; have[CV_CPU_AVX512_ICL] = false; } } @@ -572,8 +575,16 @@ struct HWFeatures have[CV_CPU_VSX3] = (CV_VSX3); #endif + bool skip_baseline_check = false; +#ifndef NO_GETENV + if (getenv("OPENCV_SKIP_CPU_BASELINE_CHECK")) + { + skip_baseline_check = true; + } +#endif int baseline_features[] = { CV_CPU_BASELINE_FEATURES }; - if (!checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]))) + if (!checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0])) + && !skip_baseline_check) { fprintf(stderr, "\n" "******************************************************************\n" @@ -600,12 +611,12 @@ struct HWFeatures { if (have[feature]) { - if (dump) fprintf(stderr, "%s - OK\n", getHWFeatureNameSafe(feature)); + if (dump) fprintf(stderr, " ID=%3d (%s) - OK\n", feature, getHWFeatureNameSafe(feature)); } else { result = false; - if (dump) fprintf(stderr, "%s - NOT AVAILABLE\n", getHWFeatureNameSafe(feature)); + if (dump) fprintf(stderr, " ID=%3d (%s) - NOT AVAILABLE\n", feature, getHWFeatureNameSafe(feature)); } } } From b1485d0337b0d31575fec0dcc50149c8162f44f4 Mon Sep 17 00:00:00 2001 From: Wise86 Date: Sat, 5 Oct 2019 11:48:09 +0200 Subject: [PATCH 9/9] upgrade the file to use the correct package name and include py3/gtk3 support --- .../py_setup_in_ubuntu.markdown | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown b/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown index 722517273b..f88ffe6793 100644 --- a/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown +++ b/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown @@ -5,7 +5,7 @@ Goals ----- In this tutorial We will learn to setup OpenCV-Python in Ubuntu System. -Below steps are tested for Ubuntu 16.04 (64-bit) and Ubuntu 14.04 (32-bit). +Below steps are tested for Ubuntu 16.04 and 18.04 (both 64-bit). OpenCV-Python can be installed in Ubuntu in two ways: - Install from pre-built binaries available in Ubuntu repositories @@ -62,18 +62,36 @@ We need **CMake** to configure the installation, **GCC** for compilation, **Pyth ``` sudo apt-get install cmake -sudo apt-get install python-dev python-numpy sudo apt-get install gcc g++ ``` +to support python2: -Next we need **GTK** support for GUI features, Camera support (libv4l), Media Support +``` +sudo apt-get install python-dev python-numpy +``` + +to support python3: + +``` +sudo apt-get install python3-dev python3-numpy +``` + +Next we need **GTK** support for GUI features, Camera support (v4l), Media Support (ffmpeg, gstreamer) etc. ``` -sudo apt-get install gtk2-devel -sudo apt-get install libv4l-devel -sudo apt-get install ffmpeg-devel -sudo apt-get install gstreamer-plugins-base-devel +sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev +sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev +``` + +to support gtk2: +``` +sudo apt-get install libgtk2.0-dev +``` + +to support gtk3: +``` +sudo apt-get install libgtk-3-dev ``` ### Optional Dependencies @@ -87,14 +105,15 @@ But it may be a little old. If you want to get latest libraries, you can install development files for system libraries of these formats. ``` -sudo apt-get install libpng-devel -sudo apt-get install libjpeg-turbo-devel -sudo apt-get install jasper-devel -sudo apt-get install openexr-devel -sudo apt-get install libtiff-devel -sudo apt-get install libwebp-devel +sudo apt-get install libpng-dev +sudo apt-get install libjpeg-dev +sudo apt-get install libopenexr-dev +sudo apt-get install libtiff-dev +sudo apt-get install libwebp-dev ``` +@note If you are using Ubuntu 16.04 you can also install ```libjasper-dev``` to add a system level support for the JPEG2000 format. + ### Downloading OpenCV To download the latest source from OpenCV's [GitHub Repository](https://github.com/opencv/opencv).