From 38b6c44b4c78077e5a96b1f159db26693197d649 Mon Sep 17 00:00:00 2001 From: Ed J Date: Wed, 1 Jun 2022 00:51:55 +0100 Subject: [PATCH 01/34] for then given -> for the given --- modules/calib3d/include/opencv2/calib3d.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 63eded027f..da27f50869 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -2117,7 +2117,7 @@ described below. therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit length. @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks -inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to recover pose. In the output mask only inliers which pass the cheirality check. This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies @@ -2168,7 +2168,7 @@ length. are feature points from cameras with same focal length and principal point. @param pp principal point of the camera. @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks -inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to recover pose. In the output mask only inliers which pass the cheirality check. This function differs from the one above that it computes camera intrinsic matrix from focal length and @@ -2204,7 +2204,7 @@ length. @param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite points). @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks -inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to recover pose. In the output mask only inliers which pass the cheirality check. @param triangulatedPoints 3D points which were reconstructed by triangulation. From f28e191d709a7483859d21084ab5708348e9da1c Mon Sep 17 00:00:00 2001 From: Ed J Date: Wed, 1 Jun 2022 00:53:33 +0100 Subject: [PATCH 02/34] cheirality -> chirality --- modules/calib3d/include/opencv2/calib3d.hpp | 12 ++++++------ modules/calib3d/src/five-point.cpp | 2 +- modules/calib3d/src/sqpnp.hpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index da27f50869..c2d23e92f3 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -2099,7 +2099,7 @@ unit length. CV_EXPORTS_W void decomposeEssentialMat( InputArray E, OutputArray R1, OutputArray R2, OutputArray t ); /** @brief Recovers the relative camera rotation and the translation from an estimated essential -matrix and the corresponding points in two images, using cheirality check. Returns the number of +matrix and the corresponding points in two images, using chirality check. Returns the number of inliers that pass the check. @param E The input essential matrix. @@ -2118,10 +2118,10 @@ therefore is only known up to scale, i.e. t is the direction of the translation length. @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to -recover pose. In the output mask only inliers which pass the cheirality check. +recover pose. In the output mask only inliers which pass the chirality check. This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies -possible pose hypotheses by doing cheirality check. The cheirality check means that the +possible pose hypotheses by doing chirality check. The chirality check means that the triangulated 3D points should have positive depth. Some details can be found in @cite Nister03. This function can be used to process the output E and mask from @ref findEssentialMat. In this @@ -2169,7 +2169,7 @@ are feature points from cameras with same focal length and principal point. @param pp principal point of the camera. @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to -recover pose. In the output mask only inliers which pass the cheirality check. +recover pose. In the output mask only inliers which pass the chirality check. This function differs from the one above that it computes camera intrinsic matrix from focal length and principal point: @@ -2205,11 +2205,11 @@ length. points). @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to -recover pose. In the output mask only inliers which pass the cheirality check. +recover pose. In the output mask only inliers which pass the chirality check. @param triangulatedPoints 3D points which were reconstructed by triangulation. This function differs from the one above that it outputs the triangulated 3D point that are used for -the cheirality check. +the chirality check. */ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, InputArray cameraMatrix, OutputArray R, OutputArray t, double distanceThresh, InputOutputArray mask = noArray(), diff --git a/modules/calib3d/src/five-point.cpp b/modules/calib3d/src/five-point.cpp index dbdd294c7e..f78fab0b97 100644 --- a/modules/calib3d/src/five-point.cpp +++ b/modules/calib3d/src/five-point.cpp @@ -520,7 +520,7 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, P3(Range::all(), Range(0, 3)) = R1 * 1.0; P3.col(3) = -t * 1.0; P4(Range::all(), Range(0, 3)) = R2 * 1.0; P4.col(3) = -t * 1.0; - // Do the cheirality check. + // Do the chirality check. // Notice here a threshold dist is used to filter // out far away points (i.e. infinite points) since // their depth may vary between positive and negative. diff --git a/modules/calib3d/src/sqpnp.hpp b/modules/calib3d/src/sqpnp.hpp index 97c10e34e7..66c478f371 100644 --- a/modules/calib3d/src/sqpnp.hpp +++ b/modules/calib3d/src/sqpnp.hpp @@ -111,7 +111,7 @@ private: static double det3x3(const cv::Matx& e); /* - * @brief Tests the cheirality for a given solution. + * @brief Tests the chirality for a given solution. * @param solution The solution to evaluate. */ inline bool positiveDepth(const SQPSolution& solution) const; From 82010bf5c105a3e6f1c2fbf73e7ec164c7a96235 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Fri, 24 Jun 2022 11:31:54 +0200 Subject: [PATCH 03/34] Fix some overflows in drawing. --- modules/imgproc/src/drawing.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp index 65735bd9c3..81d56075ca 100644 --- a/modules/imgproc/src/drawing.cpp +++ b/modules/imgproc/src/drawing.cpp @@ -1159,7 +1159,7 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin edge[0].x = edge[1].x = -XY_ONE; edge[0].dx = edge[1].dx = 0; - ptr += img.step*y; + ptr += (int64_t)img.step*y; do { @@ -1188,7 +1188,7 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin } edge[i].ye = ty; - edge[i].dx = ((xe - xs)*2 + (ty - y)) / (2 * (ty - y)); + edge[i].dx = ((xe - xs)*2 + ((int64_t)ty - y)) / (2 * ((int64_t)ty - y)); edge[i].x = xs; edge[i].idx = idx; break; @@ -1461,7 +1461,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) size_t step = img.step; int pix_size = (int)img.elemSize(); uchar* ptr = img.ptr(); - int err = 0, dx = radius, dy = 0, plus = 1, minus = (radius << 1) - 1; + int64_t err = 0, dx = radius, dy = 0, plus = 1, minus = (radius << 1) - 1; int inside = center.x >= radius && center.x < size.width - radius && center.y >= radius && center.y < size.height - radius; @@ -1471,8 +1471,8 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) while( dx >= dy ) { int mask; - int y11 = center.y - dy, y12 = center.y + dy, y21 = center.y - dx, y22 = center.y + dx; - int x11 = center.x - dx, x12 = center.x + dx, x21 = center.x - dy, x22 = center.x + dy; + int64_t y11 = center.y - dy, y12 = center.y + dy, y21 = center.y - dx, y22 = center.y + dx; + int64_t x11 = center.x - dx, x12 = center.x + dx, x21 = center.x - dy, x22 = center.x + dy; if( inside ) { @@ -1512,7 +1512,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) { if( fill ) { - x11 = std::max( x11, 0 ); + x11 = std::max( x11, (int64_t)0 ); x12 = MIN( x12, size.width - 1 ); } @@ -1550,7 +1550,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) { if( fill ) { - x21 = std::max( x21, 0 ); + x21 = std::max( x21, (int64_t)0 ); x22 = MIN( x22, size.width - 1 ); } @@ -1848,6 +1848,11 @@ void rectangle( Mat& img, Rect rec, CV_INSTRUMENT_REGION(); CV_Assert( 0 <= shift && shift <= XY_SHIFT ); + + // Crop the rectangle to right around the mat. + rec &= Rect(-(1 << shift), -(1 << shift), ((img.cols + 2) << shift), + ((img.rows + 2) << shift)); + if( !rec.empty() ) rectangle( img, rec.tl(), rec.br() - Point(1< Date: Mon, 27 Jun 2022 21:34:15 +0300 Subject: [PATCH 04/34] Workflow for labeled iOS PRs in 3.4 branch --- .github/workflows/PR-3.4.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/PR-3.4.yaml b/.github/workflows/PR-3.4.yaml index 1e3282310e..524c835b00 100644 --- a/.github/workflows/PR-3.4.yaml +++ b/.github/workflows/PR-3.4.yaml @@ -19,4 +19,7 @@ jobs: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-macOS-ARM64.yaml@main macOS-X64: - uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-macOS-x86_64.yaml@main \ No newline at end of file + uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-macOS-x86_64.yaml@main + + iOS: + uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-iOS.yaml@main From 2336b0706d10b54866abdc4470557ef1c966ec2e Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Wed, 29 Jun 2022 20:35:27 +0900 Subject: [PATCH 05/34] add support for Orin GPU --- cmake/OpenCVDetectCUDA.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index ac29e600d3..4163c51a22 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -243,12 +243,13 @@ if(CUDA_FOUND) endif() if(NOT _nvcc_res EQUAL 0) message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.") - # TX1 (5.3) TX2 (6.2) Xavier (7.2) V100 (7.0) + # TX1 (5.3) TX2 (6.2) Xavier (7.2) V100 (7.0) Orin (8.7) ocv_filter_available_architecture(__cuda_arch_bin 5.3 6.2 7.2 7.0 + 8.7 ) else() set(__cuda_arch_bin "${_nvcc_out}") From b152b8cbcdc048b290d08c2a1a201fc0f3ae1e6c Mon Sep 17 00:00:00 2001 From: Lucas Yang Date: Thu, 30 Jun 2022 04:07:43 +0800 Subject: [PATCH 06/34] Fix missing CharVector for JavaScript bindings --- modules/js/src/core_bindings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/js/src/core_bindings.cpp b/modules/js/src/core_bindings.cpp index a43fb726de..9df700c5fb 100644 --- a/modules/js/src/core_bindings.cpp +++ b/modules/js/src/core_bindings.cpp @@ -419,6 +419,7 @@ namespace binding_utils EMSCRIPTEN_BINDINGS(binding_utils) { register_vector("IntVector"); + register_vector("CharVector"); register_vector("FloatVector"); register_vector("DoubleVector"); register_vector("PointVector"); From 0f3de805f4068d20816aea16edd8ee2c49ec9b10 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sat, 2 Jul 2022 00:56:10 +0300 Subject: [PATCH 07/34] build: fix warnings --- samples/cpp/imgcodecs_jpeg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/cpp/imgcodecs_jpeg.cpp b/samples/cpp/imgcodecs_jpeg.cpp index b3abc49286..4c22a483d7 100644 --- a/samples/cpp/imgcodecs_jpeg.cpp +++ b/samples/cpp/imgcodecs_jpeg.cpp @@ -17,7 +17,7 @@ int main(int /*argc*/, const char** /* argv */ ) { const Point center( img.rows / 2 , img.cols /2 ); - for( int radius = 5; radius < img.rows ; radius += 3.5 ) + for( int radius = 5; radius < img.rows ; radius += 3 ) { cv::circle( img, center, radius, Scalar(255,0,255) ); } From 6360c3bf461d666af192237668eb26b99508513a Mon Sep 17 00:00:00 2001 From: heavyrain-lzy <1528794076@qq.com> Date: Mon, 4 Jul 2022 04:06:43 +0800 Subject: [PATCH 08/34] Merge pull request #22184 from heavyrain-lzy:fixbug_pyrUp * fix the bug in pyrUp * add test case for pyrUp * coding style --- modules/imgproc/src/pyramids.cpp | 2 +- modules/imgproc/test/test_pyramid.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 modules/imgproc/test/test_pyramid.cpp diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index 4f7732925c..0261dd4de3 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -963,7 +963,7 @@ pyrUp_( const Mat& _src, Mat& _dst, int) if (dsize.width > ssize.width*2) { - row[(_dst.cols-1) + x] = row[dx + cn]; + row[(_dst.cols-1) * cn + x] = row[dx + cn]; } } diff --git a/modules/imgproc/test/test_pyramid.cpp b/modules/imgproc/test/test_pyramid.cpp new file mode 100644 index 0000000000..343d7a2321 --- /dev/null +++ b/modules/imgproc/test/test_pyramid.cpp @@ -0,0 +1,19 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "test_precomp.hpp" + +namespace opencv_test { namespace { + +TEST(Imgproc_PyrUp, pyrUp_regression_22184) +{ + Mat src(100, 100, CV_16UC3, Scalar::all(255)); + Mat dst(100 * 2 + 1, 100 * 2 + 1, CV_16UC3, Scalar::all(0)); + pyrUp(src, dst, Size(dst.cols, dst.rows)); + double min_val = 0; + minMaxLoc(dst, &min_val); + ASSERT_GT(cvRound(min_val), 0); +} + +}} // namespace From 6a4c3b61e6fe8f40e52f510048d712497ce3bb3d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 4 Jul 2022 12:09:33 +0300 Subject: [PATCH 09/34] Improve doc of calcHist overload that accepts vectors It's not clear how ranges argument should be used in the overload of calcHist that accepts std::vector. The main overload uses array of arrays there, while std::vector overload uses a plain array. The code interprets the vector as a flattened array and rebuilds array of arrays from it. This is not obvious interpretation, so documentation has been added to explain the expected usage. --- modules/imgproc/include/opencv2/imgproc.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 4cb077f375..fd1a5d9721 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -3270,7 +3270,14 @@ CV_EXPORTS void calcHist( const Mat* images, int nimages, const int* histSize, const float** ranges, bool uniform = true, bool accumulate = false ); -/** @overload */ +/** @overload + +this variant supports only uniform histograms. + +ranges argument is either empty vector or a flattened vector of histSize.size()*2 elements +(histSize.size() element pairs). The first and second elements of each pair specify the lower and +upper boundaries. +*/ CV_EXPORTS_W void calcHist( InputArrayOfArrays images, const std::vector& channels, InputArray mask, OutputArray hist, From 2920a8e0ec3389b39666854d1eaa407fe541fb52 Mon Sep 17 00:00:00 2001 From: Yuantao Feng Date: Tue, 5 Jul 2022 06:45:14 +0800 Subject: [PATCH 10/34] Merge pull request #22185 from fengyuentau:ci_job_rename_3.4 Rename jobs for better understanding for branch 3.4 * rename jobs * remove dots from job names * correct ubuntu version for linux arm64 --- .github/workflows/PR-3.4.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/PR-3.4.yaml b/.github/workflows/PR-3.4.yaml index 524c835b00..fcfa924e96 100644 --- a/.github/workflows/PR-3.4.yaml +++ b/.github/workflows/PR-3.4.yaml @@ -6,19 +6,19 @@ on: - 3.4 jobs: - ARM64: + Ubuntu1804-ARM64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-ARM64.yaml@main - U20: + Ubuntu2004-x64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-U20.yaml@main - W10: + Windows10-x64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-W10.yaml@main macOS-ARM64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-macOS-ARM64.yaml@main - macOS-X64: + macOS-x64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-macOS-x86_64.yaml@main iOS: From a630ad73cb5dde7f8c69e86094bd4a1070ff0249 Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Wed, 6 Jul 2022 23:31:31 +0900 Subject: [PATCH 11/34] suppress warning on GCC 7 and later --- 3rdparty/openexr/CMakeLists.txt | 4 ++++ 3rdparty/protobuf/CMakeLists.txt | 4 ++++ modules/calib3d/CMakeLists.txt | 4 ++++ modules/core/CMakeLists.txt | 4 ++++ modules/dnn/CMakeLists.txt | 4 ++++ modules/features2d/CMakeLists.txt | 4 ++++ modules/flann/CMakeLists.txt | 4 ++++ modules/imgproc/CMakeLists.txt | 4 ++++ modules/ml/CMakeLists.txt | 4 ++++ modules/objdetect/CMakeLists.txt | 4 ++++ modules/shape/CMakeLists.txt | 4 ++++ modules/stitching/CMakeLists.txt | 4 ++++ modules/ts/CMakeLists.txt | 4 ++++ samples/cpp/CMakeLists.txt | 4 ++++ 14 files changed, 56 insertions(+) diff --git a/3rdparty/openexr/CMakeLists.txt b/3rdparty/openexr/CMakeLists.txt index 88f60b23c0..1fbfa4f857 100644 --- a/3rdparty/openexr/CMakeLists.txt +++ b/3rdparty/openexr/CMakeLists.txt @@ -110,6 +110,10 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -W -Wreorder -Wunused-result ) +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess) endif() diff --git a/3rdparty/protobuf/CMakeLists.txt b/3rdparty/protobuf/CMakeLists.txt index f249d2dcc3..f8372dc1ad 100644 --- a/3rdparty/protobuf/CMakeLists.txt +++ b/3rdparty/protobuf/CMakeLists.txt @@ -25,6 +25,10 @@ else() -Warray-bounds # GCC 9+ ) endif() +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() if(CV_ICC) ocv_warnings_disable(CMAKE_CXX_FLAGS -wd265 -wd858 -wd873 -wd2196 diff --git a/modules/calib3d/CMakeLists.txt b/modules/calib3d/CMakeLists.txt index a38fdf18d8..1c31ad1903 100644 --- a/modules/calib3d/CMakeLists.txt +++ b/modules/calib3d/CMakeLists.txt @@ -3,6 +3,10 @@ set(debug_modules "") if(DEBUG_opencv_calib3d) list(APPEND debug_modules opencv_highgui) endif() +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_define_module(calib3d opencv_imgproc opencv_features2d ${debug_modules} WRAP java python js ) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index beba9f804e..568a8afef1 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -38,6 +38,10 @@ endif() if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wenum-compare -Wunused-function -Wshadow) endif() +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() if(CV_TRACE AND HAVE_ITT) add_definitions(-DOPENCV_WITH_ITT=1) diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 4019356392..680be360ba 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -35,6 +35,10 @@ else() -Wunused-parameter -Wsign-compare ) endif() +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) endif() diff --git a/modules/features2d/CMakeLists.txt b/modules/features2d/CMakeLists.txt index 1d29320a14..28af58565b 100644 --- a/modules/features2d/CMakeLists.txt +++ b/modules/features2d/CMakeLists.txt @@ -1,6 +1,10 @@ set(the_description "2D Features Framework") ocv_add_dispatched_file(sift SSE4_1 AVX2 AVX512_SKX) +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() set(debug_modules "") if(DEBUG_opencv_features2d) diff --git a/modules/flann/CMakeLists.txt b/modules/flann/CMakeLists.txt index 78e041129b..5935f679d4 100644 --- a/modules/flann/CMakeLists.txt +++ b/modules/flann/CMakeLists.txt @@ -1,2 +1,6 @@ set(the_description "Clustering and Search in Multi-Dimensional Spaces") +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_define_module(flann opencv_core WRAP python) diff --git a/modules/imgproc/CMakeLists.txt b/modules/imgproc/CMakeLists.txt index 3b45482481..5787ec502c 100644 --- a/modules/imgproc/CMakeLists.txt +++ b/modules/imgproc/CMakeLists.txt @@ -12,6 +12,10 @@ ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2) ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX) ocv_add_dispatched_file(undistort SSE2 AVX2) ocv_define_module(imgproc opencv_core WRAP java python js) +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_check_environment_variables(OPENCV_IPP_GAUSSIAN_BLUR) option(OPENCV_IPP_GAUSSIAN_BLUR "Enable IPP optimizations for GaussianBlur (+8Mb in binary size)" OFF) diff --git a/modules/ml/CMakeLists.txt b/modules/ml/CMakeLists.txt index 1b64cc4f17..8b76e0c8ad 100644 --- a/modules/ml/CMakeLists.txt +++ b/modules/ml/CMakeLists.txt @@ -1,2 +1,6 @@ set(the_description "Machine Learning") +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_define_module(ml opencv_core WRAP java python) diff --git a/modules/objdetect/CMakeLists.txt b/modules/objdetect/CMakeLists.txt index 414e578099..34b77eab6b 100644 --- a/modules/objdetect/CMakeLists.txt +++ b/modules/objdetect/CMakeLists.txt @@ -1,4 +1,8 @@ set(the_description "Object Detection") +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_define_module(objdetect opencv_core opencv_imgproc opencv_calib3d WRAP java python js) if(HAVE_QUIRC) diff --git a/modules/shape/CMakeLists.txt b/modules/shape/CMakeLists.txt index 527a0c2f71..209eb11f34 100644 --- a/modules/shape/CMakeLists.txt +++ b/modules/shape/CMakeLists.txt @@ -1,2 +1,6 @@ set(the_description "Shape descriptors and matchers") +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_define_module(shape opencv_core opencv_imgproc opencv_video WRAP python) diff --git a/modules/stitching/CMakeLists.txt b/modules/stitching/CMakeLists.txt index 44f35eb59b..7ea34a1608 100644 --- a/modules/stitching/CMakeLists.txt +++ b/modules/stitching/CMakeLists.txt @@ -3,6 +3,10 @@ set(the_description "Images stitching") if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations -Wshadow -Wstrict-aliasing) endif() +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d") if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES) diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index f95bed0793..fd6e008333 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -15,6 +15,10 @@ if(WINRT) endif() ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) +if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) +endif() ocv_add_module(ts INTERNAL opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui) diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 6ae9586fd4..8cb11c0222 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -41,6 +41,10 @@ foreach(sample_filename ${cpp_samples}) ocv_warnings_disable(CMAKE_CXX_FLAGS -Winconsistent-missing-override -Wsuggest-override) endif() endif() + if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) + # suppress warnings from GCC only on 7.1 and later + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) + endif() set(package "cpp") if(sample_filename MATCHES "tutorial_code") set(package "tutorial") From 0a88f84847b8d22582d11ed054cdbe33512b6a25 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Fri, 8 Jul 2022 00:24:01 +0200 Subject: [PATCH 12/34] Merge pull request #22208 from vrabaud:34_calibinit Add missing code. * Add missing code. This was removed in c7fc563dc0ac2d21ad2bd618e741227c0a4b4f76 The resize is also a side-effect. * Use shorteer cv::Point2f *= --- modules/calib3d/src/calibinit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 0a8cdd5c6f..1dff8de6e6 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -1232,7 +1232,7 @@ int ChessBoardDetector::cleanFoundConnectedQuads(std::vector& q centers[i] = ci; center += ci; } - center.x *= (1.0f / quad_count); + center *= (1.0f / quad_count); // If we still have more quadrangles than we should, // we try to eliminate bad ones based on minimizing the bounding box. @@ -1298,6 +1298,7 @@ int ChessBoardDetector::cleanFoundConnectedQuads(std::vector& q quad_group[min_box_area_index] = quad_group[quad_count]; centers[min_box_area_index] = centers[quad_count]; } + quad_group.resize(quad_count); return quad_count; } From db706769333a4cd5f4a9d5176dcf790256aefc23 Mon Sep 17 00:00:00 2001 From: Rong Mantle Bao Date: Sat, 9 Jul 2022 07:20:44 +0800 Subject: [PATCH 13/34] Use cross-platform std::chrono in getTickCount() Add conditional compilation directives to enable uses of std::chrono on supported compilers. Use std::chrono::steady_clock as a source to retrieve current tick count and clock frequency. Fixes opencv/opencv#6902. --- modules/core/src/system.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index adb957908d..dda62fb89e 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -302,6 +302,16 @@ DECLARE_CV_CPUID_X86 #endif +#if ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) + #define HAVE_CXX11 1 +#else + #define HAVE_CXX11 0 +#endif + +#if HAVE_CXX11 + #include +#endif + namespace cv { @@ -840,7 +850,10 @@ bool useOptimized(void) int64 getTickCount(void) { -#if defined _WIN32 || defined WINCE +#if HAVE_CXX11 + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); + return (int64)now.time_since_epoch().count(); +#elif defined _WIN32 || defined WINCE LARGE_INTEGER counter; QueryPerformanceCounter( &counter ); return (int64)counter.QuadPart; @@ -859,7 +872,11 @@ int64 getTickCount(void) double getTickFrequency(void) { -#if defined _WIN32 || defined WINCE +#if HAVE_CXX11 + using clock_period_t = std::chrono::steady_clock::duration::period; + double clock_freq = clock_period_t::den / clock_period_t::num; + return clock_freq; +#elif defined _WIN32 || defined WINCE LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); return (double)freq.QuadPart; From fa613e393f96ef7de246a418761af72f36a0c390 Mon Sep 17 00:00:00 2001 From: Rong Mantle Bao Date: Sun, 10 Jul 2022 17:34:07 +0800 Subject: [PATCH 14/34] Read CV_CXX11 for C++11 detection --- modules/core/src/system.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index dda62fb89e..3b6877105d 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -301,14 +301,7 @@ DECLARE_CV_CPUID_X86 #endif #endif - -#if ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) - #define HAVE_CXX11 1 -#else - #define HAVE_CXX11 0 -#endif - -#if HAVE_CXX11 +#if defined CV_CXX11 #include #endif @@ -850,7 +843,7 @@ bool useOptimized(void) int64 getTickCount(void) { -#if HAVE_CXX11 +#if defined CV_CXX11 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); return (int64)now.time_since_epoch().count(); #elif defined _WIN32 || defined WINCE @@ -872,7 +865,7 @@ int64 getTickCount(void) double getTickFrequency(void) { -#if HAVE_CXX11 +#if defined CV_CXX11 using clock_period_t = std::chrono::steady_clock::duration::period; double clock_freq = clock_period_t::den / clock_period_t::num; return clock_freq; From 87ef6a9cc13749a3fba918350ffd97ce06753d80 Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Tue, 12 Jul 2022 19:42:39 +0900 Subject: [PATCH 15/34] build: suppress the warning DRY bump the version --- 3rdparty/carotene/CMakeLists.txt | 2 +- 3rdparty/carotene/hal/CMakeLists.txt | 2 +- cmake/OpenCVDetectHalide.cmake | 2 +- modules/python/CMakeLists.txt | 2 +- platforms/android/android.toolchain.cmake | 2 +- platforms/linux/gnu.toolchain.cmake | 2 +- samples/CMakeLists.txt | 2 +- samples/cpp/example_cmake/CMakeLists.txt | 2 +- samples/hal/c_hal/CMakeLists.txt | 2 +- samples/hal/slow_hal/CMakeLists.txt | 2 +- samples/openvx/CMakeLists.txt | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/3rdparty/carotene/CMakeLists.txt b/3rdparty/carotene/CMakeLists.txt index bd26a2d7ef..3d49a2def6 100644 --- a/3rdparty/carotene/CMakeLists.txt +++ b/3rdparty/carotene/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) +cmake_minimum_required(VERSION ${MIN_VER_CMAKE} FATAL_ERROR) project(Carotene) diff --git a/3rdparty/carotene/hal/CMakeLists.txt b/3rdparty/carotene/hal/CMakeLists.txt index 0162aae101..6f209981a6 100644 --- a/3rdparty/carotene/hal/CMakeLists.txt +++ b/3rdparty/carotene/hal/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +cmake_minimum_required(VERSION ${MIN_VER_CMAKE} FATAL_ERROR) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) diff --git a/cmake/OpenCVDetectHalide.cmake b/cmake/OpenCVDetectHalide.cmake index 4828c299ae..dc484a7d3d 100644 --- a/cmake/OpenCVDetectHalide.cmake +++ b/cmake/OpenCVDetectHalide.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION ${MIN_VER_CMAKE}) if(" ${HALIDE_ROOT_DIR}" STREQUAL " ") unset(HALIDE_ROOT_DIR CACHE) diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index a51acf386e..990156074a 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -40,7 +40,7 @@ add_subdirectory(python3) else() # standalone build -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8.12.2) project(OpenCVPython CXX C) include("./standalone.cmake") diff --git a/platforms/android/android.toolchain.cmake b/platforms/android/android.toolchain.cmake index 50b342c7a6..1dca060fdf 100644 --- a/platforms/android/android.toolchain.cmake +++ b/platforms/android/android.toolchain.cmake @@ -189,7 +189,7 @@ # # ------------------------------------------------------------------------------ -cmake_minimum_required( VERSION 2.6.3 ) +cmake_minimum_required( VERSION 2.8.12.2 ) if( DEFINED CMAKE_CROSSCOMPILING ) # subsequent toolchain loading is not really needed diff --git a/platforms/linux/gnu.toolchain.cmake b/platforms/linux/gnu.toolchain.cmake index cba08e7fbb..d8f6c571ca 100644 --- a/platforms/linux/gnu.toolchain.cmake +++ b/platforms/linux/gnu.toolchain.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12.2) # load settings in case of "try compile" set(TOOLCHAIN_CONFIG_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain.config.cmake") diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 68afc487a2..bc8d5097ef 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -56,7 +56,7 @@ else() # Standalone mode # #=================================================================================================== -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12.2) project(samples C CXX) option(BUILD_EXAMPLES "Build samples" ON) diff --git a/samples/cpp/example_cmake/CMakeLists.txt b/samples/cpp/example_cmake/CMakeLists.txt index c669660cef..fb8000ae24 100644 --- a/samples/cpp/example_cmake/CMakeLists.txt +++ b/samples/cpp/example_cmake/CMakeLists.txt @@ -1,5 +1,5 @@ # cmake needs this line -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12.2) # Define project name project(opencv_example_project) diff --git a/samples/hal/c_hal/CMakeLists.txt b/samples/hal/c_hal/CMakeLists.txt index 8502779e84..8cf78aa5ff 100644 --- a/samples/hal/c_hal/CMakeLists.txt +++ b/samples/hal/c_hal/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR) set(PROJECT_NAME "c_hal") set(HAL_LIB_NAME "c_hal") diff --git a/samples/hal/slow_hal/CMakeLists.txt b/samples/hal/slow_hal/CMakeLists.txt index d42fb0b6fd..1ffa4670b6 100644 --- a/samples/hal/slow_hal/CMakeLists.txt +++ b/samples/hal/slow_hal/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR) set(PROJECT_NAME "slow_hal") set(HAL_LIB_NAME "slow_hal") diff --git a/samples/openvx/CMakeLists.txt b/samples/openvx/CMakeLists.txt index 701184d369..fd04e6b9e2 100644 --- a/samples/openvx/CMakeLists.txt +++ b/samples/openvx/CMakeLists.txt @@ -1,6 +1,6 @@ ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt) -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 2.8.12.2) set(OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS opencv_core From 3135063100bba50fe0fff3c83a732e77eeb62ba6 Mon Sep 17 00:00:00 2001 From: Rong Mantle Bao Date: Mon, 11 Jul 2022 18:36:36 +0800 Subject: [PATCH 16/34] Make objdetect/test C++11-compliant and reproducible - Add conditional compilation directives to replace deprecated std::random_shuffle with new std::shuffle when C++11 is available. - Set random seed to a fixed value before shuffling containers to ensure reproducibility. Resolves opencv/opencv#22209. --- modules/objdetect/test/test_precomp.hpp | 6 ++++++ modules/objdetect/test/test_qrcode_encode.cpp | 21 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/objdetect/test/test_precomp.hpp b/modules/objdetect/test/test_precomp.hpp index 4131b43995..14f8b0ede2 100644 --- a/modules/objdetect/test/test_precomp.hpp +++ b/modules/objdetect/test/test_precomp.hpp @@ -8,4 +8,10 @@ #include "opencv2/objdetect.hpp" #include "opencv2/objdetect/objdetect_c.h" +#if defined CV_CXX11 + #include +#else + #include +#endif + #endif diff --git a/modules/objdetect/test/test_qrcode_encode.cpp b/modules/objdetect/test/test_qrcode_encode.cpp index 351e6abc83..9212f338a0 100644 --- a/modules/objdetect/test/test_qrcode_encode.cpp +++ b/modules/objdetect/test/test_qrcode_encode.cpp @@ -5,6 +5,16 @@ #include "test_precomp.hpp" namespace opencv_test { namespace { +#if !defined CV_CXX11 +// Wrapper for generating seeded random number via std::rand. +template +class SeededRandFunctor { +public: + SeededRandFunctor() { std::srand(Seed); } + int operator()(int i) { return std::rand() % (i + 1); } +}; +#endif + std::string encode_qrcode_images_name[] = { "version1_mode1.png", "version1_mode2.png", "version1_mode4.png", "version2_mode1.png", "version2_mode2.png", "version2_mode4.png", @@ -381,8 +391,15 @@ TEST(Objdetect_QRCode_Encode_Decode_Structured_Append, DISABLED_regression) std::string symbol_set = config["symbols_set"]; std::string input_info = symbol_set; - std::random_shuffle(input_info.begin(), input_info.end()); - +#if defined CV_CXX11 + // std::random_shuffle is deprecated since C++11 and removed in C++17. + // Use manually constructed RNG with a fixed seed and std::shuffle instead. + std::mt19937 rand_gen {1}; + std::shuffle(input_info.begin(), input_info.end(), rand_gen); +#else + SeededRandFunctor<1> rand_gen; + std::random_shuffle(input_info.begin(), input_info.end(), rand_gen); +#endif for (int j = min_stuctures_num; j < max_stuctures_num; j++) { QRCodeEncoder::Params params; From ed4bf13960e68c48ced45f53f3cd3c1b41f67b9d Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Tue, 12 Jul 2022 16:24:44 +0200 Subject: [PATCH 17/34] Fix cleanFoundConnectedQuads. --- modules/calib3d/src/calibinit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 1dff8de6e6..309f7bbe58 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -1256,7 +1256,7 @@ int ChessBoardDetector::cleanFoundConnectedQuads(std::vector& q Mat points(1, quad_count, CV_32FC2, ¢ers[0]); cv::convexHull(points, hull, true); centers[skip] = temp; - double hull_area = contourArea(hull, true); + double hull_area = contourArea(hull, false); // remember smallest box area if (hull_area < min_box_area) From 45fbb67abac39631f4447e4f3958998cd200c366 Mon Sep 17 00:00:00 2001 From: Zihao Mu Date: Wed, 13 Jul 2022 11:25:27 +0800 Subject: [PATCH 18/34] fix scale layer can not handle 1x1 weight correctly. --- modules/dnn/src/layers/scale_layer.cpp | 10 +++++++ modules/dnn/src/onnx/onnx_importer.cpp | 37 +++++++++++++++---------- modules/dnn/test/test_onnx_importer.cpp | 2 ++ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/modules/dnn/src/layers/scale_layer.cpp b/modules/dnn/src/layers/scale_layer.cpp index 594b0bb624..406d27b46a 100644 --- a/modules/dnn/src/layers/scale_layer.cpp +++ b/modules/dnn/src/layers/scale_layer.cpp @@ -91,6 +91,16 @@ public: if (hasWeights && hasBias) CV_CheckEQ(weights.total(), bias.total(), "Incompatible weights/bias blobs"); + if (weights.total() == 1) + { + // The total() of bias should be same as weights. + if (hasBias) + inpBlob.convertTo(outBlob, CV_32F, weights.at(0), bias.at(0)); + else + inpBlob.convertTo(outBlob, CV_32F, weights.at(0)); + return; + } + int endAxis; for (endAxis = axis + 1; endAxis <= inpBlob.dims; ++endAxis) { diff --git a/modules/dnn/src/onnx/onnx_importer.cpp b/modules/dnn/src/onnx/onnx_importer.cpp index 7a0532fcf4..8221855e33 100644 --- a/modules/dnn/src/onnx/onnx_importer.cpp +++ b/modules/dnn/src/onnx/onnx_importer.cpp @@ -1818,6 +1818,8 @@ void ONNXImporter::parseMatMul(LayerParams& layerParams, const opencv_onnx::Node void findBroadAxis(const MatShape& broadShape, const MatShape& outShape, size_t& axis, int& broadAxis) { + // Currently, this function can only complete 1-dimensional expansion of broadShape. + // If there are two dimensions in broadShape that need to be expended, it will fail. const size_t diff = outShape.size() - broadShape.size(); // find the first non-one element of the broadcasting shape @@ -1982,25 +1984,30 @@ void ONNXImporter::parseMul(LayerParams& layerParams, const opencv_onnx::NodePro const MatShape& outShape = outShapes[node_proto.input(0)]; size_t axis = 0; - int broadAxis = -1; - findBroadAxis(broadShape, outShape, axis, broadAxis); - - // if there is a one dimension in the middle that should be broadcasted, broadcast it - if (broadAxis != -1) + if (total(broadShape) != 1) { - opencv_onnx::NodeProto concat_node_proto = node_proto; - const std::string& input1 = concat_node_proto.input(1); + // If broadShape is a scalar, we set axis as 0. + // Other-wise, we check broadcast is available. + int broadAxis = -1; + findBroadAxis(broadShape, outShape, axis, broadAxis); + + // if there is a one dimension in the middle that should be broadcasted, broadcast it + if (broadAxis != -1) + { + opencv_onnx::NodeProto concat_node_proto = node_proto; + const std::string& input1 = concat_node_proto.input(1); - expandMid(layerParams.name, concat_node_proto, input1, outShape[broadAxis]); + expandMid(layerParams.name, concat_node_proto, input1, outShape[broadAxis]); - LayerParams concatLP; - concatLP.name = layerParams.name + "/concat"; - concatLP.set("axis", broadAxis); - concatLP.type = "Concat"; - concat_node_proto.set_output(0, concatLP.name); + LayerParams concatLP; + concatLP.name = layerParams.name + "/concat"; + concatLP.set("axis", broadAxis); + concatLP.type = "Concat"; + concat_node_proto.set_output(0, concatLP.name); - addLayer(concatLP, concat_node_proto); - node_proto.set_input(1, concatLP.name); + addLayer(concatLP, concat_node_proto); + node_proto.set_input(1, concatLP.name); + } } CV_Assert(axis != outShape.size()); diff --git a/modules/dnn/test/test_onnx_importer.cpp b/modules/dnn/test/test_onnx_importer.cpp index 56203cba56..3d1dd3858a 100644 --- a/modules/dnn/test/test_onnx_importer.cpp +++ b/modules/dnn/test/test_onnx_importer.cpp @@ -725,6 +725,8 @@ TEST_P(Test_ONNX_layers, Div) normAssert(ref, out, "", default_l1, default_lInf); expectNoFallbacksFromIE(net); + + testONNXModels("div_test_1x1",npy, 0, 0, false, true, 2); } TEST_P(Test_ONNX_layers, DynamicReshape) From d2b1e382070e4580bf4486317b8ca740ac5fda01 Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Thu, 14 Jul 2022 11:17:38 +0300 Subject: [PATCH 19/34] Pragma to ignore -Waggressive-loop-optimizations on Linux ARM64 --- modules/features2d/src/sift.simd.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/features2d/src/sift.simd.hpp b/modules/features2d/src/sift.simd.hpp index b5033459b9..dfe113b9b3 100644 --- a/modules/features2d/src/sift.simd.hpp +++ b/modules/features2d/src/sift.simd.hpp @@ -829,10 +829,14 @@ else // CV_8U v_pack_store(dst + k, __pack01); } #endif +// avoid warning "iteration 7 invokes undefined behavior" on Linux ARM64 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waggressive-loop-optimizations" for( ; k < len; k++ ) { dst[k] = saturate_cast(rawDst[k]*nrm2); } +#pragma GCC diagnostic pop } #else float* dst = dstMat.ptr(row); From bd54ba911db662ab2ec32d0c378bc431c1473d5d Mon Sep 17 00:00:00 2001 From: scorpiozj Date: Sun, 10 Jul 2022 20:39:04 +0800 Subject: [PATCH 20/34] Update imgproc.hpp fix Rect value of integral image example; --- modules/imgproc/include/opencv2/imgproc.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index fd1a5d9721..9ab8999e30 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -2725,7 +2725,7 @@ It makes possible to do a fast blurring or fast block correlation with a variabl example. In case of multi-channel images, sums for each channel are accumulated independently. As a practical example, the next figure shows the calculation of the integral of a straight -rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the +rectangle Rect(4,4,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted . ![integral calculation example](pics/integral.png) From 697acf7f6a1e96fc7df4586f7900da9b863c3ff8 Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Tue, 19 Jul 2022 13:10:05 +0300 Subject: [PATCH 21/34] Linux ARM64 rename ubuntu version on 3.4 --- .github/workflows/PR-3.4.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PR-3.4.yaml b/.github/workflows/PR-3.4.yaml index fcfa924e96..8d954a26cc 100644 --- a/.github/workflows/PR-3.4.yaml +++ b/.github/workflows/PR-3.4.yaml @@ -6,7 +6,7 @@ on: - 3.4 jobs: - Ubuntu1804-ARM64: + Ubuntu2004-ARM64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-ARM64.yaml@main Ubuntu2004-x64: From 1feabf42755a3c6011674b40aed9d735048c97fd Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Tue, 19 Jul 2022 13:52:29 +0300 Subject: [PATCH 22/34] Fixed an issue with a recursion of cv2 in python --- modules/python/package/cv2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/python/package/cv2/__init__.py b/modules/python/package/cv2/__init__.py index f8e631382c..086fc48dec 100644 --- a/modules/python/package/cv2/__init__.py +++ b/modules/python/package/cv2/__init__.py @@ -40,7 +40,7 @@ def bootstrap(): BINARIES_PATHS = [] g_vars = globals() - l_vars = locals() + l_vars = locals().copy() if sys.version_info[:2] < (3, 0): from . load_config_py2 import exec_file_wrapper From b3269b08a19d1da49cf63754d92bdbd39e22c568 Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Wed, 20 Jul 2022 19:25:39 +0900 Subject: [PATCH 23/34] neon: add dotprod dispatch implementation * read vector at runtime * add enum --- cmake/OpenCVCompilerOptimizations.cmake | 7 +- cmake/checks/cpu_dotprod.cpp | 24 +++++++ modules/core/CMakeLists.txt | 2 +- .../include/opencv2/core/cv_cpu_dispatch.h | 4 ++ .../core/include/opencv2/core/cv_cpu_helper.h | 21 ++++++ modules/core/include/opencv2/core/cvdef.h | 2 + .../include/opencv2/core/hal/intrin_neon.hpp | 65 +++++++++---------- modules/core/src/system.cpp | 19 ++++++ 8 files changed, 106 insertions(+), 38 deletions(-) create mode 100644 cmake/checks/cpu_dotprod.cpp diff --git a/cmake/OpenCVCompilerOptimizations.cmake b/cmake/OpenCVCompilerOptimizations.cmake index 058443821a..1e0e812afc 100644 --- a/cmake/OpenCVCompilerOptimizations.cmake +++ b/cmake/OpenCVCompilerOptimizations.cmake @@ -46,7 +46,7 @@ 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_CLX;AVX512_ICL") -list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16) +list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16 NEON_DOTPROD) list(APPEND CPU_ALL_OPTIMIZATIONS MSA) list(APPEND CPU_ALL_OPTIMIZATIONS VSX VSX3) list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS) @@ -326,6 +326,7 @@ if(X86 OR X86_64) elseif(ARM OR AARCH64) ocv_update(CPU_NEON_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_neon.cpp") ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp") + ocv_update(CPU_NEON_DOTPROD_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_dotprod.cpp") if(NOT AARCH64) ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16") if(NOT MSVC) @@ -337,9 +338,11 @@ elseif(ARM OR AARCH64) endif() ocv_update(CPU_FP16_IMPLIES "NEON") else() - ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16") + ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16;NEON_DOTPROD") ocv_update(CPU_NEON_FLAGS_ON "") ocv_update(CPU_FP16_IMPLIES "NEON") + ocv_update(CPU_NEON_DOTPROD_FLAGS_ON "-march=armv8.2-a+dotprod") + ocv_update(CPU_NEON_DOTPROD_IMPLIES "NEON") set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}") endif() elseif(MIPS) diff --git a/cmake/checks/cpu_dotprod.cpp b/cmake/checks/cpu_dotprod.cpp new file mode 100644 index 0000000000..4f39c50659 --- /dev/null +++ b/cmake/checks/cpu_dotprod.cpp @@ -0,0 +1,24 @@ +#include + +#if defined __GNUC__ && (defined __arm__ || defined __aarch64__) +#include "arm_neon.h" +int test() +{ + const unsigned int src[] = { 0, 0, 0, 0 }; + unsigned int dst[4]; + uint32x4_t v_src = *(uint32x4_t*)src; + uint8x16_t v_m0 = *(uint8x16_t*)src; + uint8x16_t v_m1 = *(uint8x16_t*)src; + uint32x4_t v_dst = vdotq_u32(v_src, v_m0, v_m1); + *(uint32x4_t*)dst = v_dst; + return (int)dst[0]; +} +#else +#error "DOTPROD is not supported" +#endif + +int main() +{ + printf("%d\n", test()); + return 0; +} diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 568a8afef1..0163cf570c 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -6,7 +6,7 @@ ocv_add_dispatched_file(arithm SSE2 SSE4_1 AVX2 VSX3) ocv_add_dispatched_file(convert SSE2 AVX2 VSX3) ocv_add_dispatched_file(convert_scale SSE2 AVX2) ocv_add_dispatched_file(count_non_zero SSE2 AVX2) -ocv_add_dispatched_file(matmul SSE2 SSE4_1 AVX2 AVX512_SKX) +ocv_add_dispatched_file(matmul SSE2 SSE4_1 AVX2 AVX512_SKX NEON_DOTPROD) ocv_add_dispatched_file(mean SSE2 AVX2) ocv_add_dispatched_file(merge SSE2 AVX2) ocv_add_dispatched_file(split SSE2 AVX2) diff --git a/modules/core/include/opencv2/core/cv_cpu_dispatch.h b/modules/core/include/opencv2/core/cv_cpu_dispatch.h index e92798d6c9..758f905a64 100644 --- a/modules/core/include/opencv2/core/cv_cpu_dispatch.h +++ b/modules/core/include/opencv2/core/cv_cpu_dispatch.h @@ -79,6 +79,10 @@ # endif # define CV_FP16 1 #endif +#ifdef CV_CPU_COMPILE_NEON_DOTPROD +# include +# define CV_NEON_DOT 1 +#endif #ifdef CV_CPU_COMPILE_AVX2 # include # define CV_AVX2 1 diff --git a/modules/core/include/opencv2/core/cv_cpu_helper.h b/modules/core/include/opencv2/core/cv_cpu_helper.h index aaa89ed415..25cf3477c3 100644 --- a/modules/core/include/opencv2/core/cv_cpu_helper.h +++ b/modules/core/include/opencv2/core/cv_cpu_helper.h @@ -420,6 +420,27 @@ #endif #define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(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_NEON_DOTPROD +# define CV_TRY_NEON_DOTPROD 1 +# define CV_CPU_FORCE_NEON_DOTPROD 1 +# define CV_CPU_HAS_SUPPORT_NEON_DOTPROD 1 +# define CV_CPU_CALL_NEON_DOTPROD(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_NEON_DOTPROD_(fn, args) return (opt_NEON_DOTPROD::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON_DOTPROD +# define CV_TRY_NEON_DOTPROD 1 +# define CV_CPU_FORCE_NEON_DOTPROD 0 +# define CV_CPU_HAS_SUPPORT_NEON_DOTPROD (cv::checkHardwareSupport(CV_CPU_NEON_DOTPROD)) +# define CV_CPU_CALL_NEON_DOTPROD(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_DOTPROD) return (opt_NEON_DOTPROD::fn args) +# define CV_CPU_CALL_NEON_DOTPROD_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_DOTPROD) return (opt_NEON_DOTPROD::fn args) +#else +# define CV_TRY_NEON_DOTPROD 0 +# define CV_CPU_FORCE_NEON_DOTPROD 0 +# define CV_CPU_HAS_SUPPORT_NEON_DOTPROD 0 +# define CV_CPU_CALL_NEON_DOTPROD(fn, args) +# define CV_CPU_CALL_NEON_DOTPROD_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_NEON_DOTPROD(fn, args, mode, ...) CV_CPU_CALL_NEON_DOTPROD(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_MSA # define CV_TRY_MSA 1 # define CV_CPU_FORCE_MSA 1 diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index c2cdcad075..9102316968 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -282,6 +282,7 @@ namespace cv { #define CV_CPU_AVX_5124FMAPS 27 #define CV_CPU_NEON 100 +#define CV_CPU_NEON_DOTPROD 101 #define CV_CPU_MSA 150 @@ -334,6 +335,7 @@ enum CpuFeatures { CPU_AVX_5124FMAPS = 27, CPU_NEON = 100, + CPU_NEON_DOTPROD = 101, CPU_MSA = 150, diff --git a/modules/core/include/opencv2/core/hal/intrin_neon.hpp b/modules/core/include/opencv2/core/hal/intrin_neon.hpp index e17972a3fc..5792694a40 100644 --- a/modules/core/include/opencv2/core/hal/intrin_neon.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_neon.hpp @@ -78,8 +78,6 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN #define CV_NEON_AARCH64 0 #endif -// TODO -#define CV_NEON_DOT 0 //////////// Utils //////////// @@ -667,11 +665,22 @@ inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64 } // 8 >> 32 +#ifdef CV_NEON_DOT +#define OPENCV_HAL_IMPL_NEON_DOT_PRODUCT_OP(_Tpvec1, _Tpvec2, suffix) \ +inline _Tpvec1 v_dotprod_expand(const _Tpvec2& a, const _Tpvec2& b) \ +{ \ + return _Tpvec1(vdotq_##suffix(vdupq_n_##suffix(0), a.val, b.val));\ +} \ +inline _Tpvec1 v_dotprod_expand(const _Tpvec2& a, const _Tpvec2& b, const _Tpvec1& c) \ +{ \ + return _Tpvec1(vdotq_##suffix(c.val, a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_NEON_DOT_PRODUCT_OP(v_uint32x4, v_uint8x16, u32) +OPENCV_HAL_IMPL_NEON_DOT_PRODUCT_OP(v_int32x4, v_int8x16, s32) +#else inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) { -#if CV_NEON_DOT - return v_uint32x4(vdotq_u32(vdupq_n_u32(0), a.val, b.val)); -#else const uint8x16_t zero = vreinterpretq_u8_u32(vdupq_n_u32(0)); const uint8x16_t mask = vreinterpretq_u8_u32(vdupq_n_u32(0x00FF00FF)); const uint16x8_t zero32 = vreinterpretq_u16_u32(vdupq_n_u32(0)); @@ -687,23 +696,15 @@ inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) uint32x4_t s1 = vaddq_u32(vshrq_n_u32(vreinterpretq_u32_u16(even), 16), vshrq_n_u32(vreinterpretq_u32_u16(odd), 16)); return v_uint32x4(vaddq_u32(s0, s1)); -#endif } inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) { -#if CV_NEON_DOT - return v_uint32x4(vdotq_u32(c.val, a.val, b.val)); -#else return v_dotprod_expand(a, b) + c; -#endif } inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) { -#if CV_NEON_DOT - return v_int32x4(vdotq_s32(vdupq_n_s32(0), a.val, b.val)); -#else int16x8_t p0 = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); int16x8_t p1 = vmull_s8(vget_high_s8(a.val), vget_high_s8(b.val)); int16x8_t uzp1, uzp2; @@ -712,18 +713,13 @@ inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) int16x4_t uzpl1, uzpl2; _v128_unzip(vget_low_s16(sum), vget_high_s16(sum), uzpl1, uzpl2); return v_int32x4(vaddl_s16(uzpl1, uzpl2)); -#endif } inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) { -#if CV_NEON_DOT - return v_int32x4(vdotq_s32(c.val, a.val, b.val)); -#else return v_dotprod_expand(a, b) + c; -#endif } - +#endif // 16 >> 64 inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) { @@ -832,45 +828,44 @@ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_ } // 8 >> 32 +#ifdef CV_NEON_DOT +#define OPENCV_HAL_IMPL_NEON_DOT_PRODUCT_FAST_OP(_Tpvec1, _Tpvec2, suffix) \ +inline _Tpvec1 v_dotprod_expand_fast(const _Tpvec2& a, const _Tpvec2& b) \ +{ \ + return v_dotprod_expand(a, b); \ +} \ +inline _Tpvec1 v_dotprod_expand_fast(const _Tpvec2& a, const _Tpvec2& b, const _Tpvec1& c) \ +{ \ + return v_dotprod_expand(a, b, c); \ +} + +OPENCV_HAL_IMPL_NEON_DOT_PRODUCT_FAST_OP(v_uint32x4, v_uint8x16, u32) +OPENCV_HAL_IMPL_NEON_DOT_PRODUCT_FAST_OP(v_int32x4, v_int8x16, s32) +#else inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) { -#if CV_NEON_DOT - return v_uint32x4(vdotq_u32(vdupq_n_u32(0), a.val, b.val)); -#else uint16x8_t p0 = vmull_u8(vget_low_u8(a.val), vget_low_u8(b.val)); uint16x8_t p1 = vmull_u8(vget_high_u8(a.val), vget_high_u8(b.val)); uint32x4_t s0 = vaddl_u16(vget_low_u16(p0), vget_low_u16(p1)); uint32x4_t s1 = vaddl_u16(vget_high_u16(p0), vget_high_u16(p1)); return v_uint32x4(vaddq_u32(s0, s1)); -#endif } inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) { -#if CV_NEON_DOT - return v_uint32x4(vdotq_u32(c.val, a.val, b.val)); -#else return v_dotprod_expand_fast(a, b) + c; -#endif } inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) { -#if CV_NEON_DOT - return v_int32x4(vdotq_s32(vdupq_n_s32(0), a.val, b.val)); -#else int16x8_t prod = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); prod = vmlal_s8(prod, vget_high_s8(a.val), vget_high_s8(b.val)); return v_int32x4(vaddl_s16(vget_low_s16(prod), vget_high_s16(prod))); -#endif } inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) { -#if CV_NEON_DOT - return v_int32x4(vdotq_s32(c.val, a.val, b.val)); -#else return v_dotprod_expand_fast(a, b) + c; -#endif } +#endif // 16 >> 64 inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index adb957908d..3507009196 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -411,6 +411,7 @@ struct HWFeatures g_hwFeatureNames[CPU_AVX_5124FMAPS] = "AVX5124FMAPS"; g_hwFeatureNames[CPU_NEON] = "NEON"; + g_hwFeatureNames[CPU_NEON_DOTPROD] = "NEON_DOTPROD"; g_hwFeatureNames[CPU_VSX] = "VSX"; g_hwFeatureNames[CPU_VSX3] = "VSX3"; @@ -555,6 +556,24 @@ struct HWFeatures #ifdef __aarch64__ have[CV_CPU_NEON] = true; have[CV_CPU_FP16] = true; + int cpufile = open("/proc/self/auxv", O_RDONLY); + + if (cpufile >= 0) + { + Elf64_auxv_t auxv; + const size_t size_auxv_t = sizeof(auxv); + + while ((size_t)read(cpufile, &auxv, size_auxv_t) == size_auxv_t) + { + if (auxv.a_type == AT_HWCAP) + { + have[CV_CPU_NEON_DOTPROD] = (auxv.a_un.a_val & (1 << 20)) != 0; + break; + } + } + + close(cpufile); + } #elif defined __arm__ && defined __ANDROID__ #if defined HAVE_CPUFEATURES CV_LOG_INFO(NULL, "calling android_getCpuFeatures() ..."); From a016f6022c2786f827a811731f2bde605ba54526 Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Thu, 21 Jul 2022 17:47:55 +0300 Subject: [PATCH 24/34] Android GHA workflow for 3.4 branch --- .github/workflows/PR-3.4.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/PR-3.4.yaml b/.github/workflows/PR-3.4.yaml index fcfa924e96..d528f861e0 100644 --- a/.github/workflows/PR-3.4.yaml +++ b/.github/workflows/PR-3.4.yaml @@ -23,3 +23,6 @@ jobs: iOS: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-iOS.yaml@main + + Android: + uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-Android.yaml@main From f7292022727e091251f9c8f69a90d90020613b35 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Sun, 24 Jul 2022 11:30:08 +0300 Subject: [PATCH 25/34] core: remove unnecessary pointer cleanup in BufferArea --- modules/core/src/buffer_area.cpp | 3 +-- modules/core/test/test_utils.cpp | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/core/src/buffer_area.cpp b/modules/core/src/buffer_area.cpp index 2fe9d782ae..91e6cb966f 100644 --- a/modules/core/src/buffer_area.cpp +++ b/modules/core/src/buffer_area.cpp @@ -29,8 +29,7 @@ public: } void cleanup() const { - CV_Assert(ptr && *ptr); - *ptr = 0; + CV_DbgAssert(ptr); if (raw_mem) fastFree(raw_mem); } diff --git a/modules/core/test/test_utils.cpp b/modules/core/test/test_utils.cpp index d8789ddfc2..611c4b2106 100644 --- a/modules/core/test/test_utils.cpp +++ b/modules/core/test/test_utils.cpp @@ -403,9 +403,6 @@ TEST_P(BufferArea, basic) EXPECT_EQ((double)0, dbl_ptr[i]); } } - EXPECT_TRUE(int_ptr == NULL); - EXPECT_TRUE(uchar_ptr == NULL); - EXPECT_TRUE(dbl_ptr == NULL); } TEST_P(BufferArea, align) @@ -442,10 +439,6 @@ TEST_P(BufferArea, align) } } } - for (size_t i = 0; i < CNT; ++i) - { - EXPECT_TRUE(buffers[i] == NULL); - } } TEST_P(BufferArea, default_align) From 85b0b0cd7701f03f8053a59e17cf8c6f08dffdfc Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 24 Jul 2022 12:19:37 +0300 Subject: [PATCH 26/34] build: add missing GCC condition for pragma --- modules/features2d/src/sift.simd.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/features2d/src/sift.simd.hpp b/modules/features2d/src/sift.simd.hpp index dfe113b9b3..8a038612c4 100644 --- a/modules/features2d/src/sift.simd.hpp +++ b/modules/features2d/src/sift.simd.hpp @@ -829,14 +829,19 @@ else // CV_8U v_pack_store(dst + k, __pack01); } #endif + +#if defined(__GNUC__) && __GNUC__ >= 9 // avoid warning "iteration 7 invokes undefined behavior" on Linux ARM64 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waggressive-loop-optimizations" +#endif for( ; k < len; k++ ) { dst[k] = saturate_cast(rawDst[k]*nrm2); } +#if defined(__GNUC__) && __GNUC__ >= 9 #pragma GCC diagnostic pop +#endif } #else float* dst = dstMat.ptr(row); From f8597fc1506581a996fb4ef385a57816b87ab077 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 24 Jul 2022 12:39:25 +0300 Subject: [PATCH 27/34] imgproc: fixup leftovers of int->int64_t conversion --- modules/imgproc/src/drawing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp index 81d56075ca..0e938a644d 100644 --- a/modules/imgproc/src/drawing.cpp +++ b/modules/imgproc/src/drawing.cpp @@ -1040,7 +1040,7 @@ EllipseEx( Mat& img, Point2l center, Size2l axes, * Polygons filling * \****************************************************************************************/ -static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, int pix_size) +static inline void ICV_HLINE_X(uchar* ptr, int64_t xl, int64_t xr, const uchar* color, int pix_size) { uchar* hline_min_ptr = (uchar*)(ptr) + (xl)*(pix_size); uchar* hline_end_ptr = (uchar*)(ptr) + (xr+1)*(pix_size); @@ -1065,7 +1065,7 @@ static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, i } //end ICV_HLINE_X() -static inline void ICV_HLINE(uchar* ptr, int xl, int xr, const void* color, int pix_size) +static inline void ICV_HLINE(uchar* ptr, int64_t xl, int64_t xr, const void* color, int pix_size) { ICV_HLINE_X(ptr, xl, xr, reinterpret_cast(color), pix_size); } From 5bf3991f55ae264d53ce623e2b4763cc315145e3 Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Wed, 27 Jul 2022 10:19:34 +0300 Subject: [PATCH 28/34] Workflow on Ubuntu 14.04 for 3.4 branch --- .github/workflows/PR-3.4.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/PR-3.4.yaml b/.github/workflows/PR-3.4.yaml index 9658e4ef86..03267d987c 100644 --- a/.github/workflows/PR-3.4.yaml +++ b/.github/workflows/PR-3.4.yaml @@ -9,6 +9,9 @@ jobs: Ubuntu2004-ARM64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-ARM64.yaml@main + Ubuntu1404-x64: + uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-U14.yaml@main + Ubuntu2004-x64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-U20.yaml@main From e7a787aa419225d571e1ac72c071dcf8b9dc1c37 Mon Sep 17 00:00:00 2001 From: "gbowser3@gmail.com" Date: Sun, 31 Jul 2022 19:22:10 -0500 Subject: [PATCH 29/34] Imgproc: Fix doxygen typo --- modules/imgproc/include/opencv2/imgproc.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 9ab8999e30..c04b5b67a9 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -2199,7 +2199,7 @@ case of multi-channel images, each channel is processed independently. @param src input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. @param dst output image of the same size and type as src. -@param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular +@param kernel structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement @param anchor position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center. From 4c9364a8036edfaaa87f18e389e50037739730ce Mon Sep 17 00:00:00 2001 From: Andrey Senyaev Date: Mon, 1 Aug 2022 10:04:57 +0300 Subject: [PATCH 30/34] Docs workflow in GHA for 3.4 --- .github/workflows/PR-3.4.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/PR-3.4.yaml b/.github/workflows/PR-3.4.yaml index 9658e4ef86..26201fb6d6 100644 --- a/.github/workflows/PR-3.4.yaml +++ b/.github/workflows/PR-3.4.yaml @@ -26,3 +26,6 @@ jobs: Android: uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-Android.yaml@main + + docs: + uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-3.4-docs.yaml@main From 44b2f9637a7cac9069de276076db95a0d433a142 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 7 Aug 2022 15:43:10 +0300 Subject: [PATCH 31/34] Revert "suppress warning on GCC 7 and later" This reverts commit a630ad73cb5dde7f8c69e86094bd4a1070ff0249. --- 3rdparty/openexr/CMakeLists.txt | 4 ---- 3rdparty/protobuf/CMakeLists.txt | 4 ---- modules/calib3d/CMakeLists.txt | 4 ---- modules/core/CMakeLists.txt | 4 ---- modules/dnn/CMakeLists.txt | 4 ---- modules/features2d/CMakeLists.txt | 4 ---- modules/flann/CMakeLists.txt | 4 ---- modules/imgproc/CMakeLists.txt | 4 ---- modules/ml/CMakeLists.txt | 4 ---- modules/objdetect/CMakeLists.txt | 4 ---- modules/shape/CMakeLists.txt | 4 ---- modules/stitching/CMakeLists.txt | 4 ---- modules/ts/CMakeLists.txt | 4 ---- samples/cpp/CMakeLists.txt | 4 ---- 14 files changed, 56 deletions(-) diff --git a/3rdparty/openexr/CMakeLists.txt b/3rdparty/openexr/CMakeLists.txt index 1fbfa4f857..88f60b23c0 100644 --- a/3rdparty/openexr/CMakeLists.txt +++ b/3rdparty/openexr/CMakeLists.txt @@ -110,10 +110,6 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -W -Wreorder -Wunused-result ) -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess) endif() diff --git a/3rdparty/protobuf/CMakeLists.txt b/3rdparty/protobuf/CMakeLists.txt index f8372dc1ad..f249d2dcc3 100644 --- a/3rdparty/protobuf/CMakeLists.txt +++ b/3rdparty/protobuf/CMakeLists.txt @@ -25,10 +25,6 @@ else() -Warray-bounds # GCC 9+ ) endif() -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() if(CV_ICC) ocv_warnings_disable(CMAKE_CXX_FLAGS -wd265 -wd858 -wd873 -wd2196 diff --git a/modules/calib3d/CMakeLists.txt b/modules/calib3d/CMakeLists.txt index 1c31ad1903..a38fdf18d8 100644 --- a/modules/calib3d/CMakeLists.txt +++ b/modules/calib3d/CMakeLists.txt @@ -3,10 +3,6 @@ set(debug_modules "") if(DEBUG_opencv_calib3d) list(APPEND debug_modules opencv_highgui) endif() -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_define_module(calib3d opencv_imgproc opencv_features2d ${debug_modules} WRAP java python js ) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 568a8afef1..beba9f804e 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -38,10 +38,6 @@ endif() if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wenum-compare -Wunused-function -Wshadow) endif() -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() if(CV_TRACE AND HAVE_ITT) add_definitions(-DOPENCV_WITH_ITT=1) diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 680be360ba..4019356392 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -35,10 +35,6 @@ else() -Wunused-parameter -Wsign-compare ) endif() -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) endif() diff --git a/modules/features2d/CMakeLists.txt b/modules/features2d/CMakeLists.txt index 28af58565b..1d29320a14 100644 --- a/modules/features2d/CMakeLists.txt +++ b/modules/features2d/CMakeLists.txt @@ -1,10 +1,6 @@ set(the_description "2D Features Framework") ocv_add_dispatched_file(sift SSE4_1 AVX2 AVX512_SKX) -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() set(debug_modules "") if(DEBUG_opencv_features2d) diff --git a/modules/flann/CMakeLists.txt b/modules/flann/CMakeLists.txt index 5935f679d4..78e041129b 100644 --- a/modules/flann/CMakeLists.txt +++ b/modules/flann/CMakeLists.txt @@ -1,6 +1,2 @@ set(the_description "Clustering and Search in Multi-Dimensional Spaces") -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_define_module(flann opencv_core WRAP python) diff --git a/modules/imgproc/CMakeLists.txt b/modules/imgproc/CMakeLists.txt index 5787ec502c..3b45482481 100644 --- a/modules/imgproc/CMakeLists.txt +++ b/modules/imgproc/CMakeLists.txt @@ -12,10 +12,6 @@ ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2) ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX) ocv_add_dispatched_file(undistort SSE2 AVX2) ocv_define_module(imgproc opencv_core WRAP java python js) -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_check_environment_variables(OPENCV_IPP_GAUSSIAN_BLUR) option(OPENCV_IPP_GAUSSIAN_BLUR "Enable IPP optimizations for GaussianBlur (+8Mb in binary size)" OFF) diff --git a/modules/ml/CMakeLists.txt b/modules/ml/CMakeLists.txt index 8b76e0c8ad..1b64cc4f17 100644 --- a/modules/ml/CMakeLists.txt +++ b/modules/ml/CMakeLists.txt @@ -1,6 +1,2 @@ set(the_description "Machine Learning") -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_define_module(ml opencv_core WRAP java python) diff --git a/modules/objdetect/CMakeLists.txt b/modules/objdetect/CMakeLists.txt index 34b77eab6b..414e578099 100644 --- a/modules/objdetect/CMakeLists.txt +++ b/modules/objdetect/CMakeLists.txt @@ -1,8 +1,4 @@ set(the_description "Object Detection") -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_define_module(objdetect opencv_core opencv_imgproc opencv_calib3d WRAP java python js) if(HAVE_QUIRC) diff --git a/modules/shape/CMakeLists.txt b/modules/shape/CMakeLists.txt index 209eb11f34..527a0c2f71 100644 --- a/modules/shape/CMakeLists.txt +++ b/modules/shape/CMakeLists.txt @@ -1,6 +1,2 @@ set(the_description "Shape descriptors and matchers") -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_define_module(shape opencv_core opencv_imgproc opencv_video WRAP python) diff --git a/modules/stitching/CMakeLists.txt b/modules/stitching/CMakeLists.txt index 7ea34a1608..44f35eb59b 100644 --- a/modules/stitching/CMakeLists.txt +++ b/modules/stitching/CMakeLists.txt @@ -3,10 +3,6 @@ set(the_description "Images stitching") if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations -Wshadow -Wstrict-aliasing) endif() -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d") if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES) diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index fd6e008333..f95bed0793 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -15,10 +15,6 @@ if(WINRT) endif() ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) -if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) -endif() ocv_add_module(ts INTERNAL opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui) diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 8cb11c0222..6ae9586fd4 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -41,10 +41,6 @@ foreach(sample_filename ${cpp_samples}) ocv_warnings_disable(CMAKE_CXX_FLAGS -Winconsistent-missing-override -Wsuggest-override) endif() endif() - if(ARM AND CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # suppress warnings from GCC only on 7.1 and later - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) - endif() set(package "cpp") if(sample_filename MATCHES "tutorial_code") set(package "tutorial") From 75bb6aa9a1571875257742d2bf5c5593c5cca6d2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 7 Aug 2022 15:46:44 +0300 Subject: [PATCH 32/34] build: disable psabi warning with GCC 7.0 and ARM --- cmake/OpenCVCompilerOptions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index bbfd889690..db7b0e1b8c 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -134,7 +134,7 @@ if(CV_GCC OR CV_CLANG) add_extra_compiler_option(-Wshadow) add_extra_compiler_option(-Wsign-promo) add_extra_compiler_option(-Wuninitialized) - if(CV_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)) + if(CV_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0 OR ARM)) add_extra_compiler_option(-Wno-psabi) endif() if(HAVE_CXX11) From 496eed950f6d0e7fd92619d47e3cec8f06e96ace Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Mon, 8 Aug 2022 21:10:13 +0200 Subject: [PATCH 33/34] Add missing header for LIBAVCODEC_VERSION_INT --- modules/videoio/src/ffmpeg_codecs.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/videoio/src/ffmpeg_codecs.hpp b/modules/videoio/src/ffmpeg_codecs.hpp index 61788e0345..faad2596ed 100644 --- a/modules/videoio/src/ffmpeg_codecs.hpp +++ b/modules/videoio/src/ffmpeg_codecs.hpp @@ -60,6 +60,7 @@ extern "C" { #include #endif +#include #include #ifdef __cplusplus From 3d8614cb476341267ecd195d77f4aa6ab9792275 Mon Sep 17 00:00:00 2001 From: catree Date: Fri, 12 Aug 2022 10:37:09 +0200 Subject: [PATCH 34/34] Fix documentation about depth combinations for imgproc functions. --- modules/imgproc/include/opencv2/imgproc.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index c04b5b67a9..2ea2ec969e 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -78,11 +78,15 @@ Input depth (src.depth()) | Output depth (ddepth) --------------------------|---------------------- CV_8U | -1/CV_16S/CV_32F/CV_64F CV_16U/CV_16S | -1/CV_32F/CV_64F -CV_32F | -1/CV_32F/CV_64F +CV_32F | -1/CV_32F CV_64F | -1/CV_64F @note when ddepth=-1, the output image will have the same depth as the source. +@note if you need double floating-point accuracy and using single floating-point input data +(CV_32F input and CV_64F output depth combination), you can use @ref Mat.convertTo to convert +the input data to the desired precision. + @defgroup imgproc_transform Geometric Image Transformations The functions in this section perform various geometrical transformations of 2D images. They do not @@ -1753,7 +1757,7 @@ with the following \f$3 \times 3\f$ aperture: @param src Source image. @param dst Destination image of the same size and the same number of channels as src . -@param ddepth Desired depth of the destination image. +@param ddepth Desired depth of the destination image, see @ref filter_depths "combinations". @param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for details. The size must be positive and odd. @param scale Optional scale factor for the computed Laplacian values. By default, no scaling is