• 大小: 2.08MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-08
  • 语言: C#
  • 标签: emgu  人脸  识别  

资源简介

通过摄像头进行视频抓取,识别人脸、人眼,并自动保存成图片。 1.需要自行安装emgu的库,并设置好path,可官网下载 2.需要自行准备好摄像头并安装好驱动 3.需要vs2012或者SharpDevelop进行编译,bin下已有编译好的exe 官网例子,参考官网和一些资料,代码比较简单。大家也仅供参考。

资源截图

代码片段和文件信息

//----------------------------------------------------------------------------
//  Copyright (C) 2004-2012 by EMGU. All rights reserved.       
//----------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.GPU;

namespace emguDemo
{
   public static class DetectFace
   {
      public static void Detect(Image image String faceFileName String eyeFileName List faces List eyes out long detectionTime)
      {
         Stopwatch watch;

         if (GpuInvoke.HasCuda)
         {
            using (GpuCascadeClassifier face = new GpuCascadeClassifier(faceFileName))
            using (GpuCascadeClassifier eye = new GpuCascadeClassifier(eyeFileName))
            {
               watch = Stopwatch.StartNew();
               using (GpuImage gpuImage = new GpuImage(image))
               using (GpuImage gpuGray = gpuImage.Convert())
               {
                  Rectangle[] faceRegion = face.DetectMultiScale(gpuGray 1.1 10 Size.Empty);
                  faces.AddRange(faceRegion);
                  foreach (Rectangle f in faceRegion)
                  {
                     using (GpuImage faceImg = gpuGray.GetSubRect(f))
                     {
                        //For some reason a clone is required.
                        //Might be a bug of GpuCascadeClassifier in opencv
//                        using (GpuImage clone = faceImg.Clone())
//                        {
//                           Rectangle[] eyeRegion = eye.DetectMultiScale(clone 1.1 10 Size.Empty);
//
//                           foreach (Rectangle e in eyeRegion)
//                           {
//                              Rectangle eyeRect = e;
//                              eyeRect.Offset(f.X f.Y);
//                              eyes.Add(eyeRect);
//                           }
//                        }
                     }
                  }
               }
               watch.Stop();
            }
         }
         else
         {
            //Read the HaarCascade objects
            using (CascadeClassifier face = new CascadeClassifier(faceFileName))
            using (CascadeClassifier eye = new CascadeClassifier(eyeFileName))
            {
               watch = Stopwatch.StartNew();
               using (Image gray = image.Convert()) //Convert it to Grayscale
               {
                  //normalizes brightness and increases contrast of the image
                  gray._EqualizeHist();

                  //Detect the faces  from the gray scale image and store the locations as rectangle
                  //The first dimensional is the channel
                  //The second dimension is

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-07 14:09  emguDemo\
     目录           0  2014-04-08 17:34  emguDemo\emguDemo\
     文件         942  2014-04-07 14:09  emguDemo\emguDemo.sln
     文件       51712  2014-04-07 22:00  emguDemo\emguDemo.v11.suo
     文件         167  2014-04-07 15:06  emguDemo\emguDemo\App.config
     目录           0  2014-04-07 17:47  emguDemo\emguDemo\bin\
     目录           0  2014-04-08 17:33  emguDemo\emguDemo\bin\Debug\
     文件      294912  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.dll
     文件       49152  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.GPU.dll
     文件      147862  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.GPU.xml
     文件       36864  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.ML.dll
     文件      133267  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.ML.xml
     文件      126976  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.UI.dll
     文件       35149  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.UI.xml
     文件     1185017  2012-08-20 13:49  emguDemo\emguDemo\bin\Debug\Emgu.CV.xml
     文件       32768  2012-08-20 12:41  emguDemo\emguDemo\bin\Debug\Emgu.Util.dll
     文件       22236  2012-08-20 12:41  emguDemo\emguDemo\bin\Debug\Emgu.Util.xml
     文件       12800  2014-04-07 17:41  emguDemo\emguDemo\bin\Debug\emguDemo.exe
     文件         167  2014-04-07 15:06  emguDemo\emguDemo\bin\Debug\emguDemo.exe.config
     文件       34304  2014-04-07 17:41  emguDemo\emguDemo\bin\Debug\emguDemo.pdb
     文件       22472  2014-04-07 17:47  emguDemo\emguDemo\bin\Debug\emguDemo.vshost.exe
     文件         167  2014-04-07 15:06  emguDemo\emguDemo\bin\Debug\emguDemo.vshost.exe.config
     文件         490  2012-06-06 02:06  emguDemo\emguDemo\bin\Debug\emguDemo.vshost.exe.manifest
     文件      521766  2012-07-25 11:57  emguDemo\emguDemo\bin\Debug\haarcascade_eye.xml
     文件     1290445  2012-07-25 11:57  emguDemo\emguDemo\bin\Debug\haarcascade_frontalface_default.xml
     文件       91814  2012-07-25 11:44  emguDemo\emguDemo\bin\Debug\lena.jpg
     文件      307200  2012-07-25 11:44  emguDemo\emguDemo\bin\Debug\ZedGraph.dll
     文件     1492968  2012-07-25 11:44  emguDemo\emguDemo\bin\Debug\ZedGraph.xml
     目录           0  2014-04-08 16:31  emguDemo\emguDemo\bin\Debug\zh-CN\
     文件        4096  2012-07-25 11:44  emguDemo\emguDemo\bin\Debug\zh-CN\ZedGraph.resources.dll
     目录           0  2014-04-09 17:49  emguDemo\emguDemo\bin\Release\
............此处省略67个文件信息

评论

共有 条评论