1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Merge pull request #28664 from pratham-mcw:armpl_dft_opt

Add ARMPL support for DFT Function #28664

- This PR introduces hal/armpl/ with implementation of 1D, 2D DFT and DCT routines using ARM Performance Libraries as a custom HAL replacement for OpenCV's DFT & DCT Function.
- ArmPL MSI package is automatically downloaded and extracted via CMake when building on Windows ARM64, with a WITH_ARMPL option that defaults to ON for that platform.
- Forward and inverse real DFT calls in dxt.cpp are routed through ArmPL when available, with scaling applied only when needed.
- Test error thresholds in test_dxt.cpp are relaxed (from 1e-5 to 2e-4 for float ) to account for numerical differences between ArmPL and OpenCV's reference DFT results.

**Performance Benchmarks :**
<img width="993" height="835" alt="image" src="https://github.com/user-attachments/assets/76def647-6d20-4bce-8bc9-7363e723669f" />

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
This commit is contained in:
Pratham Kumar
2026-05-14 13:26:21 +05:30
committed by GitHub
parent 357ad24262
commit eadaab5fbb
9 changed files with 3176 additions and 1 deletions
@@ -19,6 +19,7 @@ Introduction to OpenCV {#tutorial_table_of_content_introduction}
- @subpage tutorial_windows_visual_studio_opencv
- @subpage tutorial_windows_visual_studio_image_watch
- @subpage tutorial_windows_msys2_vscode
- @subpage tutorial_windows_armpl
##### Java & Android
- @subpage tutorial_java_dev_intro
@@ -0,0 +1,169 @@
Building OpenCV with ARM Performance Libraries (ARMPL) on Windows {#tutorial_windows_armpl}
==================================================================
@prev_tutorial{tutorial_windows_install}
@next_tutorial{tutorial_linux_install}
| | |
| -: | :- |
@tableofcontents
Introduction {#tutorial_windows_armpl_intro}
============
This tutorial explains how to build OpenCV on Windows (AArch64) with
[ARM Performance Libraries (ARMPL)](https://developer.arm.com/Tools%20and%20Software/Arm%20Performance%20Libraries)
as a math backend. ARMPL provides optimized BLAS and LAPACK routines for Arm-based hardware
and can significantly accelerate OpenCV operations such as DFT and DCT.
Step 1: Download and Install ARM Performance Libraries {#tutorial_windows_armpl_download}
=====================================================
1. Open a browser and go to the
[ARM Performance Libraries Downloads page](https://developer.arm.com/Tools%20and%20Software/Arm%20Performance%20Libraries#Downloads).
2. Under **Windows / AArch64**, download the installer for your preferred toolchain:
| File | Architecture | Size |
|------|--------------|------|
| `arm-performance-libraries_26.01_Windows.msi` | AArch64 | ~240 MiB |
3. Run the downloaded `.msi` installer and follow the on-screen instructions.
The default installation directory is:
```
C:\Program Files\Arm Performance Libraries\armpl_26.01
```
Step 2: Configure System Environment Variables {#tutorial_windows_armpl_env}
=============================================
OpenCV's CMake scripts (and the ARMPL runtime itself) need to find the library files at both
build time and run time. Add the following entries to the **System** `PATH` variable:
1. Open **System Properties**, click **Advanced**, then **Environment Variables**.
2. Under **System variables**, select `Path` and click **Edit**.
3. Add the two paths below (adjust the version number if yours differs):
```
C:\Program Files\Arm Performance Libraries\armpl_26.01\lib
C:\Program Files\Arm Performance Libraries\armpl_26.01\bin
```
4. Click **OK** on every dialog to save.
Step 3: Clone OpenCV {#tutorial_windows_armpl_clone}
====================
```bat
git clone https://github.com/opencv/opencv.git
cd opencv
```
If you also need the extra modules:
```bat
git clone https://github.com/opencv/opencv_contrib.git
```
Step 4: Configure with CMake {#tutorial_windows_armpl_cmake}
============================
Create a build directory and run CMake with ARMPL support enabled.
**Without OpenMP (single-threaded ARMPL):**
```bat
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A ARM64 ^
-DWITH_ARMPL=ON ^
-DARMPL_ROOT_DIR="C:\Program Files\Arm Performance Libraries\armpl_26.01" ^
-DWITH_OPENMP=OFF ^
..
```
**With OpenMP (multi-threaded ARMPL):**
ARMPL ships both serial and OpenMP-enabled library variants. To use the multi-threaded variant,
enable OpenMP in CMake:
```bat
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A ARM64 ^
-DWITH_ARMPL=ON ^
-DARMPL_ROOT_DIR="C:\Program Files\Arm Performance Libraries\armpl_26.01" ^
-DWITH_OPENMP=ON ^
..
```
@note Enabling `WITH_OPENMP=ON` causes CMake to link against the `armpl_lp64_mp` (multi-threaded)
variant of ARMPL. Disabling it links against the serial `armpl_lp64` variant. Only one variant
should be enabled at a time to avoid symbol conflicts.
Step 5: Build and Install {#tutorial_windows_armpl_build}
=========================
Open the generated `.sln` file in Visual Studio and build the **Release** configuration, or
build from the command line:
```bat
cmake --build . --config Release --parallel
cmake --install . --config Release
```
Step 6: Verify the Build {#tutorial_windows_armpl_verify}
=========================
After a successful build, confirm that OpenCV detects ARMPL by running:
```bat
opencv_version --verbose 2>&1 | findstr /i armpl
```
You should see a line similar to:
```
ARMPL: YES (armpl_26.01)
```
Alternatively, check the CMake configuration log for the line:
```
-- ARMPL support: YES
```
Troubleshooting {#tutorial_windows_armpl_troubleshoot}
===============
**CMake cannot find ARMPL:**
Make sure `ARMPL_ROOT_DIR` points to the folder that contains both `include\` and `lib\`
sub-directories:
```
C:\Program Files\Arm Performance Libraries\armpl_26.01
bin\
include\
lib\
```
**Runtime error: DLL not found:**
Ensure that both the `lib\` and `bin\` directories are on the system `PATH` and that
you opened a new Command Prompt after adding them (changes are not picked up by already-open
sessions).
**Linker errors with OpenMP:**
If you see duplicate symbol errors when `WITH_OPENMP=ON`, make sure you are not also linking
against the serial ARMPL library. Pass `-DWITH_OPENMP=ON` consistently and clean the build
directory before re-running CMake.
See also {#tutorial_windows_armpl_seealso}
=========
- @ref tutorial_windows_install - Generic Windows build guide
- [ARM Performance Libraries documentation](https://developer.arm.com/documentation/101004/)
- @ref tutorial_general_install - General installation guide