From c4763279eb1e4a7918566643ebf24bcc73e4450c Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 1 Oct 2025 10:18:11 +0300 Subject: [PATCH] Added inRange HAL entry point. --- modules/core/src/arithm.cpp | 12 +++++++++ modules/core/src/hal_replacement.hpp | 38 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 01a1a02900..5c1033be81 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -2113,6 +2113,18 @@ void cv::inRange(InputArray _src, InputArray _lowerb, convertAndUnrollScalar( lb, src.type(), lbuf, blocksize ); convertAndUnrollScalar( ub, src.type(), ubuf, blocksize ); + + if (depth == CV_8U && src.dims <= 2) { + uint8_t lb_scalar = lbuf[0]; + uint8_t ub_scalar = ubuf[0]; + CALL_HAL(inRange_u8, cv_hal_inRange8u, src.data, src.step, dst.data, dst.step, dst.depth(), src.cols, src.rows, src.channels(), + lb_scalar, ub_scalar); + } else if (depth == CV_32F && src.dims <= 2) { + double lb_scalar = lb.ptr(0)[0]; + double ub_scalar = ub.ptr(0)[0]; + CALL_HAL(inRange_f32, cv_hal_inRange32f, src.data, src.step, dst.data, dst.step, dst.depth(), src.cols, src.rows, src.channels(), + lb_scalar, ub_scalar); + } } for( size_t i = 0; i < it.nplanes; i++, ++it ) diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index c48f1163bb..f809351550 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -1138,6 +1138,44 @@ inline int hal_ni_sum(const uchar *src_data, size_t src_step, int src_type, int #define cv_hal_sum hal_ni_sum //! @endcond +/** + @brief inRange (lower_bound <= src_value) && (src_value <= upper_bound) ? 255 : 0 + @param src_data Source image data + @param src_step Source image step + @param dst_data Destination image data + @param dst_step Destination image step + @param dst_depth Destination image depth + @param width Image width + @param height Image height + @param cn number of channels + @param lower_bound Range lower bound + @param upper_bound Range upper bound +*/ +inline int hal_ni_inRange8u(const uchar *src_data, size_t src_step, + uchar *dst_data, size_t dst_step, int dst_depth, int width, + int height, int cn, uchar lower_bound, uchar upper_bound) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +/** + @brief inRange (lower_bound <= src_value) && (src_value <= upper_bound) ? 255 : 0 + @param src_data Source image data + @param src_step Source image step + @param dst_data Destination image data + @param dst_step Destination image step + @param dst_depth Destination image depth + @param width Image width + @param height Image height + @param cn number of channels + @param lower_bound Range lower bound + @param upper_bound Range upper bound +*/ +inline int hal_ni_inRange32f(const uchar *src_data, size_t src_step, + uchar *dst_data, size_t dst_step, int dst_depth, int width, + int height, int cn, double lower_bound, double upper_bound) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } + +//! @cond IGNORED +#define cv_hal_inRange8u hal_ni_inRange8u +#define cv_hal_inRange32f hal_ni_inRange32f +//! @endcond + //! @} #if defined(__clang__)