.Net (dotNet) wrappers for OpenCV?

57,623

Solution 1

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

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

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 4

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 5

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

Share:
57,623
Kris Erickson
Author by

Kris Erickson

Full Stack developer, in spare time blogger about programming and builder of things (Recipe Folder for example).

Updated on July 05, 2022

Comments

  • Kris Erickson
    Kris Erickson almost 2 years

    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.

  • Kaganar
    Kaganar about 10 years
    Beware, EmguCV uses a dual GPL3/Commercial license whereas OpenCV uses a BSD license. Note that OpenCVSharp uses an LGPL license. OpenCVSharp is actively developed as of April, 2014.
  • Mike
    Mike almost 10 years
    It is also available on github
  • VoteCoffee
    VoteCoffee over 9 years
    It is also available on NuGet and is the recommended location if you're using VS2012 or later
  • kdbanman
    kdbanman almost 9 years
    If you have plans to ship your project as a real, maintainable product, then be wary of OpenCVSharp. I played with it for a few weeks - it works fine but the docs and examples are sparse. I like its BSD license and the dev is good/active, but he needs a proper team. EmguCV's documentation, working examples, and community support are vastly superior.
  • kdbanman
    kdbanman almost 9 years
    I really like your idea. Removing a layer of maintenance and complexity by ignoring a third party wrapper sounds great. Can you link/provide a minimal example of the modified source?
  • Dmitry Fedorkov
    Dmitry Fedorkov over 7 years
    EmguCV depends on an old versions of the system libraries (including GTK+ 2). It might be a problem if you are planning to use it on any unsupported system e.g. Arch Linux.
  • Andy P
    Andy P about 7 years
    Link to getting started guide is timing out for me
  • Fetchez la vache
    Fetchez la vache about 7 years
    Has your blog been relocated, @friism ? friism.com is dead.
  • Avi Turner
    Avi Turner over 3 years
    Kudos for keeping the answer updated over 5 years after original post.
  • Sid133
    Sid133 almost 3 years
    Yeah. License is something to watchout if we are to build products.