A list,

Matlab do multi-person scene face recognition. The first pretreatment, face positioning, segmentation, training, PCA dimensionality reduction to find the covariance matrix, face feature value, and then each test of the face of the matrix, respectively, for difference comparison, the results of the smallest is the target face, output recognition results, this design has a visual GUI user operation interface.

Ii. Source code

function varargout = Main(varargin)
% MAIN MATLAB code for Main.fig
%      MAIN, by itself, creates a new MAIN or raises the existing
%      singleton*.
%
%      H = MAIN returns the handle to a new MAIN or the handle to
%      the existing singleton*.
%
%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN.M with the given input arguments.
%
%      MAIN('Property'.'Value',...). creates anew MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Main_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one % instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Main

% Last Modified by GUIDE v2. 5 21-Nev- 2020. 01:12:36

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Main_OpeningFcn, ...
                   'gui_OutputFcn',  @Main_OutputFcn, ...
                   'gui_LayoutFcn', [],...'gui_Callback'[]);if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Main is made visible.
function Main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Main (see VARARGIN)

% Choose default command line output for Main
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Main wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Main_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.edit1,'string'.'Idea: Make the face database of the person in the group photo in advance, and train it well')

% --- Executes on button press in pushbuttonfacedetect.
function pushbuttonfacedetect_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonfacedetect (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% if the image has not been loadedif(~isfield(handles,'I'))
     str = sprintf('You haven't loaded the image yet! ');
    set(handles.reporttext,'string',str);
    return
end

I = handles.I;
[faceI,box] = facedetect(I);

ifAxes (~ isEmpty (faceI)) % Axes (handles. Axes1)'Position',box,'EdgeColor'.'r'); Axes (handles. Axes2) axes(faceI)else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


handles.faceI = faceI;
% Update handles structure
guidata(hObject, handles);
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
   set(handles.edit2,'string'.'Idea: From the group photo, locate the face, and divide it into the corresponding box to display')


% --- Executes on button press in pushbuttonfacedetect.
function pushbuttonfacedetect_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonfacedetect (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% if the image has not been loadedif(~isfield(handles,'I'))
     str = sprintf('You haven't loaded the image yet! ');
    set(handles.reporttext,'string',str);
    return
end

I = handles.I;
[faceI,box] = facedetect(I);

ifAxes (~ isEmpty (faceI)) % Axes (handles. Axes1)'Position',box,'EdgeColor'.'r'); Axes (handles. Axes2) axes(faceI)else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


handles.faceI = faceI;
% Update handles structure
guidata(hObject, handles);
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
set(handles.edit3,'string'.'Idea: Identify each face individually')


% --- Executes on button press in pushbuttonfacedetect.
function pushbuttonfacedetect_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonfacedetect (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% if the image has not been loadedif(~isfield(handles,'I'))
     str = sprintf('You haven't loaded the image yet! ');
    set(handles.reporttext,'string',str);
    return
end

I = handles.I;
[faceI,box] = facedetect(I);

ifAxes (~ isEmpty (faceI)) % Axes (handles. Axes1)'Position',box,'EdgeColor'.'r'); Axes (handles. Axes2) axes(faceI)else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


handles.faceI = faceI;
% Update handles structure
guidata(hObject, handles);

% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
set(handles.edit4,'string'.'Expansion: Application scenarios can be changed to classroom attendance, dormitory attendance, railway station and other public places')

% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double


% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end


% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
I = imread('5.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit5,'string',classlabel);
    drawnow
    
   
    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);


% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)

I = imread('6.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)

I = imread('7.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
I = imread('8.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);

% hObject    handle to pushbutton12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit11_Callback(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double


% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double


% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end


% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
I = imread('9.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);

% hObject    handle to pushbutton13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)

I = imread('10.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
       
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

I = imread('11.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
I = imread('12.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);

% hObject    handle to pushbutton16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)


[filename, pathname] = uigetfile( ...
{'*.jpg; *.png; *.jpeg'.'Image Files (*.bmp; *.jpg; *.png; *.jpeg)'; .'*. *'.'All Files (*.*)'},...'Pick an image');
if isequal(filename,0) || isequal(pathname,0).return; end fpath=[pathname filename]; % combine filename and directory name into a full path img=imread(fpath); axes(handles.axes1) imshow(img) title('Group photo')
msgbox('Interested, can add Q discussion, 1183814288')

% hObject    handle to pushbutton17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton18.
function pushbutton18_Callback(hObject, eventdata, handles)
msgbox('Counting part of the idea: Locator implementation')
set(handles.reporttext,'string'.'Project Customization, Q: 1183814288')
% hObject    handle to pushbutton18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton19.
function pushbutton19_Callback(hObject, eventdata, handles)
ax2=(handles.axes2); cla(ax2,'reset') ax3=(handles.axes3); cla(ax3,'reset') ax4=(handles.axes4); cla(ax4,'reset') ax5=(handles.axes5); cla(ax5,'reset')

% hObject    handle to pushbutton19 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function edit13_Callback(hObject, eventdata, handles)
% hObject    handle to edit13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit13 as text
%        str2double(get(hObject,'String')) returns contents of edit13 as a double


% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function reporttext_Callback(hObject, eventdata, handles)
% hObject    handle to reporttext (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of reporttext as text
%        str2double(get(hObject,'String')) returns contents of reporttext as a double


% --- Executes during object creation, after setting all properties.
function reporttext_CreateFcn(hObject, eventdata, handles)
% hObject    handle to reporttext (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit15_Callback(hObject, eventdata, handles)
% hObject    handle to edit15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit15 as text
%        str2double(get(hObject,'String')) returns contents of edit15 as a double


% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit16_Callback(hObject, eventdata, handles)
% hObject    handle to edit16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit16 as text
%        str2double(get(hObject,'String')) returns contents of edit16 as a double


% --- Executes during object creation, after setting all properties.
function edit16_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit17_Callback(hObject, eventdata, handles)
% hObject    handle to edit17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit17 as text
%        str2double(get(hObject,'String')) returns contents of edit17 as a double


% --- Executes during object creation, after setting all properties.
function edit17_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



function edit18_Callback(hObject, eventdata, handles)
% hObject    handle to edit18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit18 as text
%        str2double(get(hObject,'String')) returns contents of edit18 as a double


% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end


% --- Executes on button press in pushbutton20.
function pushbutton20_Callback(hObject, eventdata, handles)

I = imread('10.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
       
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

I = imread('13.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    

guidata(hObject, handles);
% hObject    handle to pushbutton20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton21.
function pushbutton21_Callback(hObject, eventdata, handles)

I = imread('10.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
       
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

I = imread('14.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton22.
function pushbutton22_Callback(hObject, eventdata, handles)

I = imread('10.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
       
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

I = imread('15.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
    %axes(handles.axes1)
    %imshow(faceI)
    strtitle = sprintf('Result %d person',classlabel);
    title(strtitle)

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton23.
function pushbutton23_Callback(hObject, eventdata, handles)

I = imread('10.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
       
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

I = imread('16.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
    
   

    
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton23 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton24.
function pushbutton24_Callback(hObject, eventdata, handles)

I = imread('10.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value and location classLabel = TrainLabel (minIndex); % Indicates the class number % STR =sprintf('Identification complete. Identify this photo as person %d. ',classlabel);
    set(handles.edit4,'string',classlabel);
    drawnow
       
else
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

I = imread('11.bmp'); Handles.I = I; handles.faceI = I; % Update handles structure load trainresult.mat

if(isfield(handles,'faceI') && ~isempty(handles.faceI))% If a face faceI is detected= handles.faceI; [M,N,color] = size(faceI); % gets the size of the image, and the color typeif color == 3% If color image I = rGB2Gray (faceI); % to grayscale imageelseI = faceI; end % I1= imadjust(I1,stretchlim(I1)); Gray transform, image enhancementif (isequal([M,N],goalsize) == 0)% If not64*64I = imresize (I, goalsize); % becomes fixed64*64End samplesnum = size(PCAfeatures,1); % number of training samples I1 = I(:); % image conversion1The column matrix I1 is equal todouble(I1'); Z=(I1-mA); % minus mean feature1 = Z*V; PCA feature dd = Zeros (1,samplesnum);
    for j = 1Feature2 = PCAfeatures(j,:); D = dist(feature1,feature2); % Calculate the distance between features dd(j) = d; End [value,minindex] = min(dd); % minimum value, and the locationelse
   set(handles.reporttext,'string'.'No face detected, unable to identify! ');
end


guidata(hObject, handles);
% hObject    handle to pushbutton24 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
Copy the code

Second, operation results

Third, note

Version: 2014 a