DirectCVThe main goal of this project is to provide a small lightweight layer over Intel's OpenCV image processing library. Using this wrapper you can easily access a lot of OpenCV functions in .NET 2.0 environment.
The development started in february 2008 because I had to use OpenCV from C#
... [More]
for our project at the Budapest Tech. I looked around on the Internet looking for OpenCV wrappers but there were a large set of functions what I coundn't find in any of these. Finally I decided to write my own simple OpenCV wrapper in which all these necessary functions are available.
The "direct" word in the project's name means that the wrapper allows you to call OpenCV functions directly. The names of the functions are almost the same as in the original OpenCV library. For example there is a function called cvLoadImage() in OpenCV. You can call this function throught DirectCV by calling the CV.LoadImage() static method. As you can see all the supported methods can be found in the CV static class. The parameters of the functions are the same as in OpenCV but since the methods can't take pointer parameters or can't return a pointer there are some differences. Generally the pointers are replaced with IntPtr type, with arrays, or with out/ref parameters.
Note that the only purpose of DirectCV is to provide access to the basic OpenCV functions and therefore it doesn't always follow object oriented approaches. The main goal is to be as similar as possible with the original C OpenCV library. The benefit of this is that if you are familiar with the OpenCV, you can learn how to use DirectCV in no time and you can use the OpenCV documentation as reference.
DirectCV is written entirely in C# and uses mashalling, P/Invoke, and interop services to provide access to the OpenCV functions.
Almost every static method of the CV class is documented based on the OpenCV documentation so the IntelliSense can show some very useful information for you automatically. The wrapper also supports default parameters.
Many OpenCV function takes an integer parameter what describes how to execute the operation. In C language you would pass some predefined constant value for these parameters. Unfortunately this requires you to know what kind of constants are valid for a given function. To make things easier I created a large collection of enums to replace these constants. This way it's much harder to pass wrong values to a given function and the code will be much easier to read.
For example a DirectCV 'hello world' program looks like this:
static void Main(string[] args)
{
// Create a new window with the given name.
CV.NamedWindow("DemoWindow");
// Load an image.
IntPtr imagePtr = CV.LoadImage("SampleImage.jpg", CvLoadImage.Color);
// Show the loaded image
CV.ShowImage("DemoWindow", imagePtr);
// Wait for keypress.
CV.WaitKey();
// Finally we have to release the image and destroy the window.
CV.ReleaseImage(ref imagePtr);
CV.DestroyWindow("DemoWindow");
}If you find this wrapper useful:
please refer to the following article:
Nagy, A., Vámossy, Z., „OpenCV C# Wrapper-based Video Enhancement Using Different Optical Flow Methods in the Super-resolution”, in proc. 6th International Symposium on Intelligent Systems and Informatics, Subotica, Serbia, 2008, CD issue, IEEE C. N. CFP0884C-CDR or in the credits of your program a mention to "Attila Nagy's DirectCV" would be appreciated. [Less]