• 大小: 4.01MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-17
  • 语言: C#
  • 标签: adaboost  emgu  人脸检测  C#  

资源简介

编写的C# win form程序,实现了调用emgucv库通过adaboost算法进行人脸和眼睛的检测,使用的正面人脸分类器。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;

namespace FaceDetectTest
{
    public partial class Form1 : Form
    {
        private Capture capture;
        private HaarCascade haar_face;
        private HaarCascade haar_eye;
        public Form1()
        {
            InitializeComponent();
        }

        private void tick(object sender EventArgs e)
        {
            using (Image image = capture.Queryframe())
            {
                if (image != null)
                {
                    using (haar_face = new HaarCascade(@“C:\opencv\data\haarcascades\haarcascade_frontalface_alt2.xml“))
                    using (haar_eye = new HaarCascade(@“C:\Emgu\emgucv-windows-x86 2.3.0.1416\opencv\data\haarcascades\haarcascade_eye.xml“))
                    {
                        using (Image gray = image.Convert()) //Convert it to Grayscale
                        {
                            //normalizes brightness and increases contrast of the image
                            gray._EqualizeHist();
                            MCvAvgComp[] facesDetected = haar_face.Detect(gray1.110Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING new Size(20 20));

                            foreach (MCvAvgComp f in facesDetected)
                            {
                                //draw the face detected in the 0th (gray) channel with blue color
                                image.Draw(f.rect new Bgr(Color.Blue) 2);

                                //Set the region of interest on the faces
                                gray.ROI = f.rect;
                                MCvAvgComp[] eyesDetected = haar_eye.Detect(
                                   gray
                                   1.1
                                   10
                                   Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING
                                   new Size(20 20));
                                gray.ROI = Rectangle.Empty;

                                foreach (MCvAvgComp eye in eyesDetected)
                                {
                                   Rectangle eyeRect = eye.rect;
                                   eyeRect.Offset(f.rect.X f.rect.Y);
                                   image.Draw(eyeRect new Bgr(Color.Red) 2);
                                }
                                
                                //
                            }
                            pictureBox1.Image = image.ToBitmap();
                        }
                    }
                }
            }
        }

        private void button1_Click(object sender EventArgs e)
        {
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1950720  2012-04-10 10:43  FaceDetectTest\FaceDetectTest\bin\Debug\cvextern.dll

     文件     279552  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.dll

     文件      29184  2012-04-06 14:06  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.GPU.dll

     文件      67072  2012-04-06 14:06  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.GPU.pdb

     文件     104310  2012-04-06 14:06  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.GPU.xml

     文件     792064  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.pdb

     文件     113152  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.UI.dll

     文件     136704  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.UI.pdb

     文件      35149  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.UI.xml

     文件    1094587  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.CV.xml

     文件      23040  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.Util.dll

     文件      54784  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.Util.pdb

     文件      21208  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\Emgu.Util.xml

     文件      10240  2012-06-04 17:01  FaceDetectTest\FaceDetectTest\bin\Debug\FaceDetectTest.exe

     文件      34304  2012-06-04 17:01  FaceDetectTest\FaceDetectTest\bin\Debug\FaceDetectTest.pdb

     文件      11600  2012-06-04 17:00  FaceDetectTest\FaceDetectTest\bin\Debug\FaceDetectTest.vshost.exe

     文件        490  2010-03-17 22:39  FaceDetectTest\FaceDetectTest\bin\Debug\FaceDetectTest.vshost.exe.manifest

     文件    1715200  2012-04-10 10:46  FaceDetectTest\FaceDetectTest\bin\Debug\opencv_core231.dll

     文件    1629696  2012-04-10 10:46  FaceDetectTest\FaceDetectTest\bin\Debug\opencv_imgproc231.dll

     文件     307200  2010-05-26 11:12  FaceDetectTest\FaceDetectTest\bin\Debug\ZedGraph.dll

     文件    1492968  2010-05-26 11:12  FaceDetectTest\FaceDetectTest\bin\Debug\ZedGraph.xml

     文件      10240  2012-04-06 14:05  FaceDetectTest\FaceDetectTest\bin\Debug\zh-CN\Emgu.CV.UI.resources.dll

     文件       4096  2010-05-26 11:12  FaceDetectTest\FaceDetectTest\bin\Debug\zh-CN\ZedGraph.resources.dll

     文件      11600  2012-04-10 10:48  FaceDetectTest\FaceDetectTest\bin\Release\FaceDetectTest.vshost.exe

     文件        490  2010-03-17 22:39  FaceDetectTest\FaceDetectTest\bin\Release\FaceDetectTest.vshost.exe.manifest

     文件    1950720  2012-04-10 10:43  FaceDetectTest\FaceDetectTest\cvextern.dll

     文件       4684  2012-04-10 10:46  FaceDetectTest\FaceDetectTest\FaceDetectTest.csproj

     文件       3248  2012-04-07 23:00  FaceDetectTest\FaceDetectTest\Form1.cs

     文件       3079  2012-04-07 22:14  FaceDetectTest\FaceDetectTest\Form1.Designer.cs

     文件       6011  2012-04-07 22:14  FaceDetectTest\FaceDetectTest\Form1.resx

............此处省略45个文件信息

评论

共有 条评论