A list,

This paper uses ORL face database, which is taken by Cambridge Laboratory in The UK. There are 40 people in total and 10 photos of each person with different expressions from different angles, so there are 400 sample data in total. The image size is 11292 and the format is PGM. In this paper, the first 5 sheets of each person are used as training sets and the last 5 sheets are used as test sets. ORL face database available on the web site to download https://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html 1 face recognition is what? Facial recognition technology, this is, by means of computer aided Recognize faces from static or moving images. Face recognition in this problem, is given a figure, the use of face database to match it, judge whether it belongs to the database. If so, give the category she belongs to. 2 why choose face as recognition feature to recognize? Because a face, like a fingerprint, is unique, it can be used to identify a person. In other words, if we want to identify an object, we need to select its main features, distinguishing features, so that the recognition results are reliable. Just like if we want to identify a person, why not identify their height, weight, skin color, eye size, etc.? Because these are not unique, they are too common as data, and the probability of two people having the same height, weight, and skin color is too high to be the only distinguishing feature. DNA, fingerprint, iris and other attributes are chosen to identify a person because these attributes are unique. No one in the world has the same characteristics as you. 3 Face recognition is how? (1) find the region of interest —- from the complex scene detection and separation of the face of the region; (2) capture features – extraction of face recognition features; (3) Match – to match and identify; 4 In order to achieve face recognition, what do you do? (1) face database ORL (2) part of the database of face pictures used to do training data, model. (3) The other part can be used to do test data, check the recognition rate. 5. PCA principal component analysis for dimensionality reduction (1) Why dimensionality reduction? Because each face image contains 11292=10304 pixels, and each row represents a sample, the dimension is 10304 dimensions. Such a large dimension makes data processing very difficult and eliminates the idea of directly using pixels as eigenvalues to identify. (2) What is PCA? How does it reduce dimension? PCA is principal Component analysis. PCA dimensionality reduction is used to remove the correlation between pixels, remove the principal components, and discard those components that cannot provide us with important feature information. PCA can select the main components by sorting the component components (10304 dimensions) in the sample data, constitute the principal component V(N *k) matrix (K dimensions), and output the k-dimension matrix pcaA after dimensionality reduction. B1) The principal component matrix V can be directly substituted into the formula in test. M and classify. M to obtain the matrix after dimension reduction. TestFace = (testface-repmat (meanVec, m, 1))*V; % In b12) classify. M, xNewFace=(xNewFace-meanVec)*V; The output K-dimensional matrix pcaA will replace the original sample data to participate in subsequent data processing, that is, pcaA will become the sample. 3 Data normalization (1) What is data normalization? Data normalization, also known as data scale normalization, refers to the projection of the value range of an attribute into a specific range, such as the commonly used [0,1] or [-1,+1] normalization. B) The role of data normalization? B1) Prevent features in a relatively large numerical range from overpowering those in a small numerical range. For example, several people have a wide range of height (150cm-180cm) and a small range of weight (50kg-60kg). After data normalization, the difference between the two attributes is reduced, which well protects the attributes with a small range of change can still play an important role in target recognition. B2) Avoid some data overflow problems and scale to the same range. For example, limit all data to [-1,+1] so that even the big ones have to bend their heads. 6 SVM classification recognition a) What is SVM? SVM Support Vector Machine. SVM is a classification method. It establishes a classification model through training data and uses the classification model to classify test data. It’s like stacking a black box, and you throw balls into it, and he can sort the balls. That is, of course, if you use a bunch of balls (training data) to build this black box. A1) SVMTrain — Establish classification model by training data SVMStruct A2) SVMClassify — classify and identify test data by model

B) Advantages of SVM? The traditional pattern recognition technology only considers the fitting of classifier to the training sample and aims to minimize the classification errors on the training set. However, in the case of lack of small representative training sets, blindly reducing errors in training sets will easily lead to over-fitting. This is called focusing on the existing (training data), not knowing the situation, to look to the future (test data) ah big brother! At this time, SVM appeared. She knew how to weigh advantages and disadvantages, instead of blindly pursuing perfect training data fitting, she took into account training error and testing error to obtain the overall victory, really a wise goddess! Let the traditional identification technology diaosi brothers put to the dust! C) the focus of SVM? SVM focuses on the selection of classification model and model parameters. C1) Classification model: Excessive fitting can be prevented by controlling the complexity of classification model. Therefore, SVM prefers simple models to interpret data — straight lines in two-dimensional space, planes in three-dimensional space, and hyperplanes in higher-dimensional space. C2) Parameter selection: parameter selection is based on – > finding the optimal classification hyperplane, that is, finding the optimal classification hyperplane that can successfully separate two types of samples and has the maximum classification interval. D) What are the technical hotspots of SVM?

