基于matlab的自动人脸识别系统GUI设计

   之前做的一个课设项目半成品,一边网上找资料一边自己瞎捣鼓,完成了GUI界面的设计,实时视频中的人脸检测和追踪,PCA算法训练,单张人脸识别。但是识别率比较低,多人人脸识别和识别准确率统计这些部分还没有完成,等之后有空闲时再进行完善,然后将整个项目的具体过程给大家分享。下面是代码(省事,整个代码贴上来了,需要的话自己再处理一下吧,也欢迎各位大佬指点一下小白)。PCA算法部分参考了GitHub开源项目-face_recognize-master人脸检测部分参考了https://www.ilovematlab.cn/thread-201626-8-1.html
function varargout = charutupian(varargin)
% CHARUTUPIAN MATLAB code for charutupian.fig
%      CHARUTUPIAN, by itself, creates a new CHARUTUPIAN or raises the existing
%      singleton*.
%
%      H = CHARUTUPIAN returns the handle to a new CHARUTUPIAN or the handle to
%      the existing singleton*.
%
%      CHARUTUPIAN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CHARUTUPIAN.M with the given input arguments.
%
%      CHARUTUPIAN('Property','Value',...) creates a new CHARUTUPIAN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before charutupian_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to charutupian_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 charutupian% Last Modified by GUIDE v2.5 23-Jun-2020 22:26:13% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @charutupian_OpeningFcn, ...'gui_OutputFcn',  @charutupian_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before charutupian is made visible.
function charutupian_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 charutupian (see VARARGIN)% Choose default command line output for charutupian
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes charutupian wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = charutupian_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)
% 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)
% 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)
% varargout{1} = handles.output;% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, 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)
%拍照% Create a cascade detector object.global vidDeviceglobal imim = step(vidDevice);axes(handles.axes2);imshow(im);% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% 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)global vidDevice
vidDevice = imaq.VideoDevice('winvideo',1,'MJPG_1280x720') ;
hVideoIn = vision.VideoPlayer;
hVideoIn.Name  = 'Input Video';
hVideoOut = vision.VideoPlayer;
hVideoOut.Name  = 'Output Video';
faceDetector = vision.CascadeObjectDetector();
pointTracker = vision.PointTracker('MaxBidirectionalError', 2);
numPts = 0;
n = 0;
while(n<200)videoFrame = step(vidDevice);videoFrameOutput = videoFrame;videoFrameGray = rgb2gray(videoFrame);if numPts < 10% Detection mode.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;% Convert the rectangle represented as [x, y, w, h] into an% M-by-2 matrix of [x,y] coordinates of the four corners. This% is needed to be able to transform the bounding box to display% the orientation of the face.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.videoFrameOutput = insertShape(videoFrameOutput, 'Polygon', bboxPolygon, 'LineWidth', 3);% Display detected corners.videoFrameOutput = insertMarker(videoFrameOutput, xyPoints, '+', 'Color', 'white');endelse% 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.videoFrameOutput = insertShape(videoFrameOutput, 'Polygon', bboxPolygon, 'LineWidth', 3);% Display tracked points.videoFrameOutput = insertMarker(videoFrameOutput, visiblePoints, '+', 'Color', 'white');% Reset the points.oldPoints = visiblePoints;setPoints(pointTracker, oldPoints);endend% Display video.step(hVideoIn, videoFrame);step(hVideoOut, videoFrameOutput);n = n+1;
end
release(vidDevice);
release(hVideoOut);
release(hVideoIn);% --- 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)
global im                   %待识别图片
global reference
global W
global imgmean              %行均值向量
global col_of_data          %列数
global pathname
global img_path_list% 预处理新数据
im = double(im(:));
objectone = W'*(im - imgmean);
distance = 100000000;% 最小距离法,寻找和待识别图片最为接近的训练图片
for k = 1:col_of_data     %遍历每张图片temp = norm(objectone - reference(:,k));  %if(distance>temp)aimone = k;distance = temp;aimpath = strcat(pathname, '/', img_path_list(aimone).name);axes( handles.axes3 )imshow(aimpath)disp('识别成功')elsedisp('识别不成功')end
end
disp('完成')% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%训练机器
global reference
global W
global imgmean
global col_of_data
global pathname
global img_path_list% 批量读取指定文件夹下的图片
pathname = uigetdir;
img_path_list = dir(strcat(pathname,'\*.jpg'));
img_num = length(img_path_list);
imagedata = [];
if img_num >0for j = 1:img_numimg_name = img_path_list(j).name;temp = imread(strcat(pathname, '/', img_name));   %读取照片temp = double(temp(:));imagedata = [imagedata, temp];end
end
col_of_data = size(imagedata,2);   %返回列数% 中心化 & 计算协方差矩阵
imgmean = mean(imagedata,2);             %返回行均值向量
for i = 1:col_of_dataimagedata(:,i) = imagedata(:,i) - imgmean;
end
covMat = imagedata'*imagedata;
[COEFF, latent, explained] = pcacov(covMat);% 选择构成95%能量的特征值
i = 1;
proportion = 0;
while(proportion < 95)proportion = proportion + explained(i);i = i+1;
end
p = i - 1;   % 特征脸
W = imagedata*COEFF;    % N*M阶
W = W(:,1:p);           % N*p阶,选出最大的P个构成变换矩阵(1280X720)*P% 训练样本在新座标基下的表达矩阵 p*M
reference = W'*imagedata;
p
img_path_list
disp('训练好了')% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global W
global reference
col_of_data = 60;pathname = uigetdir;
img_path_list = dir(strcat(pathname,'\*.bmp'));
img_num = length(img_path_list);
testdata = [];
if img_num >0for j = 1:img_numimg_name = img_path_list(j).name;temp = imread(strcat(pathname, '/', img_name));temp = double(temp(:));testdata = [testdata, temp];end
end
col_of_test = size(testdata,2);
testdata = center( testdata );
object = W'* testdata;% 最小距离法,寻找和待识别图片最为接近的训练图片
% 计算分类器准确率
num = 0;
for j = 1:col_of_test;distance = 1000000000000;for k = 1:col_of_data;temp = norm(object(:,j) - reference(:,k));if(distance>temp)aimone = k;distance = temp;endendif ceil(j/3)==ceil(aimone/4)num = num + 1;end
end
accuracy = num/col_of_test;
msgbox(['分类器准确率:                   ',num2str(accuracy)],'accuracy')% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im;
[filename, pathname] = uigetfile({'*.jpg'},'choose photo');
p = [pathname, filename];
im = imread(p);
axes( handles.axes2);
imshow(im);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

