• 大小: 530KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-21
  • 语言: C#
  • 标签: C#  人脸识别  

资源简介

用C#做学习型人脸识别程序(尝鲜版)DEMO和源码

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using System.IO;

namespace FaceRecognition
{
    /***************
     * face recognition
     * by Nobi (conmajia@gmail.com)
     * May 11th 2012
     * this is an experiment
     * and based on EmguCV
     * all codes are almost standard.
     * 
     * Sergio Andrés Guitérrez Rojas‘s work
     * was the start point.
     * More features added. 
     * -- conmajia
     *  
     * use it in anyway as you wish.
     * you can keep my name or not.
     * it depends on you.
     * all that I expect is a nice meal. (haha)
     * **************/
    public partial class Form1 : Form
    {
        #region variables
        // webcam
        Capture webcam;
        bool cameraInUse = false;

        // cascading lib
        HaarCascade faceHaar;

        // Font to show name
        MCvFont font = new MCvFont(
            Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_TRIPLEX
            1.2
            1.2
            );

        // frame being dealing dealed trained
        Image current;
        Image gray = null;

        // List to store trained faces & people
        List> learnedFaces = new List>();
        List learnedPeople = new List();

        MCvAvgComp[] foundFaces;

        #endregion

        #region initiates
        public Form1()
        {
            InitializeComponent();
        }

        private void initHaar(ref HaarCascade h string path)
        {
            h = new HaarCascade(path);
        }

        // try load early trained faces
        private void loadBackupImages(List> list)
        {
            //try
            //{
            //    // names stored in /backup/names.txt
            //    // names delimilited by ‘|‘ (the pipe)
            //    string nameFileContent
            //        = File.ReadAllText(Application.StartupPath + “/backup/names.txt“);
            //    string[] names = nameFileContent.Split(‘|‘);

            //    foreach (string name in names)
            //    {
            //        // load images
            //        list.Add(
            //            new Image
            //                Application.StartupPath
            //                + “/backup/face_“
            //                + name
            //                + “.bmp“
            //                )
            //            );
            //        // TODO: change list into dictionary
            //        people.Add(name);
            //    }
            //}
            //catch (Exception)
            //{
            //    Console.WriteLine(“Load nothing from backup files.“);
            //}
        }
        #endregio

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       10332  2012-05-11 22:05  Form1.Designer.cs
     文件       10652  2012-05-11 22:13  Form1.cs
     文件      506314  2012-05-11 18:15  haarcascade_eye.xml
     文件     3644763  2012-05-11 18:15  haarcascade_frontalface_alt_tree.xml
     文件       32768  2012-05-11 22:13  FaceRecognition.exe

评论

共有 条评论