Kernel function: when low dimension cannot separate the two types of samples, nonlinear mapping can be adopted to high dimension and hyperplane can be used to separate. Mapping from lower dimensions to higher dimensions is where the kernel function is used, and the magic of the kernel function is that you don’t need to know exactly what the mapping is to give you a linear classification of some nonlinear classification, and the computational complexity is no greater than in lower dimensions. This is a genius function! Kernel function. Commonly used kernel functions are: linear kernel function, polynomial kernel function, radial basis kernel function, Sigmoid kernel function. SVM to more classes: because SVM is a dichotomer, her basic idea is to separate two types of samples, that is, can only be used for the classification of two types of samples. If you want to identify multiple classes, you need to use some strategies. Common strategies include: one-to-many maximum response strategy, one-to-one voting strategy, one-to-one elimination strategy.

7 face recognition algorithm steps overview: (1) read training data set; (2) Principal component analysis reduces dimension and removes correlation between data; (3) Data normalization (excluding the influence of data unit factor on classification, this has little influence on the experiment); (4) SVM training (selecting radial basis and function); (5) Read test data, reduce dimension and normalize; (6) The classification function generated in Step 4 is used for classification (multi-classification problem, one-to-one voting strategy is adopted, and the category with the most votes is returned); (7) Calculate the correct rate.

Ii. Source code

% FR_GUI.m
addpath(genpath('/'))
global h_axes1;
global h_axes2;
h_f = figure('name'.Face Recognition System Based on PCA and SVM);

h_textC = uicontrol(h_f, 'style'.'text'.'unit'.'normalized'.'string'.'C='.'position'. [0.05 0.7 0.1 0.06]);
h_editC = uicontrol(h_f, 'style'.'edit'.'unit'.'normalized'.'position'[0.05 0.6 0.1 0.06],...
    'callback'.'C = str2num(get(h_editC, ''string'')));
h_textGamma = uicontrol(h_f, 'style'.'text'.'unit'.'normalized'.'string'.'gamma='.'position'. [0.05 0.5 0.1 0.06]);
h_editGamma = uicontrol(h_f, 'style'.'edit'.'unit'.'normalized'.'position'[0.05 0.4 0.1 0.06],...
    'callback'.'gamma = str2num(get(h_editGamma, ''string''))); % gets the current values of the C and gamma arguments, which were used in the last training t = dir('Mat/params.mat');
if length(t) = =0C = Inf; gamma =1
elseload Mat/params.mat; end function [imgRow,imgCol,FaceContainer,faceLabel]=ReadFaces(nFacesPerPerson, nPerson, BTest) % The first five faces to read into the ORL face library for a specified number of faces (training) % % Enter: nFacesPerPerson - the number of samples each person needs to read. The default value is5% nPerson - Number of people to read. Default is all40Personal % bTest --boolType parameter. The default is0, means reading training samples (before5Zhang); If it is1, after reading the test sample5Output: FaceContainer -- vectorized FaceContainer, nPerson *103042Dimensional matrix, each row corresponds to a face vectorif nargin==0 %default value
    nFacesPerPerson=5; % before5Zhang is used to train nPerson=40; % Number of people to read (total per person10Zhang, a former5Eg. Zhang is used for training0;
elseif nargin < 3
    bTest = 0;
end

img=imread('Data/ORL/S1/1.pgm'); ImgRow,imgCol =size(img); FaceContainer = zeros(nFacesPerPerson*nPerson, imgRow*imgCol); faceLabel = zeros(nFacesPerPerson*nPerson,1); % Read training datafor i=1:nPerson
    i1=mod(i,10); % bits i0 =char(i/10);
    strPath='Data/ORL/S';
    if( i0~=0 )
        strPath=strcat(strPath,'0'+i0);
    end
    strPath=strcat(strPath,'0'+i1);
    strPath=strcat(strPath,'/');
    tempStrPath=strPath;
    for j=1:nFacesPerPerson
        strPath=tempStrPath;
        
        if bTest == 0% Read training data strPath =strcat(strPath, '0'+j);
        else
            strPath = strcat(strPath, num2str(5+j));
        end

        FaceContainer((i- 1)*nFacesPerPerson+j, :) = img(:)'; faceLabel((i-1)*nFacesPerPerson+j) = i; end % j end % iCopy the code

3. Operation results



Fourth, note

Version: 2014 a