Pages

Showing posts with label eye. Show all posts
Showing posts with label eye. Show all posts

Sunday

Détection d'œil avec MATLAB 2016

La reconnaissance faciale par ordinateur:

La reconnaissance de visage est le processus d'identification d'une ou plusieurs personnes dans des images ou des vidéos en analysant et en comparant des modèles. Les algorithmes pour la reconnaissance faciale extraient typiquement les caractéristiques faciales et les comparent à une base de données pour trouver la meilleure correspondance. La reconnaissance faciale est une partie importante de nombreux systèmes biométriques, de sécurité et de surveillance, ainsi que des systèmes d'indexation d'image et de vidéo.

Étapes du processus de reconnaissance de visage.



Notions de base


La détection d'objets à l'aide des classificateurs en cascade Haar est une méthode de détection d'objet efficace proposée par Paul Viola et Michael Jones dans son article "Détection Rapide d'Objets utilisant une Cascade de Fonctions Simples". Cascade est formée à partir d'un grand nombre d'images positives et négatives. Il est ensuite utilisé pour détecter des objets dans d'autres images.

Ici, nous allons travailler avec la détection de l'eye. Initialement, l'algorithme a besoin de beaucoup d'images positives (images des yeux) et d'images négatives (images sans yeux) pour former le classificateur. Ensuite, nous devons extraire des fonctionnalités de celui-ci. Pour cela, les caractéristiques de haar indiquées dans l'image ci-dessous sont utilisées. Ils sont comme notre noyau convolutionnel. Chaque caractéristique est une valeur unique obtenue en soustrayant la somme des pixels sous le rectangle blanc de la somme des pixels sous le rectangle noir.

Détection d'œil a base de Matlab:


Eye detection using MATLAB



Code MATLAB:



faceDetector = vision.CascadeObjectDetector('C:\Users\Imed\Desktop\Projet_sign_detection_matlab\eye.xml');
pointTracker = vision.PointTracker('MaxBidirectionalError', 8);
cam = webcam();
videoFrame = snapshot(cam);
frameSize = size(videoFrame);

videoPlayer = vision.VideoPlayer('Position', [100 100 [frameSize(2), frameSize(1)]+30]);
runLoop = true;
numPts = 0;
frameCount = 0;
while runLoop && frameCount < 800
    videoFrame = snapshot(cam);
    videoFrameGray = rgb2gray(videoFrame);
    frameCount = frameCount + 1;

    if numPts < 10
        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(xyPoints,1);
            release(pointTracker);
            initialize(pointTracker, xyPoints, videoFrameGray);

            % Save a copy of the points.
            oldPoints = xyPoints;
            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);

            % 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 face being tracked.
            videoFrame = insertShape(videoFrame, 'Polygon', bboxPolygon, 'LineWidth', 3);
            position =  [1 50; 100 50];
value = [111 pi];text_str = 'eye';position =xyPoints;
box_color = {'red'};
hh=[bboxPoints(4,1) bboxPoints(4,2)];
videoFrame= insertText(videoFrame,hh,text_str,'FontSize',14,'BoxColor',...
    box_color,'BoxOpacity',0.6,'TextColor','white');
            % Display tracked points.
            videoFrame = insertMarker(videoFrame, visiblePoints, '+', 'Color', 'white');

            % Reset the points.
            oldPoints = visiblePoints;
            setPoints(pointTracker, oldPoints);
        end

    end

    % Display the annotated video frame using the video player object.
    step(videoPlayer, videoFrame);

    % Check whether the video player window has been closed.
    runLoop = isOpen(videoPlayer);
end

% Clean up.
clear cam;
release(videoPlayer);
release(pointTracker);
release(faceDetector);


Telechargement :

eye.xml 



Plus d'informations : imedelmottakel@gmail.com





Top 10 common Software Architectural Patterns

Introduction: Did you ever posed the question:  How large software in industrial scale systems are designed ? Here I'll explai...