資源簡介
openCv 人臉識別源代碼,編程環(huán)境是:VS2015大家需要先配置好環(huán)境,該源碼加了人臉識別考勤點名上傳到sql數(shù)據(jù)庫的代碼,大家只需要將time1的enabled事件設成True,再修改下指向連接的數(shù)據(jù)庫及可。
代碼片段和文件信息
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.CV.Structure;
using?Emgu.Util;
using?Emgu.CV.CvEnum;?
using?Emgu.CV.Features2D;
using?System.IO;
using?System.Data.SqlClient;
using?System.Net;
using?SpeechLib;
namespace?FaceCap
{
????public?partial?class?FaceCap?:?Form
????{
????????Timer?timer1?=?new?Timer();
????????int?counter?=?0;
????????private?Capture?cap;??????
????????private?HaarCascade?haar;
????????Image?Imageframe;
????????MCvFont?font?=?new?MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX?0.5d?0.5d);
????????Image?result?TrainedFace?=?null;
????????Image?gray?=?null;
????????List>?trainingImages?=?new?List>();
????????List?labels?=?new?List();
????????List?NamePersons?=?new?List();
????????int?ContTrain?NumLabels?t;
????????string?name?=?null;
????????string?names?=?null;
???????
????????private?void?Processframe(object?sender?EventArgs?arg)
????????{
????????????NamePersons.Add(““);
????????????Imageframe?=?cap.Queryframe().Resize(640?480?Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
????????????gray?=?Imageframe.Convert();
????????????//Face?Detector
????????????MCvAvgComp[][]?facesDetected?=?gray.DetectHaarCascade(haar?1.2?10?Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING?new?Size(20?20));
????????????//Action?for?each?element?detected
????????????foreach?(MCvAvgComp?f?in?facesDetected[0])
????????????{
????????????????t?=?t?+?1;
????????????????result?=?Imageframe.Copy(f.rect).Convert().Resize(100?100?Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
????????????????//draw?the?face?detected?in?the?0th?(gray)?channel?with?red?color
????????????????Imageframe.Draw(f.rect?new?Bgr(Color.Blue)?2);
????????????????try
????????????????{
????????????????????if?(trainingImages.ToArray().Length?!=?0)
????????????????????{
????????????????????????//TermCriteria?for?face?recognition?with?numbr?of?trained?images?like?maxIteration
????????????????????????MCvTermCriteria?termCrit?=?new?MCvTermCriteria(ContTrain?0.001);
????????????????????????//Eigen?face?recognizer
????????????????????????EigenobjectRecognizer?recognizer?=?new?EigenobjectRecognizer(
???????????????????????????trainingImages.ToArray()
???????????????????????????labels.ToArray()
???????????????????????????3500
???????????????????????????ref?termCrit);
????????????????????????name?=?recognizer.Recognize(result);
????????????????????????//顯示識別后的人臉姓名或編號
????????????????????????textBox2.Text?=?name;
????????????????????????//Draw?the?label?for?each?face?detected?and?recognized
????????????????????????Imageframe.Draw(name?ref?font?new?Point(f.rect.X?-?2?f.rect.Y?-?2)?new?Bgr(Color.Red));
????????????????????}
????????????????}
?????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-05-14?14:30??Openvc?動態(tài)人臉識別對比學習(004)\
?????文件?????????378??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\.gitattributes
?????文件?????????574??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\.gitignore
?????目錄???????????0??2018-05-14?14:28??Openvc?動態(tài)人臉識別對比學習(004)\.vs\
?????目錄???????????0??2018-05-14?14:28??Openvc?動態(tài)人臉識別對比學習(004)\.vs\縱橫智控智慧監(jiān)獄人臉識別系統(tǒng)\
?????目錄???????????0??2018-05-14?14:28??Openvc?動態(tài)人臉識別對比學習(004)\.vs\縱橫智控智慧監(jiān)獄人臉識別系統(tǒng)\v14\
?????文件???????53248??2018-05-14?14:40??Openvc?動態(tài)人臉識別對比學習(004)\.vs\縱橫智控智慧監(jiān)獄人臉識別系統(tǒng)\v14\.suo
?????文件?????????144??2018-05-08?14:41??Openvc?動態(tài)人臉識別對比學習(004)\app.config
?????目錄???????????0??2018-05-08?13:48??Openvc?動態(tài)人臉識別對比學習(004)\bin\
?????目錄???????????0??2018-05-14?14:40??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\
?????文件??????325472??2018-05-14?14:39??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\2018-05-14_143944.png
?????文件??????325782??2018-05-14?14:40??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\2018-05-14_144011.png
?????文件??????603136??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\cvextern.dll
?????文件??????264704??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\Emgu.CV.dll
?????文件??????111616??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\Emgu.CV.UI.dll
?????文件???????10240??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\Emgu.CV.UI.resources.dll
?????文件???????23040??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\Emgu.Util.dll
?????文件?????????490??2017-03-19?05:00??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\FaceCap.vshost.exe.manifest
?????文件??????506314??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\haarcascade_eye.xm
?????文件?????3644763??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\haarcascade_frontalface_alt_tree.xm
?????文件??????176128??2018-05-08?15:18??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\Interop.SpeechLib.dll
?????文件??????419840??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_calib3d220.dll
?????文件??????452608??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_contrib220.dll
?????文件?????2133504??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_core220.dll
?????文件??????815104??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_features2d220.dll
?????文件?????5536768??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_ffmpeg220.dll
?????文件???????30208??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_flann220.dll
?????文件??????151552??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_gpu220.dll
?????文件??????886784??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_highgui220.dll
?????文件?????1438720??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_imgproc220.dll
?????文件??????676864??2015-05-06?19:55??Openvc?動態(tài)人臉識別對比學習(004)\bin\Debug\opencv_legacy220.dll
............此處省略64個文件信息
- 上一篇:DCM文件轉圖像,并高清處理圖像
- 下一篇:桌面多顯示器多屏幕截圖
評論
共有 條評論