Skip to content

Commit 6c10282

Browse files
authored
Merge pull request #1947 from mathieucarbou/macos
Restore macOS support: add x64 and arm64 runtime NuGet packages
2 parents b1ccbe9 + f927f2a commit 6c10282

14 files changed

Lines changed: 555 additions & 26 deletions

.github/workflows/macos.yml

Lines changed: 407 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/publish_nuget.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
name: artifacts_linux_arm64
3535
branch: ${{ github.ref_name }}
3636

37-
#- name: Download macos artifact
38-
# uses: dawidd6/action-download-artifact@v19
39-
# with:
40-
# github_token: ${{secrets.GITHUB_TOKEN}}
41-
# workflow: macos10.yml
42-
# name: artifacts_macos_10
43-
# branch: ${{ github.ref_name }}
37+
- name: Download macos artifact
38+
uses: dawidd6/action-download-artifact@v21
39+
with:
40+
github_token: ${{secrets.GITHUB_TOKEN}}
41+
workflow: macos.yml
42+
name: nuget-packages-macos
43+
branch: ${{ github.ref_name }}
4444

4545
- name: Download wasm artifact
4646
uses: dawidd6/action-download-artifact@v21
@@ -92,6 +92,8 @@ jobs:
9292
check_package "OpenCvSharp4.runtime.wasm.*.nupkg"
9393
check_package "OpenCvSharp4.official.runtime.linux-x64.[0-9]*.nupkg"
9494
check_package "OpenCvSharp4.official.runtime.linux-x64.slim.*.nupkg"
95+
check_package "OpenCvSharp4.runtime.osx.x64.*.nupkg"
96+
check_package "OpenCvSharp4.runtime.osx.arm64.*.nupkg"
9597
9698
if [ "$failed" -gt 0 ]; then
9799
echo ""

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ UpgradeLog*.XML
125125
# Local OpenCV / Tesseract build outputs (generated by build_opencv_windows.ps1)
126126
/opencv/build*/
127127
/opencv_artifacts/
128+
/opencv_artifacts_arm64/
128129
/tesseract_artifacts/
129130
/vcpkg_installed/
130131
/src/build/
132+
/src/build-arm64/
131133
/opencv_files
132134
/test/OpenCvSharp.Tests/dll/x64/*.dll
133135
/test/OpenCvSharp.Tests/dll/x86/*.dll

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![opencvsharp](https://socialify.git.ci/shimat/opencvsharp/image?description=1&forks=1&language=1&owner=1&pattern=Plus&stargazers=1&theme=Light)
22

3-
[![Github Actions Windows Status](https://github.com/shimat/opencvsharp/workflows/Windows%20Server%202025/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions Docker Test Status](https://github.com/shimat/opencvsharp/workflows/Docker%20Test/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions manylinux Status](https://github.com/shimat/opencvsharp/workflows/manylinux/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions Wasm Status](https://github.com/shimat/opencvsharp/workflows/Wasm/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![GitHub license](https://img.shields.io/github/license/shimat/opencvsharp.svg)](https://github.com/shimat/opencvsharp/blob/master/LICENSE)
3+
[![Github Actions Windows Status](https://github.com/shimat/opencvsharp/workflows/Windows%20Server%202025/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions Docker Test Status](https://github.com/shimat/opencvsharp/workflows/Docker%20Test/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions manylinux Status](https://github.com/shimat/opencvsharp/workflows/manylinux/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions Wasm Status](https://github.com/shimat/opencvsharp/workflows/Wasm/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions macOS Status](https://github.com/shimat/opencvsharp/workflows/macos/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![GitHub license](https://img.shields.io/github/license/shimat/opencvsharp.svg)](https://github.com/shimat/opencvsharp/blob/master/LICENSE)
44

55
OpenCvSharp is a cross-platform .NET wrapper for OpenCV, providing a rich set of image processing and computer vision functionality. It supports .NET 8+, .NET Standard 2.0/2.1, and .NET Framework 4.6.1+.
66

@@ -25,6 +25,15 @@ dotnet add package OpenCvSharp4.official.runtime.linux-x64
2525
# dotnet add package OpenCvSharp4.official.runtime.linux-x64.slim
2626
```
2727

28+
### macOS
29+
```bash
30+
dotnet add package OpenCvSharp4
31+
# Intel (x64):
32+
dotnet add package OpenCvSharp4.runtime.osx.x64
33+
# Apple Silicon (arm64):
34+
dotnet add package OpenCvSharp4.runtime.osx.arm64
35+
```
36+
2837
For more installation options, see the [Installation](#installation) section below.
2938

3039
## Features
@@ -83,6 +92,23 @@ dotnet run
8392
> ⚠️ The distro-specific `OpenCvSharp4.official.runtime.ubuntu.*` packages are **no longer maintained**. Use `OpenCvSharp4.official.runtime.linux-x64` instead.
8493
8594

95+
### macOS (Intel and Apple Silicon)
96+
Add `OpenCvSharp4` and the runtime package matching your architecture:
97+
```bash
98+
dotnet new console -n ConsoleApp01
99+
cd ConsoleApp01
100+
dotnet add package OpenCvSharp4
101+
# Intel (x64):
102+
dotnet add package OpenCvSharp4.runtime.osx.x64
103+
# Apple Silicon (arm64):
104+
dotnet add package OpenCvSharp4.runtime.osx.arm64
105+
# --- edit Program.cs ---
106+
dotnet run
107+
```
108+
109+
> **Note:** The macOS packages include FFmpeg, Tesseract, Freetype, and all standard OpenCV modules, statically linked.
110+
111+
86112
### Slim profile module coverage
87113

88114
The `slim` runtime packages keep a practical subset while reducing runtime dependencies.
@@ -177,12 +203,14 @@ http://shimat.github.io/opencvsharp/api/OpenCvSharp.html
177203
|**[OpenCvSharp4.runtime.linux-arm64](https://www.nuget.org/packages/OpenCvSharp4.runtime.linux-arm64/)**| Native bindings for Linux ARM64 (AArch64) |
178204
|**[OpenCvSharp4.runtime.linux-arm](https://www.nuget.org/packages/OpenCvSharp4.runtime.linux-arm/)**| **Deprecated.** Compatibility shim for `OpenCvSharp4.runtime.linux-arm64`. |
179205
|**[OpenCvSharp4.runtime.wasm](https://www.nuget.org/packages/OpenCvSharp4.runtime.wasm/)**| Native bindings for WebAssembly |
180-
206+
|**[OpenCvSharp4.runtime.osx.x64](https://www.nuget.org/packages/OpenCvSharp4.runtime.osx.x64/)**| Native bindings for macOS Intel (x64). FFmpeg, Tesseract, HDF, and Freetype are not included. |
207+
|**[OpenCvSharp4.runtime.osx.arm64](https://www.nuget.org/packages/OpenCvSharp4.runtime.osx.arm64/)**| Native bindings for macOS Apple Silicon (arm64). FFmpeg, Tesseract, HDF, and Freetype are not included. |
208+
181209
> **Note:** Windows x86 (32-bit) support has been dropped as of the OpenCV 4.13.0 release series.
182210
> The `OpenCvSharp4.runtime.win` and `OpenCvSharp4.runtime.win.slim` packages now ship **x64-only** native binaries.
183211
> Users requiring x86 Windows support should stay on the last OpenCV 4.12.x-based packages.
184212
185-
Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so) is required for OpenCvSharp to work. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, and WebAssembly are available.
213+
Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so / libOpenCvSharpExtern.dylib) is required for OpenCvSharp to work. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, macOS x64/arm64, and WebAssembly are available.
186214

187215
Packages named OpenCvSharp3-* and OpenCvSharp-* are deprecated.
188216
> [OpenCvSharp3-AnyCPU](https://www.nuget.org/packages/OpenCvSharp3-AnyCPU/) / [OpenCvSharp3-WithoutDll](https://www.nuget.org/packages/OpenCvSharp3-WithoutDll/) / [OpenCvSharp-AnyCPU](https://www.nuget.org/packages/OpenCvSharp-AnyCPU/) / [OpenCvSharp-WithoutDll](https://www.nuget.org/packages/OpenCvSharp-WithoutDll/)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(VCPKG_TARGET_ARCHITECTURE arm64)
2+
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
3+
set(VCPKG_OSX_ARCHITECTURES arm64)
4+
set(VCPKG_CRT_LINKAGE dynamic)
5+
set(VCPKG_LIBRARY_LINKAGE static)
6+
7+
# Release-only build: skip debug libraries to reduce build time and artifact size.
8+
set(VCPKG_BUILD_TYPE release)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(VCPKG_TARGET_ARCHITECTURE x64)
2+
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
3+
set(VCPKG_OSX_ARCHITECTURES x86_64)
4+
set(VCPKG_CRT_LINKAGE dynamic)
5+
set(VCPKG_LIBRARY_LINKAGE static)
6+
7+
# Release-only build: skip debug libraries to reduce build time and artifact size.
8+
set(VCPKG_BUILD_TYPE release)

docs/docfx/articles/intro.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Introduction to OpenCvSharp
1+
# Introduction to OpenCvSharp
22

33
OpenCvSharp is a .NET wrapper for OpenCV, one of the most popular open-source computer vision libraries.
44

@@ -10,7 +10,7 @@ OpenCvSharp provides cross-platform .NET bindings for OpenCV, allowing you to us
1010

1111
- **Windows**: x64, x86, UWP
1212
- **Linux**: Ubuntu 22.04, 24.04, ARM
13-
- **macOS**: x64
13+
- **macOS**: x64 (Intel), arm64 (Apple Silicon)
1414
- **WebAssembly**: Browser-based applications
1515

1616
## Getting Started
@@ -28,6 +28,8 @@ dotnet add package OpenCvSharp4.runtime.win # Windows
2828
# dotnet add package OpenCvSharp4.runtime.win.slim # Windows slim
2929
dotnet add package OpenCvSharp4.official.runtime.linux-x64 # Linux x64
3030
# dotnet add package OpenCvSharp4.official.runtime.linux-x64.slim # Linux x64 slim
31+
dotnet add package OpenCvSharp4.runtime.osx.x64 # macOS x64 (Intel)
32+
dotnet add package OpenCvSharp4.runtime.osx.arm64 # macOS arm64 (Apple Silicon)
3133
```
3234

3335
### Quick Example
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
4+
<NoBuild>true</NoBuild>
5+
<IncludeBuildOutput>false</IncludeBuildOutput>
6+
7+
<!-- NuGet Package Metadata -->
8+
<PackageId>OpenCvSharp4.runtime.osx.arm64</PackageId>
9+
<Title>OpenCvSharp native bindings for macOS arm64 (Apple Silicon)</Title>
10+
<Authors>shimat</Authors>
11+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
12+
<PackageProjectUrl>https://github.com/shimat/opencvsharp</PackageProjectUrl>
13+
<PackageIcon>opencvsharp.png</PackageIcon>
14+
<Description>Internal implementation package for OpenCvSharp to work on macOS arm64 (Apple Silicon)</Description>
15+
<PackageTags>Image Processing OpenCV Wrapper FFI opencvsharp macos arm64 applesilicon</PackageTags>
16+
<Copyright>Copyright 2008-2026</Copyright>
17+
<PackageReleaseNotes></PackageReleaseNotes>
18+
<RepositoryUrl>https://github.com/shimat/opencvsharp.git</RepositoryUrl>
19+
<RepositoryType>git</RepositoryType>
20+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
21+
<PackageReadmeFile>README.runtime.md</PackageReadmeFile>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<None Include="libOpenCvSharpExtern.dylib" Pack="true" PackagePath="runtimes/osx-arm64/native" />
26+
<None Include="icon/opencvsharp.png" Pack="true" PackagePath="" />
27+
<None Include="README.runtime.md" Pack="true" PackagePath="" />
28+
</ItemGroup>
29+
</Project>

nuget/OpenCvSharp4.runtime.osx.10.15-x64.csproj renamed to nuget/OpenCvSharp4.runtime.osx.x64.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
44
<NoBuild>true</NoBuild>
55
<IncludeBuildOutput>false</IncludeBuildOutput>
66

77
<!-- NuGet Package Metadata -->
8-
<PackageId>OpenCvSharp4.runtime.osx.10.15-x64</PackageId>
9-
<Title>OpenCvSharp native bindings for macOS.10.15-x64</Title>
8+
<PackageId>OpenCvSharp4.runtime.osx.x64</PackageId>
9+
<Title>OpenCvSharp native bindings for macOS x64 (Intel)</Title>
1010
<Authors>shimat,vladkol</Authors>
1111
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1212
<PackageProjectUrl>https://github.com/shimat/opencvsharp</PackageProjectUrl>
1313
<PackageIcon>opencvsharp.png</PackageIcon>
14-
<Description>Internal implementation package for OpenCvSharp to work on macOS 10</Description>
14+
<Description>Internal implementation package for OpenCvSharp to work on macOS x64 (Intel)</Description>
1515
<PackageTags>Image Processing OpenCV Wrapper FFI opencvsharp macos</PackageTags>
1616
<Copyright>Copyright 2008-2026</Copyright>
1717
<PackageReleaseNotes></PackageReleaseNotes>

nuget/README.managed.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ dotnet add package OpenCvSharp4
2929
dotnet add package OpenCvSharp4.official.runtime.linux-x64
3030
```
3131

32+
### macOS
33+
34+
```bash
35+
dotnet add package OpenCvSharp4
36+
# Intel (x64):
37+
dotnet add package OpenCvSharp4.runtime.osx.x64
38+
# Apple Silicon (arm64):
39+
dotnet add package OpenCvSharp4.runtime.osx.arm64
40+
```
41+
3242
For more installation options, see [Installation on GitHub](https://github.com/shimat/opencvsharp#installation).
3343

3444
## Requirements
@@ -45,6 +55,9 @@ The official `OpenCvSharp4.official.runtime.linux-x64` package is built on manyl
4555
- **Full package**: uses GTK3 for `highgui` support (`Cv2.ImShow`, `Cv2.WaitKey`, etc.). GTK3 (`libgtk-3.so.0`) is pre-installed on standard Ubuntu/Debian/RHEL environments and typically requires no action. In minimal or container environments where GTK3 is absent, install it manually: Ubuntu/Debian: `apt-get install libgtk-3-0`; RHEL/AlmaLinux: `dnf install gtk3`. Alternatively, use the **slim** package which has no GUI dependencies.
4656
- **Slim package** (`OpenCvSharp4.official.runtime.linux-x64.slim`): `highgui` is disabled; no GTK3 or other GUI dependencies. Suitable for headless and container environments.
4757

58+
### macOS (Intel and Apple Silicon)
59+
The `OpenCvSharp4.runtime.osx.x64` and `OpenCvSharp4.runtime.osx.arm64` packages provide native bindings for macOS. FFmpeg, Tesseract, Freetype, and all standard OpenCV modules are statically linked.
60+
4861
## Slim Profile
4962

5063
The `slim` runtime packages (`OpenCvSharp4.Windows.Slim`, `OpenCvSharp4.official.runtime.linux-x64.slim`, etc.) bundle a smaller native library:

0 commit comments

Comments
 (0)