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

资源简介

基于训练卷积神经网络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 < n

    % 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

评论

共有 条评论