基于matlab的自动人脸识别系统GUI设计相关推荐

  1. python人脸识别系统界面设计_基于卷积神经网络的人脸识别系统的设计(Python)

    基于卷积神经网络的人脸识别系统的设计(Python)(论文10000字,外文翻译,参考代码,流程图,人脸图像库) 摘要:随着社会的进步与发展,个人信息的保护变得十分重要.传统的密码保护方式已经不再满足 ...

  2. 使用gpu服务器搭建人脸识别系统,基于GPU的大规模人脸识别系统的设计与实现

    摘要: 近年来,随着基于深度学习的人脸识别技术的发展,成为了计算机视觉研究最热门的领域之一,被广泛的应用于公共安全.安防.金融等领域.但在实际应用场景中,人脸识别的准确率往往容易受到光线.遮挡.姿态等 ...

  3. 基于MATLAB的小波变换数字图像水印系统GUI设计与实现

    摘 要 通过对数字水印的原理和算法的分析,了解信息隐藏的实现手段与效果.在信息加载和提取过程中,突破传统的加密技术,用更具专业性的检测手段来保护专属的信息产权.本文利用了水印良好的鲁棒性和不可感知性, ...

  4. 基于MATLAB的人脸识别系统GUI

    基于MATLAB的人脸识别系统GUI,可以识别出不同表情的人脸 演示视频:[基于matlab人脸识别系统-哔哩哔哩] https://b23.tv/Pj8j0Uu 运行截图: 源码获取+卫星:DX52 ...

  5. 基于matlab的人脸五官边缘检测方法,基于MATLAB的人脸识别系统的设计

    基于MATLAB的人脸识别系统的设计(论文12000字,外文翻译,参考程序) 摘要:本文基于MATLAB平台设计了一款简单的人脸识别系统,通过USB摄像头来采集图像,经过肤色方法进行人脸检测与定位,然 ...

  6. 人脸识别系统 matlab,基于MATLAB的人脸识别系统的设计

    基于MATLAB的人脸识别系统的设计(论文12000字,外文翻译,参考程序) 摘要:本文基于MATLAB平台设计了一款简单的人脸识别系统,通过USB摄像头来采集图像,经过肤色方法进行人脸检测与定位,然 ...

  7. python dlib caffe人脸相似度_基于深度学习的人脸识别系统(Caffe+OpenCV+Dlib)【一】如何配置caffe属性表...

    前言 基于深度学习的人脸识别系统,一共用到了5个开源库:OpenCV(计算机视觉库).Caffe(深度学习库).Dlib(机器学习库).libfacedetection(人脸检测库).cudnn(gp ...

  8. 基于深度学习的人脸识别系统(Caffe+OpenCV+Dlib)【三】VGG网络进行特征提取

    前言 基于深度学习的人脸识别系统,一共用到了5个开源库:OpenCV(计算机视觉库).Caffe(深度学习库).Dlib(机器学习库).libfacedetection(人脸检测库).cudnn(gp ...

  9. 基于深度学习的人脸识别系统系列(Caffe+OpenCV+Dlib)——【六】设计人脸识别的识别类...

    前言 基于深度学习的人脸识别系统,一共用到了5个开源库:OpenCV(计算机视觉库).Caffe(深度学习库).Dlib(机器学习库).libfacedetection(人脸检测库).cudnn(gp ...

最新文章

  1. ROS编程: 一些Tips
  2. Apache Flink 零基础入门(二十)Flink kafka connector
  3. linux 删除乱码的文件夹,Linux服务器删除乱码文件和文件夹的方法
  4. esp32 micropython 加密_ESP32 MicroPython教程:使用SHA-256
  5. windows10完全删除mysql_Windows 10系统下彻底删除卸载MySQL的方法教程
  6. iPlayer惨遭破解诅咒AKAIO作者扬言要让它支持商业游戏
  7. 《Running.Lean.2nd.Edition.Feb.2012》 读书笔记
  8. mysql联合查询_mysql中的联合查询
  9. vue项目移动端、pc端适配方案(px转rem)
  10. android怎么取消安全模式,安卓手机安全模式怎么关闭
  11. MySql查询某一天的数据
  12. 王牌战争文明重启服务器维护,王牌战争文明重启攻略 新手开荒指南
  13. 更新后的哥德巴赫猜想(位运算)
  14. authorizationPolicy详解
  15. 【猛料】腾讯前总监受贿侵占数百万获刑9年
  16. 官方完整HL7 ECG-XML例子及注释翻译(1)
  17. 学java用什么电脑_学java用什么电脑比较好?电脑需要什么样的配置?
  18. 短信平台验证码的特点
  19. 阿piu传-文档批量上传客户端-道客巴巴版使用帮助
  20. oculus设备VR漫游

热门文章

  1. PDF Expert for mac v2.5.21中文激活版
  2. Scrum敏捷开发笔记
  3. Okular – 轻巧快速的跨平台文档阅读器
  4. “大数据”探路社区商业
  5. python+java+vue校园办公室报修管理系统#计算机毕业设计
  6. 电竞新时代,AGON爱攻II AG272FCX到底怎么样?
  7. 难点突破!5G+4K 超远距离影像实时交互传输怎么办?
  8. 技术报告:渗透测试分析
  9. matlab中如何从一个矩阵的行列中找出 0 元素的个数 或者位置 并作为判断条件
  10. jsp连接servlet配置web.xml