function varargout = face_detect(varargin)
% FACE_DETECT MATLAB code for face_detect.fig
% FACE_DETECT, by itself, creates a new FACE_DETECT or raises the existing
% singleton*.
%
% H = FACE_DETECT returns the handle to a new FACE_DETECT or the handle to
% the existing singleton*.
%
% FACE_DETECT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FACE_DETECT.M with the given input arguments.
%
% FACE_DETECT('Property','Value',...) creates a new FACE_DETECT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before face_detect_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to face_detect_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 face_detect
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @face_detect_OpeningFcn, ...
'gui_OutputFcn', @face_detect_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 face_detect is made visible.
function face_detect_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 face_detect (see VARARGIN)
% Choose default command line output for face_detect
handles.output = hObject;
Unt;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes face_detect wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = face_detect_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;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
ax1=(handles.axes1);cla(ax1,'reset')
ax2=(handles.axes2);cla(ax2,'reset')
ax4=(handles.edit1);cla(ax4,'reset')
%读取人脸库的路径
%文件筛选框 选择图片
[filename,pathname] = uigetfile({'*.jpg;*.bmp;*.tif;*.png;*.gif','All Image Files'},'请选择一张图片');
if filename == 0%如果没有选择,直接返回即可
return;
end
strfullname = strcat(pathname,filename);%取得图像文件全名
TestImage= imread(strfullname);%读取图片
axes(handles.axes1);
imshow(TestImage);%显示图片
title('测试图像');
handles.TestImage=TestImage;
TrainDatabasePath=handles.TrainDatabasePath;
str1=sprintf('温馨提示\n\n');
str2=sprintf(' 1.时间有限,专攻MATLAB算法\n');
str3=sprintf(' 2.有需要可加工程师\n');
str4=sprintf(' 3.祝您生活愉快\n');
string=[str1 str2 str3 str4];
msgbox(string,'温馨提示','none');
Unt;
return
% 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)
str1=sprintf('温馨提示\n\n');
str2=sprintf(' 1.时间有限,专攻MATLAB算法\n');
str3=sprintf(' 2.有需要可加工程师\n');
str4=sprintf(' 3.祝您生活愉快\n');
string=[str1 str2 str3 str4];
msgbox(string,'温馨提示','none');
Unt;
return
Difference = double(InImage)-m;
ProjectedTestImage = Eigenfaces'*Difference; % 将待测样本投影到特征空间
%%%%%%%%%%%%%%%%%%%%%%%% 按照欧式距离取最小的原则得出匹配的人脸
Euc_dist = [];
for i = 1 : Train_Number
q = ProjectedImages(:,i);
temp = ( norm( ProjectedTestImage - q ) )^2;
Euc_dist = [Euc_dist temp];
end
%选取最小欧式距离的人脸
[Euc_dist_min , Recognized_index] = min(Euc_dist);
%获取该人脸的数字代号
OutputName = strcat(int2str(Recognized_index),'.jpg');
SelectedImage = strcat(TrainDatabasePath,'\',OutputName);
SelectedImage = imread(SelectedImage);
axes(handles.axes2);
imshow(SelectedImage);
title('库内匹配人脸');
%输出识别人脸的数字代号
%str = strcat('Matched image is : ',OutputName);
set(handles.edit1,'string',Recognized_index);
%%%%输出打卡信息
%%%%%%%%%%%%%输出个人信息
classlabel=Recognized_index;
if classlabel==1 | classlabel==2
set(handles.edit13,'string','姚明');
elseif classlabel==3 | classlabel==4
set(handles.edit13,'string','B');
elseif classlabel==5 | classlabel==6
set(handles.edit13,'string','名字');
elseif classlabel==7 | classlabel==8
set(handles.edit13,'string','D');
elseif classlabel==9 | classlabel==10
set(handles.edit13,'string','E');
elseif classlabel==11 | classlabel==12
set(handles.edit13,'string','F');
elseif classlabel==13 | classlabel==14
set(handles.edit13,'string','G');
elseif classlabel==15 | classlabel==16
set(handles.edit13,'string','H');
elseif classlabel==17 | classlabel==18
set(handles.edit13,'string','I');
elseif classlabel==19| classlabel==20
set(handles.edit13,'string','J');
end
%识别的时间
% 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 pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
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 COMPUT
蒹葭苍苍987
- 粉丝: 0
- 资源: 93
最新资源
- Azure OpenAI:生成式人工智能的创新与实践
- ParseError12.md
- 内存分配失败异常解决办法.md
- java.静态关键字(解决方案).md
- content_1736261633667.zip
- MATLAB 实现基于AOA(算术优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- MATLAB 实现基于AFSA(人工鱼鹰算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- CCleaner注册表修复工具
- MATLAB 实现基于NGO(北方苍鹰优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- MATLAB 实现基于SLWCHOA(简化的Levy加权黑猩猩优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- 基于python+Django+Mysql的校园二手交易市场源码+数据库脚本+文档说明
- 基于C++的绘图软件直线、圆、曲线、矩形、二次均匀B样条曲线、多边形等等-2025期末大作业
- 索尼CMOS图像传感器全球快门功能与工业应用:IMX264和IMX265的小型高分辨率像素设计
- MATLAB 实现基于HKELM(混合核极限学习机)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- MATLAB 实现基于EBWO(改进的白鲸优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- linux常用命令大全.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