Ask Your Question
3

C# official bindings roadmap

asked 2013-08-14 10:05:48 -0600

Luca Del Tongo gravatar image

updated 2013-08-15 04:21:06 -0600

I read latest Opencv roadmap presentation and I'd like to have some more info on c# bindings.

I'd like to know if they will be shipped with final Opencv 3.0 release or not. It would be also interesting to know if it will be a simple wrapper or more object oriented following the approach proposed by EmguCV.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
6

answered 2013-08-15 02:54:32 -0600

Kirill Kornyakov gravatar image

updated 2013-08-15 23:59:33 -0600

Unfortunately we don't have plans to release C# support in the 3.0 release, because nobody is working on it. So, you should probably continue to use EmguCV. It is not an "official" wrapper, but it seems that it is stable enough, and it provides good support.

And here is some more information about the C# support in OpenCV. There was an attempt to enable the use of OpenCV from Mono/.NET, see https://github.com/Itseez/opencv/pull/604 . This wasn't yet merged, since it needs some improvements, but guys may finish it by the 3.0 release. It is not exactly what is asked, but it actually allows you to call OpenCV from C#.

And I think that we'll have "simple wrapper", simply because we don't want to have/maintain two versions of API. All OpenCV wrappers are autogenerated from the C++ one, and this is good.

  1. It allows to have always up-to-date wrappers for free, without any manual work. Somebody adds new C++ class of function, and it is immediately available in all languages.
  2. API is similar between languages, so you can switch easily between projects.

Of course in some languages [almost] everything is a class, like in Java or C#. And yes, in Java we have Core and Imgproc classes, that encapsulate free functions. We'll have something like that in C#. But we will not design a separate hierarchy of classes for every language, otherwise it will be impossible to maintain (keep aligned with evolving default C++ API).

Finally, OpenCV itself will become more object-oriented (in some sense). You're probably familiar with the cv::Algorithm concept, and all the new functionality will likely be organized this way. The library will remain flat, no deep nested namespaces and complicated class hierarchies, but all high-level algorithms will be classes. We hope that such design will simplify the library usage, and it will be reflected in the wrappers.

edit flag offensive delete link more

Comments

@Kirill Kornyakov: link not working for the pull request :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-15 04:18:48 -0600 )edit
1

Thanks a lot Kirill for your detailed explanation. As you underline, latest opencv c++ api is really more OO, so it makes sense to simply wrap it. EmguCV is really good but one of its major issues is licensing. I agree with you on your performance concerns about using IKVM + JNI calls. It' just an idea but maybe the best strategy could be the one defined by sharpdx, i.e create a tool to autogenerate wrapper from opencv headers.

Luca Del Tongo gravatar imageLuca Del Tongo ( 2013-08-15 16:41:17 -0600 )edit

Actually we have such tool =) Here it is for Python, and here is for Java. Hopefully we'll have such for MATLAB soon. So, we just need somebody to extend the same approach for C# and all other languages! It shouldn't take much, may be 3-4 months of fulltime work ;-)

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2013-08-16 00:05:33 -0600 )edit
1

Maybe it could be an interesting project to insert into gsoc2014 :-)

Luca Del Tongo gravatar imageLuca Del Tongo ( 2013-08-16 04:37:38 -0600 )edit

Just want to add that I use EmguCV at work and the Library is very well done and things that need like 15 LOC in normal OpenCV can take 2 or 3 LOC. Unfortunately, some very low level task with pointers can't be made that easy. The licensing is only 400$ for a commercial application which is close to nothing if you are planning to sell your stuff. If it's for anything else, it's free. I would highly suggest EmguCV for anyone used to .NET and who want to use the power of OpenCV without the headache of C or C++. I agree that an automatic wrapper would be great, but even if it's done, wrapper like EmguCV will still have their place because the Library is written for .NET coders.

Jean-François Côté gravatar imageJean-François Côté ( 2013-08-22 14:24:08 -0600 )edit
1

@Jean-Francois Thanks a lot for your comment. I agree with you, I developed more than one year ago my master thesis using Emgu (and some youtube tutorials) and it's the best wrapper for .NET developers. I see only some potential issues: 1) only one developer 2) Being an hand made wrapper this can introduce another layer of bugs 3) it's not always up to date with opencv, especially lately with new opencv development cycle

Luca Del Tongo gravatar imageLuca Del Tongo ( 2013-08-24 09:41:08 -0600 )edit

