Developer note: Windows ARM64
There is no prebuild version of OpenCV for Windows ARM64. See instructions below, in order to build your own.
Note: if you are on windows ARM64 and want to build for x64 use: cmake .. -A x64
Using a "world" dll version of OpenCV
Build and install a DLL "world" version of OpenCV for ARM64
(world means you get only one dll for all OpenCV)
The two important options are INSTALL_CREATE_DISTRIB (will create dll opencv_world), BUILD_SHARED_LIBS=ON (required for world build).
You can tweak the other options, which are here to reduce the build time.
(**Change the last parameter of the cmake command to your desired installation path**)
mkdir build_arm64_dll_world
cd build_arm64_dll_world
cmake ../opencv_git -DINSTALL_CREATE_DISTRIB=ON -DBUILD_SHARED_LIBS=ON -A ARM64 -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_apps=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DCMAKE_INSTALL_PREFIX=F:/dvp/_OpenCV/opencv4.6.0_arm64_dll_world
cmake --build . --config Release
cmake --install . --config Release
cmake --build . --config Debug
cmake --install . --config Debug
cd ..
Build ImGui Bundle pip package on Windows ARM64 with "world" opencv
Note / December 2022: at the time of writing, the pip package "opencv-python" refuses to build with python ARM64 on windows. imgui_bundle does work however but one cannot use opencv (aka cv2) from python.
You need an arm version of python. See https://www.python.org/downloads/windows/ (if you need pip, youd need the full setup, not the embeddable version)
Set OpenCV env variables:
-
OpenCV_DIR=/path/to/your/opencv_world_install
-
CMAKE_GENERATOR_PLATFORM=ARM64
Not so funny note: there are at least 4 incompatible ways to set an env var in Windows.
-
The clicky way
-
with PowerShell Set-Item -Path 'Env:OpenCV_DIR' -Value 'F:/dvp/_opencv/opencv4.6.0_arm64_dll_world' Set-Item -Path 'Env:CMAKE_GENERATOR_PLATFORM' -Value 'ARM64'
-
With bash export OpenCV_DIR=F:/dvp/_opencv/opencv4.6.0_arm64_dll_world export CMAKE_GENERATOR_PLATFORM=ARM64
-
With dos set OpenCV_DIR=F:/dvp/_opencv/opencv4.6.0_arm64_dll_world set CMAKE_GENERATOR_PLATFORM=ARM64
Then, pip install:
pip install -v .
Build CppLib on Windows ARM64 with world OpenCV
Specify cmake options
cmake .. -DOpenCV_DIR=F:/dvp/_opencv/opencv4.6.0_arm64_dll_world -DCMAKE_GENERATOR_PLATFORM=ARM64
Explanations:
-
OpenCV_DIR: you opencv install path
-
CMAKE_GENERATOR_PLATFORM: tells openCV to look in the ARM64 folder
Using a static version of OpenCV
Build and install a static version of OpenCV for ARM64
Git clone and checkout v4.6.0
mkdir _opencv
cd _opencv
git clone https://github.com/opencv/opencv.git opencv_git
cd opencv_git
git checkout 4.6.0
cd ..
Build and install OpenCV with those settings (Change the last parameter of the cmake command to your desired installation path)
The important option is BUILD_SHARED_LIBS=OFF. You can tweak the other options, which are here to reduce the build time.
mkdir build_ARM64
cd build_ARM64
cmake ../opencv_git -A ARM64 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_opencv_apps=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_JASPER=OFF -DWITH_JASPER=OFF -DWITH_CUDA=OFF -DWITH_FFMPEG=OFF -DWITH_GTK=OFF -DCMAKE_INSTALL_PREFIX=F:/dvp/_OpenCV/opencv4.6.0_static_install_win_vc17
cmake --build . --config Release
cmake --install .
cd ..
Build ImGui Bundle pip package on Windows ARM64 with static OpenCV
You need an arm version of python. See https://www.python.org/downloads/windows/ (if you need pip, youd need the full setup, not the embeddable version)
Set OpenCV env variables: * with PowerShell
Set-Item -Path 'Env:OpenCV_DIR' -Value 'F:/dvp/_opencv/opencv4.6.0_static_install_win_vc17' Set-Item -Path 'Env:OpenCV_STATIC' -Value 'ON'
Set-Item -Path 'Env:CMAKE_GENERATOR_PLATFORM' -Value 'ARM64'
-
With bash:
export OpenCV_DIR=F:/dvp/_opencv/opencv-4.6.0-vc14_vc15/opencv/build
-
With dos:
set OpenCV_DIR=F:/dvp/_opencv/opencv-4.6.0-vc14_vc15/opencv/build
Build CppLib on Windows ARM64 with static OpenCV
Specify cmake options
cmake .. -DOpenCV_DIR=F:/dvp/_opencv/opencv4.6.0_static_install_win_vc17 -DOpenCV_STATIC=ON -DCMAKE_GENERATOR_PLATFORM=ARM64 -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
Explanations:
-
OpenCV_DIR: you opencv install path
-
CMAKE_GENERATOR_PLATFORM: tells openCV to look in the ARM64 folder
-
OpenCV_STATIC: tells OpenCV to look in the ARM64/vc17/staticlib folder
-
CMAKE_MSVC_RUNTIME_LIBRARY: tells MSVC to use static runtime (/MT)
-
BUILD_SHARED_LIBS=OFF: build static libs. Normally, this could be ignored