資源簡介
利用Emgu.CV實現人臉識別詳解 (C#)--附源碼,一、準備工作
1、 攝像頭。
文章地址:http://blog.csdn.net/u011616825/article/details/51620061
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?Emgu.CV;
using?Emgu.CV.CvEnum;
using?Emgu.CV.Structure;
using?Emgu.Util;
using?Emgu.CV.Cuda;
using?System.Diagnostics;
using?Emgu.CV.UI;
using?System.IO;
namespace?門禁識別
{
????public?partial?class?faceDetect?:?Form
????{
????????Mat?matImg;//攝像頭圖像
????????Capture?capture;//攝像頭對象
????????Util.KingFaceDetect?kfd;
????????public?faceDetect()
????????{
????????????InitializeComponent();
????????????CvInvoke.UseOpenCL?=?false;
????????????kfd?=?new?Util.KingFaceDetect();
????????????try
????????????{
????????????????capture?=?new?Capture();
????????????????capture.Start();//攝像頭開始工作
????????????????capture.ImageGrabbed?+=?frameProcess;//實時獲取圖像
????????????}
????????????catch?(NullReferenceException?excpt)
????????????{
????????????????MessageBox.Show(excpt.Message);
????????????}
????????}
????????
????????private?void?Form2_Load(object?sender?EventArgs?e)
????????{
????????????
????????}
????????private?void?frameProcess(object?sender?EventArgs?arg)
????????{
????????????matImg?=?new?Mat();
????????????capture.Retrieve(matImg?0);
????????????picShow.Image?=?matImg.Bitmap;
????????}
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????markFaces();//100毫秒檢測一次人臉
????????}
????????private?void?markFaces()
????????{
????????????try
????????????{
????????????????picShow.Image?=?kfd.faceRecognize(capture.Queryframe()).originalImg.Bitmap;
????????????}
????????????catch
????????????{
????????????}
????????}
????????private?void?獲取樣本圖片_Click(object?sender?EventArgs?e)
????????{
????????????if?(fullname.Text?==?““)
????????????{
????????????????MessageBox.Show(“請輸入樣本姓名。“);
????????????}
????????????else
????????????{
????????????????string?filePath?=?Application.StartupPath?+?“/trainedFaces/“?+?fullname.Text?+?“_“?+?System.Guid.NewGuid().ToString()?+?“.jpg“;
????????????????sampleBox.Image.Save(filePath);
????????????????MessageBox.Show(“樣本保存完畢。“);
????????????}
????????}
????????int?currentFaceFlag?=?0;
????????Util.KingFaceDetect.faceDetectedObj?currentfdo;//點擊鼠標時的人臉檢測對象
????????private?void?sampleBox_Click(object?sender?EventArgs?e)
????????{
????????????currentfdo?=?kfd.GetFaceRectangle(capture.Queryframe());
????????????currentFaceFlag?=?0;
????????????getCurrentFaceSample(0);
????????}
????????private?void?getCurrentFaceSample(int?i)
????????{
????????????try
????????????{
????????????????fullname.Text?=?““;
????????????????Image?result?=?currentfdo.originalImg.ToImage().Copy(currentfdo.facesRectangle[i]).Resize(100?100?Emgu.CV.CvEnum.Inter.Cubic);
????????????????result._EqualizeHist();//灰度直方圖均衡化
????????????????sampleBox.Image?=?result.Bitmap;
????????????}
????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-02-01?10:47??門禁識別\
?????目錄???????????0??2018-02-01?10:46??門禁識別\門禁識別\
?????文件????????1137??2016-06-09?10:51??門禁識別\門禁識別\App.config
?????文件?????????529??2016-06-09?00:40??門禁識別\門禁識別\Program.cs
?????目錄???????????0??2016-06-09?10:54??門禁識別\門禁識別\Properties\
?????文件????????1402??2016-06-09?10:54??門禁識別\門禁識別\Properties\AssemblyInfo.cs
?????文件????????2876??2016-06-04?23:17??門禁識別\門禁識別\Properties\Resources.Designer.cs
?????文件????????5612??2016-06-04?23:17??門禁識別\門禁識別\Properties\Resources.resx
?????文件????????1099??2016-06-04?23:17??門禁識別\門禁識別\Properties\Settings.Designer.cs
?????文件?????????249??2016-06-04?23:17??門禁識別\門禁識別\Properties\Settings.settings
?????目錄???????????0??2016-06-09?10:56??門禁識別\門禁識別\Util\
?????文件????????6851??2016-06-09?10:56??門禁識別\門禁識別\Util\KingFaceDetect.cs
?????文件????????1387??2016-06-06?20:39??門禁識別\門禁識別\Util\TTS.cs
?????目錄???????????0??2016-06-05?00:55??門禁識別\門禁識別\bin\
?????目錄???????????0??2018-02-01?10:43??門禁識別\門禁識別\bin\Debug\
?????文件??????117760??2016-02-05?02:19??門禁識別\門禁識別\bin\Debug\Emgu.CV.UI.dll
?????文件???????34738??2016-02-05?02:19??門禁識別\門禁識別\bin\Debug\Emgu.CV.UI.xm
?????文件??????508416??2016-02-05?02:19??門禁識別\門禁識別\bin\Debug\Emgu.CV.World.dll
?????文件?????1377392??2016-02-05?02:19??門禁識別\門禁識別\bin\Debug\Emgu.CV.World.xm
?????文件??????188416??2007-09-07?23:48??門禁識別\門禁識別\bin\Debug\ICSharpCode.SharpZipLib.dll
?????文件???????70656??2016-06-09?10:56??門禁識別\門禁識別\bin\Debug\King.dll
?????文件??????112128??2016-06-09?10:56??門禁識別\門禁識別\bin\Debug\King.pdb
?????文件??????391168??2015-04-13?09:51??門禁識別\門禁識別\bin\Debug\NAudio.dll
?????文件?????1443840??2012-05-03?22:24??門禁識別\門禁識別\bin\Debug\NPOI.dll
?????文件??????307200??2016-01-12?03:14??門禁識別\門禁識別\bin\Debug\ZedGraph.dll
?????文件?????1492968??2016-01-12?03:14??門禁識別\門禁識別\bin\Debug\ZedGraph.xm
?????文件??????341406??2016-01-12?03:16??門禁識別\門禁識別\bin\Debug\haarcascade_eye.xm
?????文件??????930127??2016-01-12?03:16??門禁識別\門禁識別\bin\Debug\haarcascade_frontalface_default.xm
?????文件???????82944??2016-06-09?10:56??門禁識別\門禁識別\bin\Debug\iFlyDotNet.dll
?????文件???????38400??2016-06-09?10:56??門禁識別\門禁識別\bin\Debug\iFlyDotNet.pdb
?????目錄???????????0??2016-06-07?22:57??門禁識別\門禁識別\bin\Debug\trainedFaces\
............此處省略53個文件信息
- 上一篇:WpfVLC-master.rar
- 下一篇:c#課設個人日程管理附課設報告
評論
共有 條評論