From be14a1d47a9602b976eb2a6b34d29722efe4da66 Mon Sep 17 00:00:00 2001 From: Prasadayus <22bcs191@iiitdmj.ac.in> Date: Tue, 27 Oct 2026 16:44:17 +0530 Subject: [PATCH 1/5] Add Windows ARM64 support for 5.x --- .github/workflows/build_wheels_windows.yml | 29 +++++++++++++++------- setup.py | 19 +++++++++++--- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index 81098be0..7b93f743 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -1,4 +1,4 @@ -name: Windows x86_64 +name: Windows on: pull_request: @@ -17,12 +17,11 @@ on: jobs: Build: - runs-on: windows-2022 + runs-on: ${{ matrix.platform == 'arm64' && 'windows-11-arm' || 'windows-2022' }} strategy: fail-fast: false matrix: - python-version: ['3.9'] - platform: [x86, x64] + platform: [x86, x64, arm64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] @@ -32,6 +31,7 @@ jobs: ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata + PYTHON_VERSION: ${{ matrix.platform == 'arm64' && '3.11' || '3.9' }} steps: - name: Cleanup shell: bash @@ -50,17 +50,20 @@ jobs: with: submodules: false fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.platform }} - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.1 + with: + msbuild-architecture: ${{ matrix.platform }} - name: Setup NASM + if: matrix.platform != 'arm64' uses: ilammy/setup-nasm@v1 - name: Build a package - # CMake 3.25 regression fix. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version + # CMake 3.25 regression fix for x86/x64. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version run: | python --version python -m pip install --upgrade pip @@ -77,7 +80,7 @@ jobs: Test: needs: [Build] - runs-on: windows-2022 + runs-on: ${{ matrix.platform == 'arm64' && 'windows-11-arm' || 'windows-2022' }} defaults: run: shell: cmd @@ -85,10 +88,18 @@ jobs: fail-fast: false matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] - platform: [x86, x64] + platform: [x86, x64, arm64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] + exclude: + # actions/setup-python does not provide prebuilt arm64 Python before 3.11 + - platform: arm64 + python-version: '3.8' + - platform: arm64 + python-version: '3.9' + - platform: arm64 + python-version: '3.10' env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata diff --git a/setup.py b/setup.py index a6f10ffb..a0c7e008 100755 --- a/setup.py +++ b/setup.py @@ -101,10 +101,11 @@ def main(): # Files from CMake output to copy to package. # Path regexes with forward slashes relative to CMake install dir. + # Note: FFMPEG dlls are not yet provided for Windows ARM64 rearrange_cmake_output_data = { "cv2": ( [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if is64 else "")] - if os.name == "nt" + if os.name == "nt" and not (platform.machine() == "ARM64" and sys.platform == "win32") else [] ) + @@ -157,9 +158,13 @@ def main(): # HACK: Disabled generic assembler for now. # Windows 2025 CI environment does not provide suitable assembler or build is broken in OpenCV MLAS. + # On ARM64, NOTFOUND also avoids a MinGW toolchain on PATH being misdetected by CMake's ASM probe. ci_cmake_generator = ( - ["-G", "Visual Studio 17 2022", - "-DCMAKE_ASM_COMPILER="] + ["-G", "Visual Studio 18 2026", + "-DCMAKE_ASM_COMPILER=CMAKE_ASM_COMPILER-NOTFOUND"] + if os.name == "nt" and platform.machine() == "ARM64" + else ["-G", "Visual Studio 17 2022", + "-DCMAKE_ASM_COMPILER="] if os.name == "nt" else ["-G", "Unix Makefiles"] ) @@ -198,7 +203,8 @@ def main(): # Emulated cmake requires following flags to correctly detect # target architecture for windows/arm64 build "-DOPENCV_WORKAROUND_CMAKE_20989=ON", - "-DCMAKE_SYSTEM_PROCESSOR=ARM64"] + "-DCMAKE_SYSTEM_PROCESSOR=ARM64", + "-DWITH_OPENCL=OFF"] if platform.machine() == "ARM64" and sys.platform == "win32" # If it is not defined 'linker flags: /machine:X86' on Windows x64 else ["-DCMAKE_GENERATOR_PLATFORM=x64"] if is64 and sys.platform == "win32" @@ -264,6 +270,11 @@ def main(): cmake_args.append("-DWITH_LAPACK=ON") cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF") + if sys.platform.startswith('win') and platform.machine().lower() in ("arm64", "aarch64"): + # MSVC does not support OpenCV dispatch features such as NEON_FP16, NEON_BF16 and NEON_DOTPROD. So use NEON as both baseline and dispatch units + cmake_args.append("-DCPU_BASELINE=NEON") + cmake_args.append("-DCPU_DISPATCH=NEON") + # works via side effect RearrangeCMakeOutput( rearrange_cmake_output_data, files_outside_package_dir, package_data.keys() From f66dd1d99ef00f82cc32ded7e8d735cd53ce0c3b Mon Sep 17 00:00:00 2001 From: Prasadayus <22bcs191@iiitdmj.ac.in> Date: Sun, 8 Nov 2026 14:42:09 +0530 Subject: [PATCH 2/5] remove redundant CPU_BASELINE/CPU_DISPATCH NEON flags on win_arm64 --- setup.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup.py b/setup.py index a0c7e008..3b27f804 100755 --- a/setup.py +++ b/setup.py @@ -270,11 +270,6 @@ def main(): cmake_args.append("-DWITH_LAPACK=ON") cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF") - if sys.platform.startswith('win') and platform.machine().lower() in ("arm64", "aarch64"): - # MSVC does not support OpenCV dispatch features such as NEON_FP16, NEON_BF16 and NEON_DOTPROD. So use NEON as both baseline and dispatch units - cmake_args.append("-DCPU_BASELINE=NEON") - cmake_args.append("-DCPU_DISPATCH=NEON") - # works via side effect RearrangeCMakeOutput( rearrange_cmake_output_data, files_outside_package_dir, package_data.keys() From 994de5294f6c7ba74fe678805e1dfce885f8951f Mon Sep 17 00:00:00 2001 From: Prasadayus <22bcs191@iiitdmj.ac.in> Date: Tue, 10 Nov 2026 11:40:36 +0530 Subject: [PATCH 3/5] fix numpy source-build failure on win_arm64 --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ff65d776..e92c1bdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ [build-system] requires = [ "numpy<2.0; python_version<'3.9'", - "numpy==2.0.2; python_version>='3.9' and python_version<'3.13'", + "numpy==2.0.2; python_version>='3.9' and python_version<'3.13' and platform_machine!='ARM64'", + "numpy>=2.3.0; python_version>='3.9' and python_version<'3.13' and platform_machine=='ARM64'", "numpy==2.1.3; python_version=='3.13'", "numpy==2.3.2; python_version=='3.14'", "packaging", From 00c17e29b3782a714035ec6328285851b9ff2c7f Mon Sep 17 00:00:00 2001 From: Prasadayus <22bcs191@iiitdmj.ac.in> Date: Tue, 10 Nov 2026 14:49:16 +0530 Subject: [PATCH 4/5] Bump submodules to 5.1.0 --- opencv | 2 +- opencv_contrib | 2 +- opencv_extra | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opencv b/opencv index 40738fb1..e4f78fbc 160000 --- a/opencv +++ b/opencv @@ -1 +1 @@ -Subproject commit 40738fb16ceddb5fb3fea747585f7ce6abb0605b +Subproject commit e4f78fbcf1a773fbed69e14500e8b734963eb585 diff --git a/opencv_contrib b/opencv_contrib index 755e5067..b67a8551 160000 --- a/opencv_contrib +++ b/opencv_contrib @@ -1 +1 @@ -Subproject commit 755e50675d97db9b7d449d8bd6b09888646f6c6e +Subproject commit b67a855188a3d683813731010f6d39ac614733a4 diff --git a/opencv_extra b/opencv_extra index 3becd947..c9608cf1 160000 --- a/opencv_extra +++ b/opencv_extra @@ -1 +1 @@ -Subproject commit 3becd947dd6bf6340047de8ca4445a70271e6073 +Subproject commit c9608cf1253af28797bca7550846d13c7db81de7 From 9e11dede198b900055dd2d9d9e6ddd913f548cbf Mon Sep 17 00:00:00 2001 From: Prasadayus <22bcs191@iiitdmj.ac.in> Date: Wed, 11 Nov 2026 13:33:32 +0530 Subject: [PATCH 5/5] Revert submodule bumps, add WITH_OPENCL comment --- opencv | 2 +- opencv_contrib | 2 +- opencv_extra | 2 +- setup.py | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/opencv b/opencv index e4f78fbc..40738fb1 160000 --- a/opencv +++ b/opencv @@ -1 +1 @@ -Subproject commit e4f78fbcf1a773fbed69e14500e8b734963eb585 +Subproject commit 40738fb16ceddb5fb3fea747585f7ce6abb0605b diff --git a/opencv_contrib b/opencv_contrib index b67a8551..755e5067 160000 --- a/opencv_contrib +++ b/opencv_contrib @@ -1 +1 @@ -Subproject commit b67a855188a3d683813731010f6d39ac614733a4 +Subproject commit 755e50675d97db9b7d449d8bd6b09888646f6c6e diff --git a/opencv_extra b/opencv_extra index c9608cf1..3becd947 160000 --- a/opencv_extra +++ b/opencv_extra @@ -1 +1 @@ -Subproject commit c9608cf1253af28797bca7550846d13c7db81de7 +Subproject commit 3becd947dd6bf6340047de8ca4445a70271e6073 diff --git a/setup.py b/setup.py index 3b27f804..59d01195 100755 --- a/setup.py +++ b/setup.py @@ -204,6 +204,8 @@ def main(): # target architecture for windows/arm64 build "-DOPENCV_WORKAROUND_CMAKE_20989=ON", "-DCMAKE_SYSTEM_PROCESSOR=ARM64", + # Adreno GPUs (used on Windows ARM64 devices) produce numerically + # divergent OpenCL kernel results. "-DWITH_OPENCL=OFF"] if platform.machine() == "ARM64" and sys.platform == "win32" # If it is not defined 'linker flags: /machine:X86' on Windows x64