From 28b6a33d64c150e76da66f19b03c657c7b4fd05d Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Wed, 12 Mar 2025 16:01:47 +0000 Subject: [PATCH] Remove Gaussian blur related OpenCV patch It is not needed to patch OpenCV to use KleidiCV's HAL implementation, only the ALGO_HINT_APPROX hint parameter needs to be used. --- adapters/opencv/opencv-4.11.patch | 78 ++++++++++--------------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/adapters/opencv/opencv-4.11.patch b/adapters/opencv/opencv-4.11.patch index 2d4163e9b..048eb9a9e 100644 --- a/adapters/opencv/opencv-4.11.patch +++ b/adapters/opencv/opencv-4.11.patch @@ -19,7 +19,7 @@ index 2b4035285f..729cd1dd43 100644 @@ -281,6 +281,11 @@ void Mat::convertTo(OutputArray dst, int type_, double alpha, double beta) const dst.create(dims, size, dtype); Mat dstMat = dst.getMat(); - + + if( dims <= 2 ) { + int width_in_elements = src.cols * cn; + CALL_HAL(convertTo, cv_hal_convertTo, src.data, src.step, src.depth(), dstMat.data, dstMat.step, dstMat.depth(), width_in_elements, src.rows, alpha, beta); @@ -35,7 +35,7 @@ index 474fe17393..5d5289cc16 100644 @@ -1011,6 +1011,53 @@ inline int hal_ni_transpose2d(const uchar* src_data, size_t src_step, uchar* dst #define cv_hal_transpose2d hal_ni_transpose2d //! @endcond - + +/** + @brief sum + @param src_data,src_step,src_type Source image @@ -84,15 +84,15 @@ index 474fe17393..5d5289cc16 100644 +//! @endcond + //! @} - - + + diff --git a/modules/core/src/sum.dispatch.cpp b/modules/core/src/sum.dispatch.cpp index fade948336..17b40ca0e8 100644 --- a/modules/core/src/sum.dispatch.cpp +++ b/modules/core/src/sum.dispatch.cpp @@ -199,6 +199,10 @@ Scalar sum(InputArray _src) CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_sum(src, _res), _res); - + int k, cn = src.channels(), depth = src.depth(); + + double result = 0; @@ -100,7 +100,7 @@ index fade948336..17b40ca0e8 100644 + SumFunc func = getSumFunc(depth); CV_Assert( cn <= 4 && func != 0 ); - + diff --git a/modules/imgproc/src/hal_replacement.hpp b/modules/imgproc/src/hal_replacement.hpp index fe6019e3a7..b2d8c8b533 100644 --- a/modules/imgproc/src/hal_replacement.hpp @@ -108,7 +108,7 @@ index fe6019e3a7..b2d8c8b533 100644 @@ -378,6 +378,60 @@ inline int hal_ni_remap32f(int src_type, const uchar *src_data, size_t src_step, #define cv_hal_remap32f hal_ni_remap32f //! @endcond - + +/** + @brief hal_remap with a short integer map + @param src_type source and destination image type @@ -183,59 +183,16 @@ index dfc718bf87..c1f953f230 100644 + CALL_HAL(remap16s16u, cv_hal_remap16s16u, src.type(), src.data, src.step, src.cols, src.rows, dst.data, dst.step, dst.cols, dst.rows, + map1.ptr(), map1.step, map2.ptr(), map2.step, borderType, borderValue.val); } - + interpolation &= ~WARP_RELATIVE_MAP; -diff --git a/modules/imgproc/src/smooth.dispatch.cpp b/modules/imgproc/src/smooth.dispatch.cpp -index f7dafbd956..13c1341716 100644 ---- a/modules/imgproc/src/smooth.dispatch.cpp -+++ b/modules/imgproc/src/smooth.dispatch.cpp -@@ -655,6 +655,25 @@ void GaussianBlur(InputArray _src, OutputArray _dst, Size ksize, - ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType) - ); - -+ { -+ Mat src = _src.getMat(); -+ Mat dst = _dst.getMat(); -+ -+ Point ofs; -+ Size wsz(src.cols, src.rows); -+ if(!(borderType & BORDER_ISOLATED)) -+ src.locateROI( wsz, ofs ); -+ -+ if (sigma1 == 0.0 && sigma2 == 0.0 && ksize.height == ksize.width) { -+ CALL_HAL(gaussianBlurBinomial, cv_hal_gaussianBlurBinomial, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, sdepth, cn, -+ ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, borderType&~BORDER_ISOLATED); -+ } -+ -+ CALL_HAL(gaussianBlur, cv_hal_gaussianBlur, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, sdepth, cn, -+ ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, ksize.height, -+ sigma1, sigma2, borderType&~BORDER_ISOLATED); -+ } -+ - if(sdepth == CV_8U && ((borderType & BORDER_ISOLATED) || !_src.isSubmatrix())) - { - std::vector fkx, fky; -diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp -index 673c6f03e6..56d9e0b554 100644 ---- a/modules/imgproc/test/test_imgwarp_strict.cpp -+++ b/modules/imgproc/test/test_imgwarp_strict.cpp -@@ -239,7 +239,7 @@ float CV_ImageWarpBaseTest::get_success_error_level(int _interpolation, int) con - else if (_interpolation == INTER_AREA) - return 2.0f; - else -- return 1.0f; -+ return 4.0f; // Reference algorithm uses integer interpolation with 5 bits fractional part, and this greater tolerance allows better precision algorithms to pass the test - } - - void CV_ImageWarpBaseTest::validate_results() const diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp -index e8840d231b..adfaad38b0 100644 +index 4cf99b4704..332bc10f06 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1371,7 +1371,13 @@ TEST_P(Imgproc_RemapRelative, validity) cv::remap(src, dstRelative, mapRelativeX32F, mapRelativeY32F, interpolation | WARP_RELATIVE_MAP, borderType); } - + - EXPECT_EQ(cvtest::norm(dstAbsolute, dstRelative, NORM_INF), 0); + if (interpolation != INTER_LINEAR) { + EXPECT_EQ(cvtest::norm(dstAbsolute, dstRelative, NORM_INF), 0); @@ -245,5 +202,18 @@ index e8840d231b..adfaad38b0 100644 + EXPECT_LT(cvtest::norm(dstAbsolute, dstRelative, NORM_INF), 1 << (src.elemSize1() * CHAR_BIT - INTER_BITS)); + } }; - + INSTANTIATE_TEST_CASE_P(ImgProc, Imgproc_RemapRelative, testing::Combine( +diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp +index 673c6f03e6..56d9e0b554 100644 +--- a/modules/imgproc/test/test_imgwarp_strict.cpp ++++ b/modules/imgproc/test/test_imgwarp_strict.cpp +@@ -239,7 +239,7 @@ float CV_ImageWarpBaseTest::get_success_error_level(int _interpolation, int) con + else if (_interpolation == INTER_AREA) + return 2.0f; + else +- return 1.0f; ++ return 4.0f; // Reference algorithm uses integer interpolation with 5 bits fractional part, and this greater tolerance allows better precision algorithms to pass the test + } + + void CV_ImageWarpBaseTest::validate_results() const -- GitLab