【人脸识别】基于matlab GUI人脸实时检测与跟踪【含Matlab源码 673期】

举报
海神之光 发表于 2022/05/29 05:15:22 2022/05/29
1.9k+ 0 0
【摘要】 一、简介 如何在视频流中检测到人脸以及人脸追踪。对象检测和跟踪在许多计算机视觉应用中都很重要,包括活动识别,汽车安全和监视。所以这篇主要总结MATLAB的人脸检测和跟踪。 首先看一下流程。检测人脸——&...

一、简介

如何在视频流中检测到人脸以及人脸追踪。对象检测和跟踪在许多计算机视觉应用中都很重要,包括活动识别,汽车安全和监视。所以这篇主要总结MATLAB的人脸检测和跟踪。
首先看一下流程。检测人脸——>面部特征提取——>脸部追踪。

二、部分源代码

unction varargout = facedetecion(varargin)
% FACEDETECION MATLAB code for facedetecion.fig
%      FACEDETECION, by itself, creates a new FACEDETECION or raises the existing
%      singleton*.
%
%      H = FACEDETECION returns the handle to a new FACEDETECION or the handle to
%      the existing singleton*.
%
%      FACEDETECION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FACEDETECION.M with the given input arguments.
%
%      FACEDETECION('Property','Value',...) creates a new FACEDETECION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before facedetecion_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to facedetecion_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 facedetecion

% Last Modified by GUIDE v2.5 01-May-2017 19:18:42

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @facedetecion_OpeningFcn, ...
                   'gui_OutputFcn',  @facedetecion_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 facedetecion is made visible.
function facedetecion_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 facedetecion (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes facedetecion wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = facedetecion_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)
global myvideo myvideo1;
[fileName,pathName] = uigetfile('*.*','Please select an video');%文件筐,选择文件  
if(fileName)  
   fileName = strcat(pathName,fileName);  
   fileName = lower(fileName);%一致的小写字母形式  
else   
%   J = 0;%记录区域生长所分割得到的区域  
  msgbox('Please select an video');  
   return; %退出程序  
end  

% boxlnserter = vision.ShapeInserter('BorderColor','Custom','CustomBorderColor',[255 0 0]);
% videoOut = step(boxlnserter,videoFrame,bbox);
myvideo = VideoReader(fileName);
nFrames = myvideo.NumberOfFrames
vidHeight = myvideo.Height
vidWidth = myvideo.Width
mov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]);
 B_K = read(myvideo,1);
 axes(handles.axes1);
    imshow(B_K);
   
% myvideo = VideoReader(fileName);
% nFrames = myvideo.NumberOfFrames
% vidHeight = myvideo.Height
% vidWidth = myvideo.Width
% mov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]);
%  B_K = read(myvideo,1);
%     axes(handles.axes1);
%     imshow(B_K);
% --- 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)
global myvideo myvideo1;
nFrames = myvideo.NumberOfFrames
vidHeight = myvideo.Height
vidWidth = myvideo.Width
mov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]);
 faceDetector = vision.CascadeObjectDetector();
% videoFileReader = vision.VideoFileReader(fileName);
% videoFrame = step(videoFileReader);

  
 

三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]孟逸凡,柳益君.基于PCA-SVM的人脸识别方法研究[J].科技视界. 2021,(07)
[6]张娜,刘坤,韩美林,陈晨.一种基于PCA和LDA融合的人脸识别算法研究[J].电子测量技术. 2020,43(13)
[7]陈艳.基于BP神经网络的人脸识别方法分析[J].信息与电脑(理论版). 2020,32(23)
[8]戴骊融,陈万米,郭盛.基于肤色模型和SURF算法的人脸识别研究[J].工业控制计算机. 2014,27(02)

文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。

原文链接:qq912100926.blog.csdn.net/article/details/115387757

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

作者其他文章

评论(0

抱歉,系统识别当前为高风险访问,暂不支持该操作

    全部回复

    上滑加载中

    设置昵称

    在此一键设置昵称,即可参与社区互动!

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。