
【人脸识别】基于matlab GUI人脸实时检测与跟踪【含Matlab源码 673期】
发布日期:2021-05-07 13:13:52
浏览次数:21
分类:原创文章
本文共 4846 字,大约阅读时间需要 16 分钟。
一、简介
如何在视频流中检测到人脸以及人脸追踪。对象检测和跟踪在许多计算机视觉应用中都很重要,包括活动识别,汽车安全和监视。所以这篇主要总结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 EDITgui_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});endif 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 facedetecionhandles.output = hObject;% Update handles structureguidata(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 structurevarargout{ 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.NumberOfFramesvidHeight = myvideo.HeightvidWidth = myvideo.Widthmov(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.NumberOfFramesvidHeight = myvideo.HeightvidWidth = myvideo.Widthmov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]); faceDetector = vision.CascadeObjectDetector();% videoFileReader = vision.VideoFileReader(fileName);% videoFrame = step(videoFileReader);
三、运行结果
四、备注
完整代码或者咨询添加QQ 1564658423
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年03月27日 19时01分48秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
JS数据类型的判断
2021-05-07
Vue面试题总结
2021-05-07
实现一个简易Vue(三)Compiler
2019-03-04
仿小米商城(上)
2019-03-04
仿小米商城(下)
2019-03-04
C#成神之路<10> C#代码中制定决策
2019-03-04
C#成神之路<11> C#循环重复语句
2019-03-04
C#成神之路<17> C#使用磁盘数据文件(1)
2019-03-04
C#成魔之路<2>Windows 应用程序高级控件(2)
2019-03-04
textarea文本框根据输入内容多少自适应高度
2019-03-04
【30】kotlin 闭包
2019-03-04
【46】kotlin 集合框架
2019-03-04
【47】kotlin IO操作
2019-03-04
【55】Kotlin android Anko 神兵利器2
2019-03-04
git忽略规则以及.gitignore文件不生效解决办法
2019-03-04
文件md5怎么会变化
2019-03-04
tablayout 滑动监听
2019-03-04
ViewModel LiveData 使用初体验
2019-03-04
Error connecting to the service protoco
2019-03-04