I have developed a c++ program which uses OpenCV. Now i want to develop a windows form based application in C#. As C# can only handle managed code it is nearly impossible to run OpenCV directly on C# application. I have searched for different ways to create C# application using OpenCV, one of which is EmguCV and the other method that i am much more interested in is importing the c++ .dll file in C# application and calling the unmanaged functions this way.
I started by creating simple functions in c++ and i was able to use cout
and cin
in my C# application by importing the dll. The problem comes when i try to include OpenCV header files in my c++ application and when i compile i get this error
error LNK1104: cannot open file 'tbb_debug.lib'
Some one has done this before but i cant figure out how he interface c++ with C# in Displaying webcam feed in cv::Mat format in a picturebox
The Question is that i have function which takes in a cv::Mat variable and performs some image processing on it and returns the processed matrix. i want to use that function written in c++ in my C# application. but the problem is that i am unable to create the dll when i include OpenCV library in c++.
So please Don't Suggest me to use EmguCV or any other .NET wrappers for OpenCV.
i am using Visual Studio 2010 for my Project.
OpenCV is a popular Computer Vision library to develop applications built using C++ and C. It has several uses like Object Detection and Video Processing. Computer Vision overlaps with fields like Image Processing, Photogrammetry, and Pattern Recognition. A popular wrapper Emgu CV is used to run OpenCV using C#.
cv2 (old interface in old OpenCV versions was named as cv ) is the name that OpenCV developers chose when they created the binding generators. This is kept as the import name to be consistent with different kind of tutorials around the internet.
OpenCV [OpenCV] is an open source (see http://opensource.org) computer vision library available from http://SourceForge.net/projects/opencvlibrary. The library is written in C and C++ and runs under Linux, Windows and Mac OS X. There is active development on interfaces for Python, Ruby, Matlab, and other languages.
This module covers various image processing operations such as image filtering, geometrical image transformations, color space conversion, histograms, etc. In the Java library of OpenCV, this module is included as a package with the name org. opencv.
I would explicitly export methods that wrap your entry points in a C++ header, and then use P/Invoke to reference them:
extern "C" __declspec(dllexport) BOOL DoSomething();
Then consume them in the C#:
[DllImport("MyOpenCVWrapper.dll")]
private static extern bool DoSomething();
I wouldn't try to reference the OpenCV headers.
Although it might not be what you're looking for, I did that task with C++/CLI and exposed it through an assembly. It was straight forward and worked pretty well. Blog article here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With