diff --git a/adapters/opencv/intrinsiccv_hal.cpp b/adapters/opencv/intrinsiccv_hal.cpp index e5aa27d7a7408a0c5b331a027b0bb6eef2e41f81..401b20a7dfea04189addf59d63945929decc08a0 100644 --- a/adapters/opencv/intrinsiccv_hal.cpp +++ b/adapters/opencv/intrinsiccv_hal.cpp @@ -175,13 +175,12 @@ int yuv_to_bgr_ex(const uchar *y_data, size_t y_step, const uchar *uv_data, int threshold(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int width, int height, int depth, int cn, double thresh, double maxValue, int thresholdType) { - (void)cn; - if ((depth == CV_8U) && (thresholdType == 0 /* THRESH_BINARY */)) { + size_t width_in_elements = width * cn; return convert_error(intrinsiccv_threshold_binary_u8( reinterpret_cast(src_data), src_step, - reinterpret_cast(dst_data), dst_step, width, height, - static_cast(thresh), static_cast(maxValue))); + reinterpret_cast(dst_data), dst_step, width_in_elements, + height, static_cast(thresh), static_cast(maxValue))); } return CV_HAL_ERROR_NOT_IMPLEMENTED; diff --git a/adapters/opencv/opencv-4.9.patch b/adapters/opencv/opencv-4.9.patch index 4f5fe860dada9640a3d8c322186d6d072c24bc1b..0fd607db02ebf91a961cedce730f69f2c022f2f0 100644 --- a/adapters/opencv/opencv-4.9.patch +++ b/adapters/opencv/opencv-4.9.patch @@ -75,19 +75,26 @@ index 6f0a83d359..4c294962ca 100644 #define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) #define CV_MAKE_TYPE CV_MAKETYPE diff --git a/modules/core/src/convert.dispatch.cpp b/modules/core/src/convert.dispatch.cpp -index 345b4624cb..1ace8f1d5c 100644 +index 345b4624cb..8698cc64bf 100644 --- a/modules/core/src/convert.dispatch.cpp +++ b/modules/core/src/convert.dispatch.cpp -@@ -202,6 +202,9 @@ void Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) cons +@@ -201,10 +201,15 @@ void Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) cons + else _dst.create( dims, size, _type ); Mat dst = _dst.getMat(); - -+ if( dims <= 2 ) -+ CALL_HAL(convertTo, cv_hal_convertTo, src.data, src.step, src.depth(), dst.data, dst.step, dst.depth(), src.cols, src.rows, alpha, beta); ++ int cn = channels(); + ++ if( dims <= 2 ) { ++ int width_in_elements = src.cols * cn; ++ CALL_HAL(convertTo, cv_hal_convertTo, src.data, src.step, src.depth(), dst.data, dst.step, dst.depth(), width_in_elements, src.rows, alpha, beta); ++ } + BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth); double scale[] = {alpha, beta}; - int cn = channels(); +- int cn = channels(); + CV_Assert( func != 0 ); + + if( dims <= 2 ) diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index 1f2b259920..b0e5db024d 100644 --- a/modules/core/src/hal_replacement.hpp diff --git a/adapters/opencv/opencv-5.x.patch b/adapters/opencv/opencv-5.x.patch index 32cf69b9d2373e7a679b47de1d936027a7c7c29f..8558e94b22473847ddf40544f7e1fc2849cf13b3 100644 --- a/adapters/opencv/opencv-5.x.patch +++ b/adapters/opencv/opencv-5.x.patch @@ -1,10 +1,10 @@ -// SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates // // SPDX-License-Identifier: Apache-2.0 diff --git a/3rdparty/intrinsiccv/CMakeLists.txt b/3rdparty/intrinsiccv/CMakeLists.txt new file mode 100644 -index 0000000000..8764ee5e99 +index 0000000000..c0ffb73ad7 --- /dev/null +++ b/3rdparty/intrinsiccv/CMakeLists.txt @@ -0,0 +1,3 @@ @@ -12,19 +12,19 @@ index 0000000000..8764ee5e99 + +include("${INTRINSICCV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt") diff --git a/CMakeLists.txt b/CMakeLists.txt -index 25e808bec3..51519ebfa3 100644 +index d462ccf1a5..76a48e2886 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -246,6 +246,8 @@ OCV_OPTION(WITH_CAP_IOS "Enable iOS video capture" ON +@@ -259,6 +259,8 @@ OCV_OPTION(WITH_CAP_IOS "Enable iOS video capture" ON VERIFY HAVE_CAP_IOS) OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" (NOT CV_DISABLE_OPTIMIZATION) - VISIBLE_IF (ARM OR AARCH64) AND NOT IOS) + VISIBLE_IF (ARM OR AARCH64) AND NOT IOS AND NOT XROS) +OCV_OPTION(WITH_INTRINSICCV "Use IntrinsicCV library for ARM platforms" OFF + VISIBLE_IF (AARCH64)) OCV_OPTION(WITH_CPUFEATURES "Use cpufeatures Android library" ON VISIBLE_IF ANDROID VERIFY HAVE_CPUFEATURES) -@@ -889,6 +891,13 @@ if(HAVE_OPENVX) +@@ -958,6 +960,13 @@ if(HAVE_OPENVX) endif() endif() @@ -38,7 +38,7 @@ index 25e808bec3..51519ebfa3 100644 if(WITH_CAROTENE) ocv_debug_message(STATUS "Enable carotene acceleration") if(NOT ";${OpenCV_HAL};" MATCHES ";carotene;") -@@ -905,6 +914,10 @@ foreach(hal ${OpenCV_HAL}) +@@ -982,6 +991,10 @@ foreach(hal ${OpenCV_HAL}) else() message(STATUS "Carotene: NEON is not available, disabling carotene...") endif() @@ -50,10 +50,10 @@ index 25e808bec3..51519ebfa3 100644 add_subdirectory(3rdparty/openvx) ocv_hal_register(OPENVX_HAL_LIBRARIES OPENVX_HAL_HEADERS OPENVX_HAL_INCLUDE_DIRS) diff --git a/doc/tutorials/introduction/config_reference/config_reference.markdown b/doc/tutorials/introduction/config_reference/config_reference.markdown -index 6b8d71341a..7958051561 100644 +index 09742ca9ba..209d6aa34a 100644 --- a/doc/tutorials/introduction/config_reference/config_reference.markdown +++ b/doc/tutorials/introduction/config_reference/config_reference.markdown -@@ -612,6 +612,7 @@ Following build options are utilized in `opencv_contrib` modules, as stated [pre +@@ -621,6 +621,7 @@ Following build options are utilized in `opencv_contrib` modules, as stated [pre `CMAKE_TOOLCHAIN_FILE` `WITH_CAROTENE` @@ -62,38 +62,40 @@ index 6b8d71341a..7958051561 100644 `WITH_EIGEN` `WITH_OPENVX` diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h -index 6f0a83d359..4c294962ca 100644 +index c7445a4de4..49a459597b 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h -@@ -81,6 +81,8 @@ typedef signed char schar; +@@ -90,6 +90,8 @@ typedef short cv_hal_bf16; #define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) #define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) + #define CV_IS_INT_TYPE(flags) (((1 << CV_MAT_DEPTH(flags)) & 0x1e1f) != 0) + #define CV_IS_FLOAT_TYPE(flags) (((1 << CV_MAT_DEPTH(flags)) & 0x1e0) != 0) - #define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) - #define CV_MAKE_TYPE CV_MAKETYPE diff --git a/modules/core/src/convert.dispatch.cpp b/modules/core/src/convert.dispatch.cpp -index 345b4624cb..1ace8f1d5c 100644 +index 7418b696bc..4bf4d863ab 100644 --- a/modules/core/src/convert.dispatch.cpp +++ b/modules/core/src/convert.dispatch.cpp -@@ -202,6 +202,9 @@ void Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) cons - _dst.create( dims, size, _type ); - Mat dst = _dst.getMat(); +@@ -195,6 +195,11 @@ void Mat::convertTo(OutputArray dst, int type_, double alpha, double beta) const + dst.create( dims, size, dtype, -1, allowTransposed ); + Mat dstMat = dst.getMat(); -+ if( dims <= 2 ) -+ CALL_HAL(convertTo, cv_hal_convertTo, src.data, src.step, src.depth(), dst.data, dst.step, dst.depth(), src.cols, src.rows, alpha, beta); ++ 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); ++ } + BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth); double scale[] = {alpha, beta}; - int cn = channels(); + CV_Assert( func != 0 ); diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp -index 6ed795b5e1..32baf11ece 100644 +index 19ac6de746..9c1a821bed 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp -@@ -731,6 +731,35 @@ inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, i - #define cv_hal_minMaxIdx hal_ni_minMaxIdx +@@ -919,6 +919,35 @@ inline int hal_ni_rotate90(int src_type, const uchar* src_data, size_t src_step, + #define cv_hal_rotate90 hal_ni_rotate90 //! @endcond +/** @@ -129,18 +131,18 @@ index 6ed795b5e1..32baf11ece 100644 diff --git a/modules/core/src/matrix_transform.cpp b/modules/core/src/matrix_transform.cpp -index 57fd0c6509..658c1f1ca9 100644 +index 5a80ac8ca7..00c19589b8 100644 --- a/modules/core/src/matrix_transform.cpp +++ b/modules/core/src/matrix_transform.cpp -@@ -5,6 +5,7 @@ - #include "precomp.hpp" +@@ -6,6 +6,7 @@ #include "opencl_kernels_core.hpp" + #include "hal_replacement.hpp" #include "opencv2/core/detail/dispatch_helper.impl.hpp" +#include "hal_replacement.hpp" #include // std::swap_ranges - -@@ -267,6 +268,8 @@ void transpose( InputArray _src, OutputArray _dst ) + #include // std::accumulate +@@ -269,6 +270,8 @@ void transpose( InputArray _src, OutputArray _dst ) return; } diff --git a/scripts/ci-opencv.sh b/scripts/ci-opencv.sh index c3b679671152db6b18432cb0c458e672721b920a..3e6e9923b464afdfbc7460471a0d7df63f08a3ba 100755 --- a/scripts/ci-opencv.sh +++ b/scripts/ci-opencv.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# + # SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates # # SPDX-License-Identifier: Apache-2.0 @@ -28,5 +28,48 @@ cmake \ -G Ninja \ -DWITH_INTRINSICCV=ON \ -DINTRINSICCV_SOURCE_PATH="$(pwd)" \ - -DBUILD_LIST=core,imgproc + -DBUILD_TESTS=ON \ + -DBUILD_LIST=core,imgproc,ts ninja -C build/build-opencv + +# Run a subset of the OpenCV test suite, requres opencv_extra for the test images +wget --no-verbose \ + https://github.com/opencv/opencv_extra/archive/refs/tags/${OPENCV_VER}.tar.gz \ + -O build/opencv_extra.tar.gz +tar xf build/opencv_extra.tar.gz -C build +rm build/opencv_extra.tar.gz +mv build/opencv_extra-${OPENCV_VER} build/opencv_extra + +pushd build/opencv_extra/testdata/cv + +join_strings_with_colon() { + local array="${1}" + # shellcheck disable=SC2068 + # Here array should be re-splitted. + array="$(printf ":%s" ${array[@]})" + echo "${array:1}" +} + +IMGPROC_TEST_PATTERNS=( + '*Imgproc_ColorGray*' + '*Imgproc_ColorRGB*' + '*Imgproc_ColorYUV*' + '*Imgproc_cvtColor_BE.COLOR_YUV*' + '*Imgproc_Threshold*' + '*Imgproc_Morphology*' + '*Imgproc_GaussianBlur*' + '*Imgproc_Sobel*' + '*Imgproc_Canny*' +) +IMGPROC_TEST_PATTERNS_STR="$(join_strings_with_colon "${IMGPROC_TEST_PATTERNS[*]}")" +../../../build-opencv/bin/opencv_test_imgproc --gtest_filter="${IMGPROC_TEST_PATTERNS_STR}" + +CORE_TEST_PATTERNS=( + '*Core_Transpose*' + '*Core_MinMaxLoc*' + '*Core_ConvertScale*' +) +CORE_TEST_PATTERNS_STR="$(join_strings_with_colon "${CORE_TEST_PATTERNS[*]}")" +../../../build-opencv/bin/opencv_test_core --gtest_filter="${CORE_TEST_PATTERNS_STR}" + +popd