shimat/opencvsharp

OpenCV wrapper for .NET

What it solves

OpenCvSharp provides a way for .NET developers to use OpenCV, the industry-standard library for computer vision and image processing, without having to write C++ code. It bridges the gap between the native C++ OpenCV API and the .NET ecosystem (C#), allowing developers to implement complex vision tasks in a managed environment.

How it works

It acts as a cross-platform .NET wrapper around the native OpenCV C++ libraries. The API is designed to mirror the native C++ API as closely as possible, ensuring that documentation and concepts from the original OpenCV project are easily transferable. It handles the transition from unmanaged C++ resources to managed C# code using IDisposable for deterministic memory management and provides specialized extensions for integrating with .NET UI frameworks like WPF, Avalonia, and GDI+.

Who it’s for

It is designed for .NET developers (using C#) who need to integrate computer vision, image analysis, or real-time video processing into their applications across Windows, Linux, macOS, or WebAssembly.

Highlights

  • High Fidelity API: Closely follows the native OpenCV C++ API for minimal friction when porting code or following official OpenCV guides.
  • Cross-Platform Support: Works across Windows (x64/ARM64), Linux (x64/ARM64), macOS (Intel/Apple Silicon), and WebAssembly.
  • Flexible Deployment: Offers different runtime profiles, including "slim" (reduced dependencies) and "headless" (no GUI dependencies for containerized services).
  • Managed Resource Handling: Implements IDisposable for unsafe resources and uses a lazily-evaluated expression tree (MatExpr) for arithmetic to prevent memory leaks during chained operations.

Related

  • Project
  • Project
  • Project
  • Project
  • Project