You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Old versions of OpenCvSharp are stored in [opencvsharp_2410](https://github.com/shimat/opencvsharp_2410).
5
+
OpenCvSharp is a cross-platform .NET wrapper for OpenCV, providing a rich set of image processing and computer vision functionality. It supports .NET Framework 4.8, .NET 8 and later, and .NET Standard 2.0.
|**OpenCvSharp4.Windows**| All-in-one package for Windows (except UWP) |[](https://badge.fury.io/nu/OpenCvSharp4.Windows)|
9
+
### Windows
10
+
```bash
11
+
dotnet add package OpenCvSharp4.Windows
12
+
```
16
13
17
-
### Native bindings
18
-
| Package | Description | Link |
19
-
|---------|-------------|------|
20
-
|**OpenCvSharp4.runtime.win**| Native bindings for Windows x64/x86 (except UWP) |[](https://badge.fury.io/nu/OpenCvSharp4.runtime.win)|
21
-
|**OpenCvSharp4.runtime.uwp**| Native bindings for UWP (Universal Windows Platform) x64/x86/ARM |[](https://badge.fury.io/nu/OpenCvSharp4.runtime.uwp)|
22
-
|**OpenCvSharp4.official.runtime.linux-x64**| Native bindings for Linux x64 (built on Ubuntu 24.04) |[](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.linux-x64)|
23
-
|**OpenCvSharp4.official.runtime.ubuntu.22.04-x64**| Native bindings for Ubuntu 22.04 x64 |[](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.ubuntu.22.04-x64)|
24
-
|**OpenCvSharp4.official.runtime.ubuntu.24.04-x64**| Native bindings for Ubuntu 24.04 x64 |[](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.ubuntu.24.04-x64)|
25
-
|**OpenCvSharp4.runtime.linux-arm**| Native bindings for Linux Arm |[](https://www.nuget.org/packages/OpenCvSharp4.runtime.linux-arm/)|
26
-
|**OpenCvSharp4.runtime.wasm**| Native bindings for WebAssembly |[](https://www.nuget.org/packages/OpenCvSharp4.runtime.wasm/)|
Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so) is required to work OpenCvSharp. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows, UWP, Ubuntu, Linux ARM, and WebAssembly are released.
20
+
For more installation options, see the [Installation](#installation) section below.
29
21
30
-
Packages named OpenCvSharp3-* and OpenCvSharp-* are deprecated.
* OpenCvSharp is modeled on the native OpenCV C/C++ API style as much as possible.
24
+
* Many classes of OpenCvSharp implement IDisposable. Unsafe resources are managed automatically.
25
+
* OpenCvSharp does not force object-oriented programming style on you. You can also call native-style OpenCV functions.
26
+
* OpenCvSharp provides functions for converting from `Mat` to `Bitmap` (GDI+) or `WriteableBitmap` (WPF).
27
+
28
+
## Target OpenCV
29
+
*[OpenCV 4.13.0](https://opencv.org/) with [opencv_contrib](https://github.com/opencv/opencv_contrib)
30
+
31
+
## Requirements
32
+
*[.NET Framework 4.8](http://www.microsoft.com/ja-jp/download/details.aspx?id=1639) / [.NET 8](https://www.microsoft.com/net/download) or later / .NET Standard 2.0
33
+
* (Windows) [Visual C++ 2022 Redistributable Package](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
* (Ubuntu) You must pre-install all the dependency packages needed to build OpenCV. Many packages such as libjpeg must be installed for OpenCV to work.
**OpenCvSharp won't work on Unity and Xamarin platforms.** For Unity, please consider using [OpenCV for Unity](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088) or some other solutions.
43
+
44
+
**OpenCvSharp does not support CUDA.** If you want to use CUDA features, you need to customize the native bindings yourself.
35
45
36
46
## Installation
37
47
38
48
### Windows (except UWP)
39
-
Add `OpenCvSharp4` and `OpenCvSharp4.runtime.win` NuGet packages to your project. You can use `OpenCvSharp4.Windows`instead.
49
+
Add `OpenCvSharp4` and `OpenCvSharp4.runtime.win` NuGet packages to your project. Alternatively, you can use the `OpenCvSharp4.Windows`all-in-one package.
40
50
41
51
### UWP
42
52
Add `OpenCvSharp4` and `OpenCvSharp4.runtime.uwp` NuGet packages to your project. Note that `OpenCvSharp4.runtime.win` and `OpenCvSharp4.Windows` don't work for UWP.
If you do not use NuGet, get DLL files from the [release page](https://github.com/shimat/opencvsharp/releases).
79
-
80
-
## Target OpenCV
81
-
*[OpenCV 4.13.0](https://opencv.org/) with [opencv_contrib](https://github.com/opencv/opencv_contrib)
82
-
83
-
## Requirements
84
-
*[.NET Framework 4.8](http://www.microsoft.com/ja-jp/download/details.aspx?id=1639) / [.NET 8](https://www.microsoft.com/net/download) or later / .NET Standard 2.0
85
-
* (Windows) [Visual C++ 2022 Redistributable Package](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
* (Ubuntu) You must pre-install all the dependency packages needed to build OpenCV. Many packages such as libjpeg must be installed in order to work OpenCV.
**OpenCvSharp won't work on Unity and Xamarin platform.** For Unity, please consider using [OpenCV for Unity](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088) or some other solutions.
95
-
96
-
**OpenCvSharp does not support CUDA.** If you want to use the CUDA features, you need to customize the native bindings yourself.
97
-
98
87
## Usage
99
-
For more details, see**[samples](https://github.com/shimat/opencvsharp_samples/)** and **[Wiki](https://github.com/shimat/opencvsharp/wiki)** pages.
88
+
For more details, refer to the**[samples](https://github.com/shimat/opencvsharp_samples/)** and **[Wiki](https://github.com/shimat/opencvsharp/wiki)** pages.
100
89
101
-
**Always remember to release Mat instances! The `using` syntax is useful.**
90
+
**Always remember to release Mat and other IDisposable resources using the `using` syntax:**
As mentioned above, objects of classes, such as Mat and MatExpr, have unmanaged resources and need to be manually released by calling the Dispose() method. Worst of all, the +, -, *, and other operators create new objects each time, and these objects need to be disposed, or there will be memory leaks. Despite having the using syntax, the code still looks very verbose.
113
+
<details>
114
+
<summary><b>Advanced: Using ResourcesTracker for automatic resource management</b></summary>
125
115
126
-
Therefore, a ResourcesTracker class is provided. The ResourcesTracker implements the IDisposable interface, and when the Dispose() method is called, all resources tracked by the ResourcesTracker are disposed. The T() method of ResourcesTracker can trace an object or an array of objects, and the method NewMat() is like T(new Mat(...). All the objects that need to be released can be wrapped with T().For example: t.T(255 - t.T(picMat * 0.8)) . Example code is as following:
116
+
As mentioned above, objects of classes such as Mat and MatExpr have unmanaged resources and need to be manually released by calling the Dispose() method. Additionally, the +, -, *, and other operators create new objects each time, and these objects need to be disposed to prevent memory leaks. Despite having the using syntax, the code can still look verbose.
117
+
118
+
Therefore, a ResourcesTracker class is provided. The ResourcesTracker implements the IDisposable interface, and when the Dispose() method is called, all resources tracked by the ResourcesTracker are disposed. The T() method of ResourcesTracker can track an object or an array of objects, and the NewMat() method is equivalent to T(new Mat(...)). All objects that need to be released can be wrapped with T(). For example: t.T(255 - t.T(picMat * 0.8)). Example code is as follows:
127
119
128
120
```csharp
129
121
using (vart=newResourcesTracker())
@@ -147,20 +139,48 @@ using (var t = new ResourcesTracker())
147
139
}
148
140
```
149
141
150
-
151
-
## Features
152
-
* OpenCvSharp is modeled on the native OpenCV C/C++ API style as much as possible.
153
-
* Many classes of OpenCvSharp implement IDisposable. There is no need to manage unsafe resources.
154
-
* OpenCvSharp does not force object-oriented programming style on you. You can also call native-style OpenCV functions.
155
-
* OpenCvSharp provides functions for converting from `Mat` into `Bitmap`(GDI+) or `WriteableBitmap`(WPF).
|**OpenCvSharp4.Windows**| All-in-one package for Windows (except UWP) |[](https://badge.fury.io/nu/OpenCvSharp4.Windows)|
159
+
160
+
### Native bindings
161
+
| Package | Description | Link |
162
+
|---------|-------------|------|
163
+
|**OpenCvSharp4.runtime.win**| Native bindings for Windows x64/x86 (except UWP) |[](https://badge.fury.io/nu/OpenCvSharp4.runtime.win)|
164
+
|**OpenCvSharp4.runtime.uwp**| Native bindings for UWP (Universal Windows Platform) x64/x86/ARM |[](https://badge.fury.io/nu/OpenCvSharp4.runtime.uwp)|
165
+
|**OpenCvSharp4.official.runtime.linux-x64**| Native bindings for Linux x64 (built on Ubuntu 24.04) |[](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.linux-x64)|
166
+
|**OpenCvSharp4.official.runtime.ubuntu.22.04-x64**| Native bindings for Ubuntu 22.04 x64 |[](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.ubuntu.22.04-x64)|
167
+
|**OpenCvSharp4.official.runtime.ubuntu.24.04-x64**| Native bindings for Ubuntu 24.04 x64 |[](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.ubuntu.24.04-x64)|
168
+
|**OpenCvSharp4.runtime.linux-arm**| Native bindings for Linux Arm |[](https://www.nuget.org/packages/OpenCvSharp4.runtime.linux-arm/)|
169
+
|**OpenCvSharp4.runtime.wasm**| Native bindings for WebAssembly |[](https://www.nuget.org/packages/OpenCvSharp4.runtime.wasm/)|
170
+
171
+
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, UWP, Ubuntu, Linux ARM, and WebAssembly are available.
172
+
173
+
Packages named OpenCvSharp3-* and OpenCvSharp-* are deprecated.
If you want to use some OpenCV features that are not provided by default in OpenCvSharp (e.g. GPU), you will have to build OpenCV yourself. The binary files of OpenCV for OpenCvSharp for Windows are created in the [opencv_files](https://github.com/shimat/opencv_files) repository. See the README.
195
+
If you want to use OpenCV features that are not included by default in OpenCvSharp (e.g., GPU support), you will need to build OpenCV yourself. The binary files of OpenCV for OpenCvSharp for Windows are created in the [opencv_files](https://github.com/shimat/opencv_files) repository. See the README for details.
0 commit comments