Skip to content

Instantly share code, notes, and snippets.

@pliablepixels
Last active February 16, 2026 22:47
Show Gist options
  • Select an option

  • Save pliablepixels/d0605aab085592e1d3b6bb9033bdc835 to your computer and use it in GitHub Desktop.

Select an option

Save pliablepixels/d0605aab085592e1d3b6bb9033bdc835 to your computer and use it in GitHub Desktop.
Compile OpenCV 4.14+ on Apple Silicon

Build instructions

1. Prerequisites

brew install cmake pkg-config numpy

2. Clone repos

git clone https://github.com/opencv/opencv
git clone https://github.com/opencv/opencv_contrib
cd opencv

3. Create build directory

mkdir -p build && cd build

4. Configure

cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D CMAKE_OSX_ARCHITECTURES=arm64 \
      -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
      -D OPENCV_ENABLE_NONFREE=ON \
      -D WITH_OPENCL=ON \
      -D WITH_OPENGL=ON \
      -D ENABLE_FAST_MATH=ON \
      -D HAVE_opencv_python3=ON \
      -D PYTHON3_EXECUTABLE=$(which python3) \
      -D PYTHON3_INCLUDE_DIR=$(python -c "from sysconfig import get_path; print(get_path('include'))") \
      -D PYTHON3_PACKAGES_PATH=$(python -c "from sysconfig import get_path; print(get_path('purelib'))") \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D BUILD_EXAMPLES=OFF \
      -D BUILD_opencv_world=OFF ..

5. Build (use all cores)

make -j$(sysctl -n hw.ncpu)

6. Install

sudo make install

7. Test everything works:

python
>>> import cv2
>>> cv2.__version__
'4.14.0-pre'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment