資源簡介
基于訓練卷積神經網絡alexnet的人臉識別設計,并采用級聯目標檢測技術對裁剪人臉進行識別。使用函數capturefacesfromvideo.m從視頻獲取訓練數據,并存儲人臉圖像。使用函數cropface.m從訓練數據的圖像中裁剪人臉。通過改變各層的數量來訓練卷積神經網絡alexnet。使用訓練后的newnet實現人臉識別。

代碼片段和文件信息
%?Create?the?face?detector?object.
faceDetector?=?vision.CascadeobjectDetector(‘FrontalFaceCART‘‘MinSize‘[150150]);
%?Here?the?loop?runs?for?300?times?you?can?change?the?threshold?(n)?based?on?the?number?of?training?data?you?need
n?=?300;
%?change?str?to?s01s02s03....?for?saving??upto?how?many?subjects?you?want?to?save?for?saving?in?respective?folders?for?
%?imwrite?in?line?88
str?=?‘s01‘;
%?Create?the?point?tracker?object.
pointTracker?=?vision.PointTracker(‘MaxBidirectionalError‘?2);
%?Create?the?webcam?object.
cam?=?webcam();
%?Capture?one?frame?to?get?its?size.
videoframe?=?snapshot(cam);
frameSize?=?size(videoframe);
%?Create?the?video?player?object.
videoPlayer?=?vision.VideoPlayer(‘Position‘?[100?100?[frameSize(2)?frameSize(1)]+30]);
runLoop?=?true;
numPts?=?0;
frameCount?=?0;
i=1;
while?runLoop?&&?frameCount?
????%?Get?the?next?frame.
????videoframe?=?snapshot(cam);
????videoframeGray?=?rgb2gray(videoframe);
????frameCount?=?frameCount?+?1;
????if?numPts?10
????????%?Detection?mode.
????????bbox?=?faceDetector.step(videoframeGray);
????????if?~isempty(bbox)
????????????%?Find?corner?points?inside?the?detected?region.
????????????points?=?detectMinEigenFeatures(videoframeGray?‘ROI‘?bbox(1?:));
????????????%?Re-initialize?the?point?tracker.
????????????xyPoints?=?points.Location;
????????????numPts?=?size(xyPoints1);
????????????release(pointTracker);
????????????initialize(pointTracker?xyPoints?videoframeGray);
????????????%?Save?a?copy?of?the?points.
????????????oldPoints?=?xyPoints;
????????????%?Convert?the?rectangle?represented?as?[x?y?w?h]?into?an
????????????%?M-by-2?matrix?of?[xy]?coordinates?of?the?four?corners.?This
????????????%?is?needed?to?be?able?to?transform?the?bounding?box?to?display
????????????%?the?orientation?of?the?face.
????????????bboxPoints?=?bbox2points(bbox(1?:));
????????????%?Convert?the?box?corners?into?the?[x1?y1?x2?y2?x3?y3?x4?y4]
????????????%?format?required?by?insertShape.
????????????bboxPolygon?=?reshape(bboxPoints‘?1?[]);
????????????%?Display?a?bounding?box?around?the?detected?face.
????????????videoframe?=?insertShape(videoframe?‘Polygon‘?bboxPolygon?‘LineWidth‘?3);
????????????%?Display?detected?corners.
????????????videoframe?=?insertMarker(videoframe?xyPoints?‘+‘?‘Color‘?‘white‘);
????????end
????else
????????%?Tracking?mode.
????????[xyPoints?isFound]?=?step(pointTracker?videoframeGray);
????????visiblePoints?=?xyPoints(isFound?:);
????????oldInliers?=?oldPoints(isFound?:);
????????numPts?=?size(visiblePoints?1);
????????if?numPts?>=?10
????????????%?Estimate?the?geometric?transformation?between?the?old?points
????????????%?and?the?new?points.
????????????[xform?oldInliers?visiblePoints]?=?estimateGeometricTransform(...
????????????????oldInliers?visiblePoints?‘similarity‘?‘MaxDistance‘?4);
????????????%?Apply?the?transformation?to?the?bounding?box.
????????????bboxPoints?=?transformPointsForward(xform?bboxPoints);
????????????%?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\
?????文件?????????538??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\README.md
?????文件????????1696??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\SimpleFaceRecognition.m
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\Training?Progress?Report\
?????文件??????136452??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\Training?Progress?Report\Training?Progress?Plot.JPG
?????文件?????????212??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\Training?Progress?Report\Training?Progress?Report.txt
?????文件????????3993??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\capturefacesfromvideo.m
?????文件?????????276??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\cropandsave.m
?????文件?????????276??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\cropface.m
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\
?????文件?????????181??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\s01\
?????文件?????????181??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\s01\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\s02\
?????文件?????????181??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\s02\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\s03\
?????文件?????????181??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\croppedfaces\s03\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\
?????文件?????????165??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\s01\
?????文件?????????165??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\s01\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\s02\
?????文件?????????165??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\s02\readme.txt
?????目錄???????????0??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\s03\
?????文件?????????165??2019-07-09?08:20??Yash0330-Face-Recognition-by-CNN-464efe8\photos\s03\readme.txt
- 上一篇:藍橋杯單片機
- 下一篇:IEEE 1471 軟件架構標準
評論
共有 條評論