A few days ago, I started to play around with Computer Vision and I found OpenCV Library would help me much in building a computer vision application. Then I found that OpenCV using C languange, which the current me already forgot C much. Then I search for OpenCV wrapper for C#, since I would work extensively in C#, finally I found EmguCV.

Emgu CV is a cross platform .Net wrapper to the Intel OpenCV image processing library. Allowing OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled in Mono and run on Linux / Mac OS X.

Now, directly to the code.

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using System.Drawing;

class HelloWorld
{
	static void Main()
	{
		string win1 = "Test Window";

		CvInvoke.cvNamedWindow(win1);

		using (Image img = new Image(400, 200, new Bgr(125, 125, 125)))
		{
		   MCvFont f = new MCvFont(FONT.CV_FONT_HERSHEY_SIMPLEX, 2.0, 2.0);
		   img.Draw("Hello, world", ref f, new Point(10, 80), new Bgr(30, 30, 30));

		   CvInvoke.cvShowImage(win1, img.Ptr);

		   CvInvoke.cvWaitKey(0);

		   CvInvoke.cvDestroyWindow(win1);
		}
	}

}

Result:

I would love to write more about OpenCV/EmguCV and Computer Vision related stuff to my post. :) Enjoy

Leave a Comment