人脸识别Emgucv (二)
创建自己的的第一个项目“Hello World”
创建一个控制台程序
添加引用 : Emgu.CV.World.dll;
在 安装Emgucv的文件夹 bin 目录寻找
贴上代码
1 using System; 2 using Emgu.CV; 3 using Emgu.CV.CvEnum; 4 using Emgu.CV.Structure; 5 6 namespace HelloWorld 7 { 8 class Program 9 { 10 static void Main(string[] args) 11 { 12 string win1 = "Test Window"; //The name of the window 13 CvInvoke.NamedWindow(win1); //Create the window using the specific name 创建一个窗口并使用此名称 14 15 Mat img = new Mat(200, 400, DepthType.Cv8U, 3); //Create a 3 channel image of 400x200 创建一个200x400的窗口 16 img.SetTo(new Bgr(255, 0, 0).MCvScalar); // set it to Blue color 设置为蓝色 17 18 //Draw "Hello, world." on the image using the specific font 用特定的字体绘制“Hello, world”的图片 19 CvInvoke.PutText( 20 img, 21 "Hello, world", 22 new System.Drawing.Point(10, 80), 23 FontFace.HersheyComplex, 24 1.0, 25 new Bgr(0, 255, 0).MCvScalar); 26 27 28 CvInvoke.Imshow(win1, img); //Show the image 展示图片 29 CvInvoke.WaitKey(0); //Wait for the key pressing event 等待事件 30 CvInvoke.DestroyWindow(win1); //Destroy the window if key is pressed 有按键按下销毁窗口! 31 } 32 } 33 }
OK 第一个demo 完成 ,来让我们运行下看下效果