function varargout = gui_demo1(varargin)
% GUI_DEMO1 M-file for gui_demo1.fig
% GUI_DEMO1, by itself, creates a new GUI_DEMO1 or raises the existing
% singleton*.
%
% H = GUI_DEMO1 returns the handle to a new GUI_DEMO1 or the handle to
% the existing singleton*.
%
% GUI_DEMO1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_DEMO1.M with the given input arguments.
%
% GUI_DEMO1('Property','Value',...) creates a new GUI_DEMO1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_demo1_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_demo1_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 gui_demo1
% Last Modified by GUIDE v2.5 16-Apr-2007 10:29:59
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_demo1_OpeningFcn, ...
'gui_OutputFcn', @gui_demo1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 gui_demo1 is made visible.
function gui_demo1_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 gui_demo1 (see VARARGIN)
% Choose default command line output for gui_demo1
handles.output = hObject;
A=ones(256,256);
axes(handles.axes2);
imshow(A);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_demo1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui_demo1_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 Browse.
function Browse_Callback(hObject, eventdata, handles)
% hObject handle to Browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[namefile,pathname]=uigetfile('*.*','Select image');
if namefile~=0
[img,map]=imread(strcat(pathname,namefile));
axes(handles.one);
imshow(img);
dimensioni = size(img);
handles.img=img;
% Update handles structure
guidata(hObject, handles);
else
warndlg('Input image must be selected.',' Warning ')
end
% --- Executes on button press in ADD_TO_DATABASE.
function ADD_TO_DATABASE_Callback(hObject, eventdata, handles)
% hObject handle to ADD_TO_DATABASE (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
messaggio='FACE RECOGNITION.';
img=handles.img;
if exist('img')
if (exist('face_database.dat')==2)
load('face_database.dat','-mat');
face_number=face_number+1;
data{face_number,1}=double(img);
prompt={strcat(messaggio,'Class number must be a positive integer <= ',num2str(max_class))};
title='Class number';
lines=1;
def={'1'};
answer=inputdlg(prompt,title,lines,def);
zparameter=double(str2num(char(answer)));
if size(zparameter,1)~=0
class_number=zparameter(1);
if (class_number<=0)||(class_number>max_class)||(floor(class_number)~=class_number)||(~isa(class_number,'double'))||(any(any(imag(class_number))))
warndlg(strcat('Class number must be a positive integer <= ',num2str(max_class)),' Warning ')
else
disp('Features extraction...please wait');
if class_number==max_class;
% this person (class) has never been added to
% database before this moment
max_class = class_number+1;
features = findfeatures(img);
else
% this person (class) has already been added to
% database
features = findfeatures(img);
end
data{face_number,2} = class_number;
L = length(features);
for ii=1:L
features_data{features_size+ii,1} = features{ii};
features_data{features_size+ii,2} = class_number;
end
features_size = length(features_data);
clc;
save('face_database.dat','data','face_number','max_class','features_data','features_size','-append');
msgbox(strcat('Database already exists: image succesfully added to class number ',num2str(class_number)),'Database result','help');
close all;
clear('img')
end
else
warndlg(strcat('Class number must be a positive integer <= ',num2str(max_class)),' Warning ')
end
else
face_number=1;
max_class=1;
data{face_number,1}=double(img);
prompt={strcat(messaggio,'Class number must be a positive integer <= ',num2str(max_class))};
title='Class number';
lines=1;
def={'1'};
answer=inputdlg(prompt,title,lines,def);
zparameter=double(str2num(char(answer)));
if size(zparameter,1)~=0
class_number=zparameter(1);
if (class_number<=0)||(class_number>max_class)||(floor(class_number)~=class_number)||(~isa(class_number,'double'))||(any(any(imag(class_number))))
warndlg(strcat('Class number must be a positive integer <= ',num2str(max_class)),' Warning ')
else
disp('Features extraction...please wait');
max_class=2;
data{face_number,2}=class_number;
features = findfeatures(img);
L = length(features);
for ii=1:L
features_data{ii,1} = features{ii};
features_data{ii,2} = class_number;
end
features_size = length(features_data);
clc;
save('face_database.dat
MATLAB实现人脸识别【深度学习、人工智能项目实战】.zip
版权申诉
144 浏览量
2023-04-21
18:10:07
上传
评论 2
收藏 344KB ZIP 举报
不脱发的程序猿
- 粉丝: 24w+
- 资源: 5773
最新资源
- MQTT协议发温湿度到阿里云平台支持下发控制LED灯与继电器对接阿里云APP
- STM32F103ZET6+OV2640+TF卡存储
- 操作系统考试要点最新版本.doc
- 操作系统试题B卷.doc
- 移动机器人自主路径规划之RRT算法MATLAB实现代码
- Python使用 LSTM循环神经网络预测风力发电厂中风机产生的功率项目源码+数据集.zip
- 深入探究文件I/O-I.MX6U嵌入式Linux C应用编程学习笔记基于正点原子阿尔法开发板
- MQTT协议发温湿度电压数据到ONENET支持下发控制LED灯与继电器(新平台)
- 平抑风电波动的电-氢混合储能容量优化配置(注释完全,可直接运行)(文档加Matlab源码)
- Gigabyte.RX560.4g 1750mhz bios GAMING OC
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