From a98fb17a0be2bac26b4ddcc31f9b091e038bb5d1 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 18 Apr 2024 11:49:42 +0300 Subject: [PATCH] Integrate ARM KleidiCV as OpenCV HAL. --- CMakeLists.txt | 15 +++++++++++++++ .../config_reference/config_reference.markdown | 1 + 2 files changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61f4ee2c154b..423c2a3cb3e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ FATAL: In-source builds are not allowed. ") endif() +# Useful for HALs if built as a CMake submodule +set(OPENCV_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) include(cmake/OpenCVMinDepVersions.cmake) @@ -258,6 +260,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 AND NOT XROS) +OCV_OPTION(WITH_KLEIDICV "Use KleidiCV library for ARM platforms" OFF + VISIBLE_IF (AARCH64)) OCV_OPTION(WITH_CPUFEATURES "Use cpufeatures Android library" ON VISIBLE_IF ANDROID VERIFY HAVE_CPUFEATURES) @@ -963,6 +967,13 @@ if(HAVE_OPENVX) endif() endif() +if(WITH_KLEIDICV) + ocv_debug_message(STATUS "Enable KleidiCV acceleration") + if(NOT ";${OpenCV_HAL};" MATCHES ";kleidicv;") + set(OpenCV_HAL "kleidicv;${OpenCV_HAL}") + endif() +endif() + if(WITH_CAROTENE) ocv_debug_message(STATUS "Enable carotene acceleration") if(NOT ";${OpenCV_HAL};" MATCHES ";carotene;") @@ -987,6 +998,10 @@ foreach(hal ${OpenCV_HAL}) else() message(STATUS "Carotene: NEON is not available, disabling carotene...") endif() + elseif(hal STREQUAL "kleidicv") + add_subdirectory(3rdparty/kleidicv) + ocv_hal_register(KLEIDICV_HAL_LIBRARIES KLEIDICV_HAL_HEADERS KLEIDICV_HAL_INCLUDE_DIRS) + list(APPEND OpenCV_USED_HAL "KleidiCV (ver ${KLEIDICV_HAL_VERSION})") elseif(hal STREQUAL "openvx") 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 dba280485fd3..7ced9a2536b1 100644 --- a/doc/tutorials/introduction/config_reference/config_reference.markdown +++ b/doc/tutorials/introduction/config_reference/config_reference.markdown @@ -623,6 +623,7 @@ Following build options are utilized in `opencv_contrib` modules, as stated [pre `CMAKE_TOOLCHAIN_FILE` `WITH_CAROTENE` +`WITH_KLEIDICV` `WITH_CPUFEATURES` `WITH_EIGEN` `WITH_OPENVX`