.Net (dotNet) wrappers for OpenCV?

C#.NetOpencvMonoCross Platform

C# Problem Overview


I've seen there are a few of them. opencvdotnet, SharperCV, EmguCV, One on Code Project.

Does anyone have any experience with any of these? I played around with the one on Code Project for a bit, but as soon as I tried to do anything complicated I got some nasty uncatchable exceptions (i.e. Msgbox exceptions). Cross platform (supports Mono) would be best.

C# Solutions


Solution 1 - C#

I started out with opencvdotnet but it's not really actively developed any more. Further, support for the feature I needed (facedetection) was patchy. I'm using EmguCV now: It wraps a much greater part of the API and the guy behind it is very responsive to suggestions and requests. The code is a joy to look at and is known to work on Mono.

I've wrote up a quick getting-started guide on my blog.

Solution 2 - C#

We use OpenCVSharp the google code website is in Japanese but it uses the latest OpenCV builds and impliments IDisposable throughout. It seems to provide more functioanlity than any of the others we have seen to date and is still active. It has quite extensive example programs as well.

Solution 3 - C#

I think it's important to note that the original question was asked in 2008, and OpenCV 2.0 was released in 2009. The version 2.0 release introduced a C++ wrapper which is significantly easier to work with than the older C interface that the OP was confronted with. For my .NET project, I'm leaving all the graphic manipulation in native C++.

Try this: create a C++/CLR DLL project which links to the OpenCV libraries. The OpenCV manual describes how to do this for a Windows C++ EXE, the same steps also work for a C++/CLR DLL. Then of course the DLL exports methods which are callable from a .NET EXE.

To test it, you should be able to incorporate any of the OpenCV samples into your DLL with a little tweaking. (Add the .CPP file to your project, convert the main() function to a class member, etc. - you know the drill...) A good test candidate might be the "mat_mask_operations" sample.

Solution 4 - C#

NuGetMustHaves has a good summary of packages on NuGet with their build dates and OpenCV revs.

As of 1/11/2022:

  • EmguCV is updated for OpenCV v 4.5.5.4823 on 1/19/2021
  • OpenCvSharp is updated for OpenCV v 4.5.5.2021123 on 1/24/2021

EmguCV and OpenCvSharp are the 2 packages with recent builds and appear to be the better choices going forward.

Beware, EmguCV uses a dual GPL3/Commercial license (source) whereas OpenCVSharp uses the BSD 3-Clause License. In other words, OpenCVSharp is free for commercial use but EmguCV is not. EmguCV has superior documentation/examples/support and a bigger development team behind it, though, making the license worthwhile in many cases.

It's worth considering what your future use cases are. If you're just looking to get running quickly using a managed language, the wrappers are fine. I started off that way. But as I got into more serious applications, I've found building a python/C++ application has better performance and more potential for reuse of code across platforms.

Solution 5 - C#

I think best wrapper is opencvsharp http://code.google.com/p/opencvsharp/

Solution 6 - C#

I created a NuGet Package to make easy to start with OpenCv in C#, using EmguCV.

Check it out! In Visual Studio search and add the myEmguCV.Net NuGet package.

https://www.nuget.org/packages/myEmguCV.Net

Solution 7 - C#

SharperCV was our tool of choice, and it doesn't let us down, for our robotics project. Even though it is currently marked as abandoned, the code is in really good shape, requires only minor tweaking to customize it for your need. No msgboxes, and actually very sane exception handling.

Not cross-platform, though, due to the interoperability layer.

Solution 8 - C#

I know this question has been answered for a long time, but I would like to add that there is a very good wrapper here. This is the new version of the openCV wrapper that you tried on code project. I've tried it for a couple of days and everything works perfect. Also, I got it working in minutes.

I don't know for the compatibility with mono but under Visual Studio 2010, it works like a charm and saved me ton's of time and money (my project is commercial and most of the library are open source with licence that doesn't allow commercial utilisation unless publishing the code)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKris EricksonView Question on Stackoverflow
Solution 1 - C#friismView Answer on Stackoverflow
Solution 2 - C#tidyupView Answer on Stackoverflow
Solution 3 - C#Paul WilliamsView Answer on Stackoverflow
Solution 4 - C#VoteCoffeeView Answer on Stackoverflow
Solution 5 - C#mrgloomView Answer on Stackoverflow
Solution 6 - C#TonyView Answer on Stackoverflow
Solution 7 - C#Silver DragonView Answer on Stackoverflow
Solution 8 - C#Jean-François CôtéView Answer on Stackoverflow