GitHub - shimat/opencvsharp
OpenCvSharp is a cross-platform .NET wrapper for OpenCV, designed to closely mirror the native C++ API while incorporating C# conventions like typed enums, exceptions, and deterministic disposal Two parallel package families exist: OpenCvSharp5 (active development, OpenCV 5.0.x, .NET 8+) and OpenCvSharp4 (maintenance mode, OpenCV 4.13.0, supports .NET Framework 4.6.1+ through .NET 8+) Linux runtime packages offer three profiles: full (with GTK3 GUI), headless (full modules, no GUI), and slim (re
Analysis
TL;DR
- OpenCvSharp is a cross-platform .NET wrapper for OpenCV, designed to closely mirror the native C++ API while incorporating C# conventions like typed enums, exceptions, and deterministic disposal
- Two parallel package families exist: OpenCvSharp5 (active development, OpenCV 5.0.x, .NET 8+) and OpenCvSharp4 (maintenance mode, OpenCV 4.13.0, supports .NET Framework 4.6.1+ through .NET 8+)
- Linux runtime packages offer three profiles: full (with GTK3 GUI), headless (full modules, no GUI), and slim (reduced modules, no GUI) — critical for containerized deployments
- OpenCvSharp does not support CUDA or Unity/Xamarin platforms; OpenCL acceleration is available through UMat
- Blazor WebAssembly support enables running OpenCvSharp image processing directly in browsers without installation
Why It Matters
OpenCvSharp fills a critical gap for .NET developers who need production-grade computer vision capabilities without leaving the C# ecosystem, providing a low-friction migration path from OpenCV C++/Python codebases. The dual-package strategy (v4/v5) and multiple Linux runtime profiles demonstrate thoughtful lifecycle management for enterprise .NET applications spanning legacy and modern runtimes.
Technical Details
- API Design: Closely follows native OpenCV C++ API structure; supports both object-oriented (class-based) and native-style functional programming paradigms; implements IDisposable for automatic unsafe resource management
- Package Architecture: Every OpenCvSharp5.* package has an OpenCvSharp4.* counterpart; runtime packages are platform-specific (win, win-arm64, linux-x64, osx.x64, osx.arm64) with optional headless and slim variants
- OpenCV Versioning: OpenCvSharp5 bundles OpenCV 5.0.x with opencv_contrib; OpenCvSharp4 bundles OpenCV 4.13.0 with opencv_contrib; includes statically linked FFmpeg (LGPL v2.1) and Tesseract in official Linux packages
- Platform Support: Linux packages built on manylinux_2_28 (Ubuntu 20.04+, Debian 10+, RHEL/AlmaLinux 8+, glibc 2.28+); Windows supports Media Foundation for video; GTK3 required for highgui on Linux (avoidable via headless/slim profiles)
- Limitations: No CUDA support (requires custom native bindings); no Unity or Xamarin support; OpenCL acceleration available via UMat class
Industry Insight
- Teams maintaining .NET Framework applications should continue on OpenCvSharp4, while new projects should adopt OpenCvSharp5 to benefit from OpenCV 5.x features and active development — plan migration using the provided 4→5 guide for namespace and API changes
- For containerized Linux deployments, prefer the headless or slim runtime profiles to eliminate GTK3 dependencies and reduce attack surface; the slim profile is optimal for microservices requiring only core vision modules
- Organizations requiring GPU acceleration beyond OpenCL should budget for custom native binding development or evaluate alternative stacks, as CUDA support is explicitly out of scope for this project
Disclaimer: The above content is generated by AI and is for reference only.