From 5fefc8c52e13ea167aadb1265f8d10a0dfb91fb7 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Thu, 22 Feb 2024 22:12:13 +0100 Subject: [PATCH 1/5] Rename the INTRINSICCV_SVE2_128 macro Renamed to INTRINSICCV_ASSUME_128BIT_SVE2 to match the corresponding CMake variable name. --- intrinsiccv/CMakeLists.txt | 4 ++-- intrinsiccv/include/intrinsiccv/config.h | 10 +++++----- intrinsiccv/src/conversions/rgb_to_rgb_sc.h | 15 ++++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/intrinsiccv/CMakeLists.txt b/intrinsiccv/CMakeLists.txt index de7a5473d..190f77c35 100644 --- a/intrinsiccv/CMakeLists.txt +++ b/intrinsiccv/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023-2024 Arm Limited and/or its affiliates +# SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates # # SPDX-License-Identifier: Apache-2.0 @@ -104,7 +104,7 @@ if(INTRINSICCV_ENABLE_SVE2) endif() if (INTRINSICCV_ASSUME_128BIT_SVE2) - list(APPEND INTRINSICCV_CXX_FLAGS "-DINTRINSICCV_SVE2_128=1") + list(APPEND INTRINSICCV_CXX_FLAGS "-DINTRINSICCV_ASSUME_128BIT_SVE2=1") endif() if (CMAKE_BUILD_TYPE EQUAL "DEBUG") diff --git a/intrinsiccv/include/intrinsiccv/config.h b/intrinsiccv/include/intrinsiccv/config.h index d4f9a8a27..2e037600b 100644 --- a/intrinsiccv/include/intrinsiccv/config.h +++ b/intrinsiccv/include/intrinsiccv/config.h @@ -1,4 +1,4 @@ -// 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 @@ -14,8 +14,8 @@ #endif // Set to '1' if 128-bit SVE2 VL is assumed, otherwise it is set to '0'. -#ifndef INTRINSICCV_SVE2_128 -#define INTRINSICCV_SVE2_128 0 +#ifndef INTRINSICCV_ASSUME_128BIT_SVE2 +#define INTRINSICCV_ASSUME_128BIT_SVE2 0 #endif // Set to '1' if compiling NEON code paths, otherwise it is set to '0'. @@ -57,8 +57,8 @@ #endif #if INTRINSICCV_TARGET_SME2 -#undef INTRINSICCV_SVE2_128 -#define INTRINSICCV_SVE2_128 0 +#undef INTRINSICCV_ASSUME_128BIT_SVE2 +#define INTRINSICCV_ASSUME_128BIT_SVE2 0 #define INTRINSICCV_TARGET_FN_ATTRS INTRINSICCV_ATTR_SECTION(".text.sme2") #define INTRINSICCV_LOCALLY_STREAMING __arm_locally_streaming #define INTRINSICCV_STREAMING_COMPATIBLE __arm_streaming_compatible diff --git a/intrinsiccv/src/conversions/rgb_to_rgb_sc.h b/intrinsiccv/src/conversions/rgb_to_rgb_sc.h index 864cbe578..145d6fb77 100644 --- a/intrinsiccv/src/conversions/rgb_to_rgb_sc.h +++ b/intrinsiccv/src/conversions/rgb_to_rgb_sc.h @@ -13,7 +13,8 @@ namespace intrinsiccv::sve2 { template class RGBToBGR final : -#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE && INTRINSICCV_SVE2_128 +#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE && \ + INTRINSICCV_ASSUME_128BIT_SVE2 public UsesTailPath, #endif public UnrollTwice { @@ -22,7 +23,8 @@ class RGBToBGR final : using VecTraits = sve2::VecTraits; using VectorType = typename VecTraits::VectorType; -#if INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || !INTRINSICCV_SVE2_128 +#if INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || \ + !INTRINSICCV_ASSUME_128BIT_SVE2 void vector_path(ContextType ctx, const ScalarType *src, ScalarType *dst) INTRINSICCV_STREAMING_COMPATIBLE { auto pg = ctx.predicate(); @@ -32,7 +34,8 @@ class RGBToBGR final : svst3(pg, dst, dst_vect); } -#else // INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || !INTRINSICCV_SVE2_128 +#else // INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || + // !INTRINSICCV_ASSUME_128BIT_SVE2 explicit RGBToBGR(svuint8x4_t &indices) INTRINSICCV_STREAMING_COMPATIBLE : indices_{indices} { initialize_indices(); @@ -93,7 +96,8 @@ class RGBToBGR final : // Hold a reference because a sizeless types cannot be members. svuint8x4_t &indices_; -#endif // !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || !INTRINSICCV_SVE2_128 +#endif // !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || + // !INTRINSICCV_ASSUME_128BIT_SVE2 }; // end of class RGBToBGR template @@ -191,7 +195,8 @@ INTRINSICCV_TARGET_FN_ATTRS static intrinsiccv_error_t rgb_to_bgr_u8_sc( Rectangle rect{width, height}; Rows src_rows{src, src_stride, 3 /* RGB */}; Rows dst_rows{dst, dst_stride, 3 /* BGR */}; -#if INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || !INTRINSICCV_SVE2_128 +#if INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE || \ + !INTRINSICCV_ASSUME_128BIT_SVE2 RGBToBGR operation; #else svuint8x4_t table_indices; -- GitLab From db1c72ad85b53112265e8376effd617e970c91c8 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Fri, 23 Feb 2024 13:47:01 +0100 Subject: [PATCH 2/5] Rename Canny algorithm related macro INTRINSICCV_DIRECTIONAL_MASKING_CONFORM_OPENCV renamed to INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV, to be more self describing. The detailed description of the macro is moved to the Canny source file. --- intrinsiccv/include/intrinsiccv/config.h | 7 +------ intrinsiccv/src/analysis/canny_neon.cpp | 17 +++++++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/intrinsiccv/include/intrinsiccv/config.h b/intrinsiccv/include/intrinsiccv/config.h index 2e037600b..d86fc807f 100644 --- a/intrinsiccv/include/intrinsiccv/config.h +++ b/intrinsiccv/include/intrinsiccv/config.h @@ -39,12 +39,7 @@ #define INTRINSICCV_ALWAYS_ENABLE_SVE2 0 #endif -// OpenCV requires that diagonal non-maxima-suppressions are calculated as -// curr > prev && curr > next -// This is different from other directions where -// curr > prev && curr >= next -// is used. Furthermore, the elements in the diagonal directions are reversed. -#define INTRINSICCV_DIRECTIONAL_MASKING_CONFORM_OPENCV 1 +#define INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV 1 // Derived configuration switches and macros below. diff --git a/intrinsiccv/src/analysis/canny_neon.cpp b/intrinsiccv/src/analysis/canny_neon.cpp index 94b99d696..21d5bc0fc 100644 --- a/intrinsiccv/src/analysis/canny_neon.cpp +++ b/intrinsiccv/src/analysis/canny_neon.cpp @@ -236,9 +236,14 @@ T *remove_constant_pool_usage(T *ptr) { // bottom-left} and {left, right} neighbouring values as governed by the // associated directions. // -// If INTRINSICCV_DIRECTIONAL_MASKING_CONFORM_OPENCV is set to 1, the diagonal -// directions are swapped, and lanes in 'next_row_by_directions', where the -// direction is diagonal, are incremented by 1 saturating. +// If INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV is set to 1: +// - diagonal directions are swapped +// - diagonal non-maxima-suppressions are calculated as: +// curr > prev && curr > next +// This is different from other directions where it is calculated as: +// curr > prev && curr >= next +// (To achieve this lanes in 'next_row_by_directions', where the direction is +// diagonal, are incremented by 1 saturating.) static void directional_masking(const int16_t *prev_rows, const int16_t *curr_rows, const int16_t *next_rows, int16x8_t directions, @@ -252,7 +257,7 @@ static void directional_masking(const int16_t *prev_rows, static constexpr int8_t kIndices[4 * kNumLanesS8] = { /* Lane offsets holding 'lane number + VL' */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -#if INTRINSICCV_DIRECTIONAL_MASKING_CONFORM_OPENCV +#if INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV /* Table lookup indices for previous row */ 32, 32, -2, 2, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* Table lookup indices for next row */ @@ -312,7 +317,7 @@ static void directional_masking(const int16_t *prev_rows, // 2.1 tmp_indices_0 = vqtbl1q_s8(next_row_table, dir); -#if INTRINSICCV_DIRECTIONAL_MASKING_CONFORM_OPENCV +#if INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV int8x16_t opencv_tmp_indices_0 = tmp_indices_0; #endif // 2.2 @@ -348,7 +353,7 @@ static void directional_masking(const int16_t *prev_rows, curr_row_by_directions = vreinterpretq_s16_s8(curr_row.val[1]); next_row_by_directions = vreinterpretq_s16_s8(next_row_by_dir); -#if INTRINSICCV_DIRECTIONAL_MASKING_CONFORM_OPENCV +#if INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV // Reuse temporary indexing values from step 2.1 to saturating add one to // diagonal values in the next row. This works only because of the domain of // input values is restricted. -- GitLab From 2233f0741c3653a0c8ce64172b700e0def9c62ad Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Thu, 22 Feb 2024 22:50:09 +0100 Subject: [PATCH 3/5] Use CMake's configure_file to create config.h --- intrinsiccv/CMakeLists.txt | 17 +++++++------- .../intrinsiccv/{config.h => config.h.in} | 23 +++++-------------- test/CMakeLists.txt | 7 ++++-- 3 files changed, 20 insertions(+), 27 deletions(-) rename intrinsiccv/include/intrinsiccv/{config.h => config.h.in} (78%) diff --git a/intrinsiccv/CMakeLists.txt b/intrinsiccv/CMakeLists.txt index 190f77c35..eb5417318 100644 --- a/intrinsiccv/CMakeLists.txt +++ b/intrinsiccv/CMakeLists.txt @@ -12,6 +12,8 @@ option(INTRINSICCV_ENABLE_SVE2 "Explicitly enables or disables SVE2 code paths f option(INTRINSICCV_ENABLE_SVE2_SELECTIVELY "Explicitly enables or disables SVE2 code paths for selected algorithms" ON) option(INTRINSICCV_ENABLE_SME2 "Explicitly enables or disables SME2 code paths for all supported algorithms" ON) option(INTRINSICCV_ASSUME_128BIT_SVE2 "If turned ON 128-bit SVE2 vector length is assumed" OFF) +option(INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE "If turned ON interleaving loads and stores are preferred instead of continuous loads and stores" OFF) +option(INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV "If turned ON Canny algorithm creates bit exact result compared to OpenCV's original implementation" ON) if (INTRINSICCV_ENABLE_SVE2 AND INTRINSICCV_ENABLE_SVE2_SELECTIVELY) message(FATAL_ERROR "[IntrinsicCV] INTRINSICCV_ENABLE_SVE2 and INTRINSICCV_ENABLE_SVE2_SELECTIVELY cannot be set at the same time") @@ -45,6 +47,12 @@ if (INTRINSICCV_ENABLE_SME2) endif() endif() +if(INTRINSICCV_BUILD_SVE2 AND INTRINSICCV_ENABLE_SVE2) + set(INTRINSICCV_ALWAYS_ENABLE_SVE2 ON) +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/include/intrinsiccv/config.h.in" "include/intrinsiccv/config.h") + file(GLOB INTRINSICCV_API_SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*_api.cpp" "${CMAKE_CURRENT_LIST_DIR}/src/**/*_api.cpp" @@ -67,6 +75,7 @@ file(GLOB INTRINSICCV_SME2_SOURCES set(INTRINSICCV_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_CURRENT_BINARY_DIR}/include" ) set(INTRINSICCV_WARNING_FLAGS @@ -99,14 +108,6 @@ set(INTRINSICCV_CXX_FLAGS ${INTRINSICCV_SDL_FLAGS} ) -if(INTRINSICCV_ENABLE_SVE2) - list(APPEND INTRINSICCV_CXX_FLAGS "-DINTRINSICCV_ALWAYS_ENABLE_SVE2=1") -endif() - -if (INTRINSICCV_ASSUME_128BIT_SVE2) - list(APPEND INTRINSICCV_CXX_FLAGS "-DINTRINSICCV_ASSUME_128BIT_SVE2=1") -endif() - if (CMAKE_BUILD_TYPE EQUAL "DEBUG") list(APPEND INTRINSICCV_CXX_FLAGS "-O0" "-g") else() diff --git a/intrinsiccv/include/intrinsiccv/config.h b/intrinsiccv/include/intrinsiccv/config.h.in similarity index 78% rename from intrinsiccv/include/intrinsiccv/config.h rename to intrinsiccv/include/intrinsiccv/config.h.in index d86fc807f..c6235aa23 100644 --- a/intrinsiccv/include/intrinsiccv/config.h +++ b/intrinsiccv/include/intrinsiccv/config.h.in @@ -7,16 +7,13 @@ // Main configuration switches. -// Set to '1' if interleaving loads and stores are preferred, otherwise it is -// set to '0'. -#ifndef INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE -#define INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE 0 -#endif +#cmakedefine01 INTRINSICCV_ALWAYS_ENABLE_SVE2 -// Set to '1' if 128-bit SVE2 VL is assumed, otherwise it is set to '0'. -#ifndef INTRINSICCV_ASSUME_128BIT_SVE2 -#define INTRINSICCV_ASSUME_128BIT_SVE2 0 -#endif +#cmakedefine01 INTRINSICCV_ASSUME_128BIT_SVE2 + +#cmakedefine01 INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE + +#cmakedefine01 INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV // Set to '1' if compiling NEON code paths, otherwise it is set to '0'. #ifndef INTRINSICCV_TARGET_NEON @@ -33,14 +30,6 @@ #define INTRINSICCV_TARGET_SME2 0 #endif -// Set to '1' to always enable SVE2 code paths, otherwise enable them -// selectively. -#ifndef INTRINSICCV_ALWAYS_ENABLE_SVE2 -#define INTRINSICCV_ALWAYS_ENABLE_SVE2 0 -#endif - -#define INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV 1 - // Derived configuration switches and macros below. #if INTRINSICCV_TARGET_NEON diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 91e782999..b22697f90 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,13 @@ -# 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 cmake_minimum_required(VERSION 3.16) -set(INTRINSICCV_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../intrinsiccv/include) +set(INTRINSICCV_INCLUDE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/../intrinsiccv/include + ${CMAKE_CURRENT_BINARY_DIR}/../intrinsiccv/include +) set(INTRINSICCV_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(INTRINSICCV_WARNING_FLAGS -- GitLab From ccbdeb2ba3ca42fc3f7a83db2986972faea5cac9 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Thu, 22 Feb 2024 22:55:00 +0100 Subject: [PATCH 4/5] Document experimental CMake configs as internal --- intrinsiccv/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intrinsiccv/CMakeLists.txt b/intrinsiccv/CMakeLists.txt index eb5417318..9c0eae83d 100644 --- a/intrinsiccv/CMakeLists.txt +++ b/intrinsiccv/CMakeLists.txt @@ -11,9 +11,9 @@ include(CheckCXXCompilerFlag) option(INTRINSICCV_ENABLE_SVE2 "Explicitly enables or disables SVE2 code paths for all supported algorithms" OFF) option(INTRINSICCV_ENABLE_SVE2_SELECTIVELY "Explicitly enables or disables SVE2 code paths for selected algorithms" ON) option(INTRINSICCV_ENABLE_SME2 "Explicitly enables or disables SME2 code paths for all supported algorithms" ON) -option(INTRINSICCV_ASSUME_128BIT_SVE2 "If turned ON 128-bit SVE2 vector length is assumed" OFF) -option(INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE "If turned ON interleaving loads and stores are preferred instead of continuous loads and stores" OFF) -option(INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV "If turned ON Canny algorithm creates bit exact result compared to OpenCV's original implementation" ON) +option(INTRINSICCV_ASSUME_128BIT_SVE2 "Internal - If turned ON 128-bit SVE2 vector length is assumed" OFF) +option(INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE "Internal - If turned ON interleaving loads and stores are preferred instead of continuous loads and stores" OFF) +option(INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV "Internal - If turned ON Canny algorithm creates bit exact result compared to OpenCV's original implementation" ON) if (INTRINSICCV_ENABLE_SVE2 AND INTRINSICCV_ENABLE_SVE2_SELECTIVELY) message(FATAL_ERROR "[IntrinsicCV] INTRINSICCV_ENABLE_SVE2 and INTRINSICCV_ENABLE_SVE2_SELECTIVELY cannot be set at the same time") -- GitLab From fbdba8478825812c1289cd67fe6c1982bf1bd614 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Thu, 22 Feb 2024 23:00:05 +0100 Subject: [PATCH 5/5] Make Canny algorithm experimental --- adapters/opencv/doc-opencv.md | 4 ++-- adapters/opencv/intrinsiccv_hal.cpp | 2 ++ adapters/opencv/intrinsiccv_hal.h | 6 +++++- intrinsiccv/CMakeLists.txt | 1 + intrinsiccv/include/intrinsiccv/config.h.in | 2 ++ intrinsiccv/include/intrinsiccv/intrinsiccv.h | 2 ++ intrinsiccv/src/analysis/canny_neon.cpp | 4 ++++ test/api/test_canny.cpp | 4 ++++ 8 files changed, 22 insertions(+), 3 deletions(-) diff --git a/adapters/opencv/doc-opencv.md b/adapters/opencv/doc-opencv.md index b8deda1b7..a197c78f0 100644 --- a/adapters/opencv/doc-opencv.md +++ b/adapters/opencv/doc-opencv.md @@ -1,5 +1,5 @@ @@ -107,7 +107,7 @@ Notes on parameters: * margins are not supported. * `dx`,`dy` - either vertical `{dx,dy} == {0,1}` or horizontal `{dx,dy == 1,0` operation is supported. -### `canny` +### `canny` (Experimental) Apply Canny edge detection filter to a given image. Notes on parameters: diff --git a/adapters/opencv/intrinsiccv_hal.cpp b/adapters/opencv/intrinsiccv_hal.cpp index 401b20a7d..4e2f2af04 100644 --- a/adapters/opencv/intrinsiccv_hal.cpp +++ b/adapters/opencv/intrinsiccv_hal.cpp @@ -495,6 +495,7 @@ int sobel(const uchar *src_data, size_t src_step, uchar *dst_data, return CV_HAL_ERROR_NOT_IMPLEMENTED; } +#if INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY int canny(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int width, int height, int cn, double lowThreshold, double highThreshold, int ksize, bool L2gradient) { @@ -520,6 +521,7 @@ int canny(const uchar *src_data, size_t src_step, uchar *dst_data, static_cast(width), static_cast(height), lowThreshold, highThreshold)); } +#endif // INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY int transpose(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int src_width, int src_height, diff --git a/adapters/opencv/intrinsiccv_hal.h b/adapters/opencv/intrinsiccv_hal.h index c6cba2ff2..1eab08d6e 100644 --- a/adapters/opencv/intrinsiccv_hal.h +++ b/adapters/opencv/intrinsiccv_hal.h @@ -1,4 +1,4 @@ -// 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 @@ -70,9 +70,11 @@ int sobel(const uchar *src_data, size_t src_step, uchar *dst_data, int margin_bottom, int dx, int dy, int ksize, double scale, double delta, int border_type); +#if INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY int canny(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int width, int height, int cn, double lowThreshold, double highThreshold, int ksize, bool L2gradient); +#endif // INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY int transpose(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int src_width, int src_height, int element_size); @@ -224,6 +226,7 @@ static inline int intrinsiccv_sobel_with_fallback( #undef cv_hal_sobel #define cv_hal_sobel intrinsiccv_sobel_with_fallback +#if INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY // canny static inline int intrinsiccv_canny_with_fallback( const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, @@ -235,6 +238,7 @@ static inline int intrinsiccv_canny_with_fallback( } #undef cv_hal_canny #define cv_hal_canny intrinsiccv_canny_with_fallback +#endif // INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY #endif // OPENCV_IMGPROC_HAL_REPLACEMENT_HPP diff --git a/intrinsiccv/CMakeLists.txt b/intrinsiccv/CMakeLists.txt index 9c0eae83d..3c5b6040f 100644 --- a/intrinsiccv/CMakeLists.txt +++ b/intrinsiccv/CMakeLists.txt @@ -13,6 +13,7 @@ option(INTRINSICCV_ENABLE_SVE2_SELECTIVELY "Explicitly enables or disables SVE2 option(INTRINSICCV_ENABLE_SME2 "Explicitly enables or disables SME2 code paths for all supported algorithms" ON) option(INTRINSICCV_ASSUME_128BIT_SVE2 "Internal - If turned ON 128-bit SVE2 vector length is assumed" OFF) option(INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE "Internal - If turned ON interleaving loads and stores are preferred instead of continuous loads and stores" OFF) +option(INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY "Internal - Enable experimental Canny algorithm" OFF) option(INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV "Internal - If turned ON Canny algorithm creates bit exact result compared to OpenCV's original implementation" ON) if (INTRINSICCV_ENABLE_SVE2 AND INTRINSICCV_ENABLE_SVE2_SELECTIVELY) diff --git a/intrinsiccv/include/intrinsiccv/config.h.in b/intrinsiccv/include/intrinsiccv/config.h.in index c6235aa23..a842fdfff 100644 --- a/intrinsiccv/include/intrinsiccv/config.h.in +++ b/intrinsiccv/include/intrinsiccv/config.h.in @@ -13,6 +13,8 @@ #cmakedefine01 INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE +#cmakedefine01 INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY + #cmakedefine01 INTRINSICCV_CANNY_ALGORITHM_CONFORM_OPENCV // Set to '1' if compiling NEON code paths, otherwise it is set to '0'. diff --git a/intrinsiccv/include/intrinsiccv/intrinsiccv.h b/intrinsiccv/include/intrinsiccv/intrinsiccv.h index 19dc8573b..e352f29ef 100644 --- a/intrinsiccv/include/intrinsiccv/intrinsiccv.h +++ b/intrinsiccv/include/intrinsiccv/intrinsiccv.h @@ -915,6 +915,7 @@ intrinsiccv_error_t intrinsiccv_sobel_3x3_horizontal_s16_u8( const uint8_t *src, size_t src_stride, int16_t *dst, size_t dst_stride, size_t width, size_t height, size_t channels); +#if INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY /// Canny edge detector for uint8_t grayscale input. Output is also a uint8_t /// grayscale image. Width and height are the same for input and output. Number /// of pixels is limited to @ref INTRINSICCV_MAX_IMAGE_PIXELS. @@ -947,6 +948,7 @@ intrinsiccv_error_t intrinsiccv_canny_u8(const uint8_t *src, size_t src_stride, size_t width, size_t height, double low_threshold, double high_threshold); +#endif // INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY /// Creates a filter context according to the parameters. /// diff --git a/intrinsiccv/src/analysis/canny_neon.cpp b/intrinsiccv/src/analysis/canny_neon.cpp index 21d5bc0fc..a76bddecf 100644 --- a/intrinsiccv/src/analysis/canny_neon.cpp +++ b/intrinsiccv/src/analysis/canny_neon.cpp @@ -6,6 +6,8 @@ #include "intrinsiccv/intrinsiccv.h" #include "intrinsiccv/neon.h" +#if INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY + namespace intrinsiccv::neon { // Container to hold strong edges. @@ -544,3 +546,5 @@ extern "C" INTRINSICCV_TARGET_FN_ATTRS intrinsiccv_error_t intrinsiccv_canny_u8( } } // namespace intrinsiccv::neon + +#endif // INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY diff --git a/test/api/test_canny.cpp b/test/api/test_canny.cpp index 71b23c81d..36f45577e 100644 --- a/test/api/test_canny.cpp +++ b/test/api/test_canny.cpp @@ -7,6 +7,8 @@ #include "framework/utils.h" #include "intrinsiccv/intrinsiccv.h" +#if INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY + #define INTRINSICCV_CANNY(type, suffix) \ INTRINSICCV_API(canny, intrinsiccv_canny_##suffix, type) @@ -49,3 +51,5 @@ TYPED_TEST(CannyTest, ImageSize) { INTRINSICCV_MAX_IMAGE_PIXELS, INTRINSICCV_MAX_IMAGE_PIXELS, 0.0, 1.0)); } + +#endif // INTRINSICCV_EXPERIMENTAL_FEATURE_CANNY -- GitLab