资源简介
MATLAB编写程序,通过人眼检测来判断是否疲劳驾驶。有界面,亲测可用

代码片段和文件信息
clc;
clear all;
close all;
%%
load DB
load svm
cl = {‘open‘‘close‘};
dim = [30 60;
30 60
40 65];
delete(imaqfind)
vid=webcam();
videoframe = snapshot(vid);
frameSize = size(videoframe);
videoPlayer = vision.VideoPlayer(‘Position‘ [100 100 [frameSize(2) frameSize(1)]+30]);
% 定位眼睛和嘴
faceDetector = vision.CascadeobjectDetector;
faceDetectorLeye = vision.CascadeobjectDetector(‘EyePairBig‘);
faceDetectorM = vision.CascadeobjectDetector(‘Mouth‘);
tic% 保存当前时间,开始计时
% 初始向量
LC = 0;
RC = 0;
MC = 0;
TF = 0;
TC = 0;
Feature = [];
c1p = 1;
species = ‘Non-Fatigue‘;%识别疲劳与否
for ii = 1:600 %设置频率为600帧
im=snapshot(vid); % 采集图片
imshow(im)
subplot(34[1 2 5 6 9 10]);
imshow(im)
%脸部定位
bbox = step(faceDetector im);
if ~isempty(bbox);
bbox = bbox(1:);%循环,直到检测成功
% 画框
rectangle(‘Position‘bbox‘edgecolor‘‘r‘);
S = skin_seg2(im);
% 分离皮肤区域
bw3 = cat(3SSS);
% 原始图像与输出结果相乘
Iss = double(im).*bw3;
Ic = imcrop(imbbox);
Ic1 = imcrop(Issbbox);%剪切
subplot(34[3 4]);
imshow(uint8(Ic1))
bboxeye = step(faceDetectorLeye Ic); %同理定位眼睛
if ~isempty(bboxeye);
bboxeye = bboxeye(1:);
Eeye = imcrop(Icbboxeye);
%画框
rectangle(‘Position‘bboxeye‘edgecolor‘‘y‘);
else
disp(‘Eyes not detected Please adapt to your posion‘)%输出
end
if isempty(bboxeye)
continue;%循环
end
Ic(1:bboxeye(2)+2*bboxeye(4)::) = 0;
% 同理定位嘴
bboxM = step(faceDetectorM Ic);
if ~isempty(bboxM);
bboxMtemp = bboxM;
if ~isempty(bboxMtemp)
bboxM = bboxMtemp(1:);
Emouth = imcrop(IcbboxM);
% 画框
rectangle(‘Position‘bboxM‘edgecolor‘‘y‘);
else
disp(‘Mouth not detected Please adapt your posion‘)
continue;
end
else
disp(‘Mouth not detected‘)
continue;
end
[nrencek ] = size(Eeye);
Leye = Eeye(:1:round(nce/2):);
Reye = Eeye(:round(nce/2+1):end:);
subplot(347)
imshow(edge(rgb2gray(Leye)‘sobel‘));%sobel边缘算子
subplot(348)
imshow(edge(rgb2gray(Reye)‘sobel‘));
Emouth3 = Emouth;
Leye = rgb2gray(Leye);
Reye = rgb2gray(Reye);
Emouth = rgb2gray(Emouth);
X = Emouth(:);
[nr1 nc1 ] = size(Emouth);
cid = kmeans(double(X)2‘emptyaction‘‘drop‘);
kout = reshape(cidnr1nc1); %调整矩阵
subplot(34[1112]);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 509 2017-06-06 14:18 match_DB.m
文件 152 2019-08-07 22:35 readme.txt
文件 495 2017-06-06 14:17 skin_seg2.m
文件 1119 2016-11-01 22:05 svm.mat
文件 185709 2016-11-01 22:05 DB.mat
文件 4935 2017-06-06 13:50 main.m
----------- --------- ---------- ----- ----
192919 6
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论