Yeah, EmguCV definitly need new blood in the development process but right now the current version is very stable and I know he's working on a new version.

Jean-François Côté gravatar imageJean-François Côté ( 2013-08-26 05:48:12 -0600 )edit
2

answered 2013-08-22 10:23:53 -0600

glopes gravatar image

updated 2013-09-02 17:46:05 -0600

I'm planning to release an updated C# interface to OpenCV 2.4.6 through NuGet over the next couple of days. These bindings were developed over the course of a year and include many features that I've missed from other attempts, namely:

  • Very close to 100% support of the latest C API (including undocumented functions)
  • Full documentation/intellisense for all supported methods, classes and enum members (arduously mined from many different sources)
  • Support for exceptions
  • Garbage-collector friendly:
    • GC is aware of the actual memory used by matrices and images
    • Pointers are guaranteed to survive function calls even if concurrent garbage collection happens
  • Object model following C++ API as much as possible (towards future increased support of C++ API)
  • BSD-style license (MIT)

I was very surprised by the decision to drop the C API, since it is still the easiest way for interoping with many high-level languages. I guess I could move my wrapper to use C++/CLI to get over this but I would then be limited to Windows-only support.

I'm very interested to follow up on efforts to do automatic generation of the C-interface. In fact, I may be even interested to contribute to it actively and push for an official C# wrapper built on top of it, if someone points me to how this was done for the other language bindings.

I was planning on doing this for my own C# interface anyway but if no one is currently working on it, I'm happy to hand you over the results.

I'll post here when I pre-release the CTP in NuGet if anyone wants to give it a try and help with the bug-hunt (although the unit test code base is growing). I'm versioning the bindings independently of OpenCV for now since the code was hand-written and it may be subject to independent changes. First pre-release will most likely be 2.5-ctp.

UPDATE: Just pushed a prerelease version of the wrapper on NuGet. Feel free to give it a try, will write a proper post when it's further along in testing.

edit flag offensive delete link more

Comments

1

Great news from you !!!! Maybe the best thing for the whole community would be to join your effort into pull request for C# automatic wrapper https://github.com/Itseez/opencv/pull/604

Luca Del Tongo gravatar imageLuca Del Tongo ( 2013-08-24 09:53:15 -0600 )edit

See above. Ended up taking a bit longer than expected, but here it is. I agree that an automatic C# wrapper would be ideal, although it's hard to automatize some of the design decisions that will really give it the .NET flavor. An automatic C interface generator would be a great first step, though.

glopes gravatar imageglopes ( 2013-09-02 17:51:25 -0600 )edit

I take a look at your wrapper and made a simple toy example with it and it works fine. The additional benefit of your wrapper and the only thing that seems more difficult to automate is GC management, other than that it seems possible to create a generator that produce an output similar to yours.

Luca Del Tongo gravatar imageLuca Del Tongo ( 2013-09-04 04:25:42 -0600 )edit

Hi,

Do you need OpenCV installed already to utilise these wrapper?

Also, What is the status of the Machine learning, Contrib and Features2D modules? I couldn't find their namespace?

MRDaniel gravatar imageMRDaniel ( 2013-09-15 23:07:14 -0600 )edit

Right now you need to copy the DLLs to the project output folder yourself so that the wrapper will run. That should be about it. I'm actually working right now on making a NuGet package that will even do this for you. Hopefully it will be up soon (stay tuned).

glopes gravatar imageglopes ( 2013-09-18 07:12:52 -0600 )edit

Just want to say, I used the interface in a commercial kinect based application, it was pretty painless super light weight awesome license and easy to use. (the wrapper plus the opencv dll's increased the final msi by only ~3 mbs, major win:) The code was compact well written and easy to grok which meant if in the future I found a feature was missing I would be able to fix it and further contribute to the project. I looked at emguCV, cvsharp etc and they all looked a bit bloated had less friendly licenses and more importantly did not just work the first time I wacked them into my project.

philliproso gravatar imagephilliproso ( 2013-11-09 07:14:03 -0600 )edit

I got the NuGet package, but I'm not sure how to start using it. Is there any tutorial or sample code for C#? Thanks!

jmmroldan gravatar imagejmmroldan ( 2014-11-12 04:41:10 -0600 )edit

Question Tools

Stats

Asked: 2013-08-14 10:05:48 -0600

Seen: 7,784 times

Last updated: Sep 02 '13