Ask Your Question
0

Creating a wrapper for C# and converting Bitmap

asked 2014-03-02 13:38:40 -0600

Stephen85 gravatar image

updated 2014-04-30 02:19:38 -0600

berak gravatar image

I have some questions about using OpenCV C++ code in C#... I have created my C++ console application which is used for the image analysis, then created a C++/CLI class library which should work as a wrapper for the OpenCV code. The main issue I'm having is converting a Bitmap received from C# to Mat, I have no idea how to do it. Can anyone point me in the right direction when it comes to the conversion and wrapping? This is the tutorial I'm using for creating the wrapper http://drthitirat.wordpress.com/2013/06/06/use-opencv-c-codes-in-a-vc-project-solution-of-creating-a-managed-clr-wrapper/

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-03-02 14:01:10 -0600

Why don't you use Emgu CV? It is a true C# wrapper for OpenCV and also has a free license. Or may be you should give the opencvsharp a try?

edit flag offensive delete link more

Comments

No, it has to be C++ code...

Stephen85 gravatar imageStephen85 ( 2014-03-02 14:04:24 -0600 )edit

Sorry, so what do you want exactly? A C++ wrapper for C#, and with OpenCV?

tuannhtn gravatar imagetuannhtn ( 2014-03-02 14:10:44 -0600 )edit

I wrote my image processing code in C++ and now i want to use it in a C# project. From the link above I have learned that I can do it by creating a managed wrapper in C++/CLI. I want to know is there any other way and how can i convert Bitmaps from c# to Mat so i can use it in C++.

Stephen85 gravatar imageStephen85 ( 2014-03-02 16:19:22 -0600 )edit

In fact, C# related problems are not really involved to this forum (see more at FAQ-http://answers.opencv.org/faq/), but now I understand that you have two requirements: use your C++ IP code in a C# project and convert a Bitmaps from C# to Mat to handle it by C++. Both of those can be solved simply by using a true C# wrapper since your IP code calls functions from OpenCV, you can call them with C# code and do not need to convert a Bitmap from C# to Mat (and with C++ again). That why I suggest you to use Emgu CV. And if the reason for your C# usage is the GUI only, you can choose QT or even MFC and forget the C# code, as well as C# Bitmap to C++ Mat conversion.

tuannhtn gravatar imagetuannhtn ( 2014-03-02 16:38:43 -0600 )edit

I don't want to use Emgu CV because I want my IP code to be platform independent. I'm not too familiar with C++ and started learning it only recently, I know it enough to write my IP code. GUI is one of the reasons as well as serial port communication my app has to have, I'm not quite sure how to do it in C++. Thanks for the advice.

Stephen85 gravatar imageStephen85 ( 2014-03-02 16:53:57 -0600 )edit
-1

answered 2017-12-11 07:23:55 -0600

hosjiu gravatar image

This link will solve your problem:

http://milindapro.blogspot.com/2015/0...

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-02 13:38:40 -0600

Seen: 5,326 times

Last updated: Dec 11 '17