This example requires Emgu CV 1.5.0.0 and up
We will start by the Hello World sample, written in C#
Click to view source code
Click to view source code
The above code will create an image of 400x200 with blue background color and the text "Hello, world" in green on the foreground. The image will be displayed a window named "Test Window".
Showing image using cvNamedWindow is good, but Emgu CV has an event better tool for the same purpose, that is, the ImageViewer class under Emgu.CV.UI namespace.
Click to view source code
using Emgu.CV;using Emgu.CV.CvEnum;using Emgu.CV.Structure;using Emgu.CV.UI;using System.Drawing;...//Create a 3 channel image of 400x200using (Mat img = new Mat(200, 400, DepthType.Cv8U, 3)) { img.SetTo(new Bgr(255, 0, 0).MCvScalar); // set it to Blue color //Draw "Hello, world." on the image using the specific font CvInvoke.PutText( img, "Hello, world", new System.Drawing.Point(10, 80), FontFace.HersheyComplex, 1.0, new Bgr(0, 255, 0).MCvScalar); //Show the image using ImageViewer from Emgu.CV.UI ImageViewer.Show(img, "Test Window");}
Click to view source code
联系客服