"""
名称:疲劳驾驶检测可视化界面
当前版本:v1.0
最后维护时间:2023.4.1
"""
from scipy.spatial import distance as dist
from imutils.video import VideoStream
from imutils import face_utils
from threading import Thread
from playsound import playsound
import numpy as np
import argparse
import imutils
import time
import dlib
import cv2
import math
import wx
import wx.xrc
import wx.adv
# 图片背景
COVER = 'D:/Drowsy_driving_dlib/picture/camera.png'
class Fatigue_detecting(wx.Frame):
def __init__(self, parent=None, id=-1, UpdateUI=None):
wx.Frame.__init__(self, parent, id=id, title='疲劳驾驶检测系统v1.0', pos=wx.DefaultPosition, size=wx.Size(900, 540),
style=wx.DEFAULT_DIALOG_STYLE | wx.TAB_TRAVERSAL)
self.UpdateUI = UpdateUI
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU)) # 底片背景颜色
# 控件
bSizer1 = wx.BoxSizer(wx.VERTICAL)
bSizer2 = wx.BoxSizer(wx.HORIZONTAL)
bSizer3 = wx.BoxSizer(wx.VERTICAL)
bSizer4 = wx.BoxSizer(wx.VERTICAL)
# 显示动画的静态控件,wx.adv.AnimationCtrl(self, wx.ID_ANY)
self.m_animCtrl1 = wx.adv.AnimationCtrl(self, wx.ID_ANY, wx.adv.NullAnimation, wx.DefaultPosition,
wx.DefaultSize, wx.adv.AC_DEFAULT_STYLE)
bSizer3.Add(self.m_animCtrl1, 1, wx.ALL | wx.EXPAND, 5)
bSizer2.Add(bSizer3, 9, wx.EXPAND, 5)
sbSizer1 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"参数设置"), wx.VERTICAL)
sbSizer2 = wx.StaticBoxSizer(wx.StaticBox(sbSizer1.GetStaticBox(), wx.ID_ANY, u"视频源"), wx.VERTICAL)
gSizer1 = wx.GridSizer(0, 2, 0, 8)
m_choice1Choices = [u"摄像头ID_0", u"摄像头ID_1", u"摄像头ID_2"]
# 可选择控件1——摄像头选择,笔记本电脑默认为0
self.m_choice1 = wx.Choice(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.Size(90, 25),
m_choice1Choices, 0)
self.m_choice1.SetSelection(0)
gSizer1.Add(self.m_choice1, 0, wx.ALL, 5)
# 开始检测控件
self.camera_button1 = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY, u"开始检测", wx.DefaultPosition,
wx.Size(90, 25), 0)
gSizer1.Add(self.camera_button1, 0, wx.ALL, 5)
# 可选择不打开摄像头进行录制视频处理
self.vedio_button2 = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY, u"打开视频文件", wx.DefaultPosition,
wx.Size(90, 25), 0)
gSizer1.Add(self.vedio_button2, 0, wx.ALL, 5)
# 停止播放控件
self.off_button3 = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY, u"暂停", wx.DefaultPosition, wx.Size(90, 25), 0)
gSizer1.Add(self.off_button3, 0, wx.ALL, 5)
sbSizer2.Add(gSizer1, 1, wx.EXPAND, 5)
sbSizer1.Add(sbSizer2, 2, wx.EXPAND, 5)
sbSizer3 = wx.StaticBoxSizer(wx.StaticBox(sbSizer1.GetStaticBox(), wx.ID_ANY, u"疲劳检测"), wx.VERTICAL)
bSizer5 = wx.BoxSizer(wx.HORIZONTAL)
self.yawn_checkBox1 = wx.CheckBox(sbSizer3.GetStaticBox(), wx.ID_ANY, u"打哈欠检测", wx.Point(-1, -1),
wx.Size(-1, 15), 0)
bSizer5.Add(self.yawn_checkBox1, 0, wx.ALL, 5)
self.blink_checkBox2 = wx.CheckBox(sbSizer3.GetStaticBox(), wx.ID_ANY, u"闭眼检测", wx.Point(-1, -1),
wx.Size(-1, 15), 0)
bSizer5.Add(self.blink_checkBox2, 0, wx.ALL, 5)
sbSizer3.Add(bSizer5, 1, wx.EXPAND, 5)
bSizer6 = wx.BoxSizer(wx.HORIZONTAL)
self.nod_checkBox7 = wx.CheckBox(sbSizer3.GetStaticBox(), wx.ID_ANY, u"点头检测", wx.Point(-1, -1), wx.Size(-1, 15),
0)
bSizer6.Add(self.nod_checkBox7, 0, wx.ALL, 5)
self.m_staticText1 = wx.StaticText(sbSizer3.GetStaticBox(), wx.ID_ANY, u"疲劳时间(秒):", wx.DefaultPosition,
wx.Size(-1, 15), 0)
self.m_staticText1.Wrap(-1)
bSizer6.Add(self.m_staticText1, 0, wx.ALL, 5)
m_listBox2Choices = [u"1", u"2", u"3", u"4", u"5", u"6"]
self.m_listBox2 = wx.ListBox(sbSizer3.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.Size(50, 24),
m_listBox2Choices, 0)
bSizer6.Add(self.m_listBox2, 0, 0, 5)
sbSizer3.Add(bSizer6, 1, wx.EXPAND, 5)
sbSizer1.Add(sbSizer3, 2, 0, 5)
sbSizer4 = wx.StaticBoxSizer(wx.StaticBox(sbSizer1.GetStaticBox(), wx.ID_ANY, u"驾驶位偏离检测"), wx.VERTICAL)
bSizer8 = wx.BoxSizer(wx.HORIZONTAL)
self.m_checkBox4 = wx.CheckBox(sbSizer4.GetStaticBox(), wx.ID_ANY, u"驾驶位偏离检测", wx.DefaultPosition,
wx.Size(-1, 15),
0)
bSizer8.Add(self.m_checkBox4, 0, wx.ALL, 5)
self.m_staticText2 = wx.StaticText(sbSizer4.GetStaticBox(), wx.ID_ANY, u"偏离时间(秒):", wx.DefaultPosition,
wx.Size(-1, 15), 0)
self.m_staticText2.Wrap(-1)
bSizer8.Add(self.m_staticText2, 0, wx.ALL, 5)
m_listBox21Choices = [u"5", u"10", u"15", u"20", u"25", u"30"]
self.m_listBox21 = wx.ListBox(sbSizer4.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.Size(50, 24),
m_listBox21Choices, 0)
bSizer8.Add(self.m_listBox21, 0, 0, 5)
sbSizer4.Add(bSizer8, 1, 0, 5)
sbSizer1.Add(sbSizer4, 1, 0, 5)
sbSizer5 = wx.StaticBoxSizer(wx.StaticBox(sbSizer1.GetStaticBox(), wx.ID_ANY, u"分析区域"), wx.VERTICAL)
bSizer9 = wx.BoxSizer(wx.HORIZONTAL)
self.m_staticText3 = wx.StaticText(sbSizer5.GetStaticBox(), wx.ID_ANY, u"检测区域: ", wx.DefaultPosition,
wx.DefaultSize, 0)
self.m_staticText3.Wrap(-1)
bSizer9.Add(self.m_staticText3, 0, wx.ALL, 5)
m_choice2Choices = [u"全视频检测", u"部分区域选取"]
self.m_choice2 = wx.Choice(sbSizer5.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
m_choice2Choices, 0)
self.m_choice2.SetSelection(0)
bSizer9.Add(self.m_choice2, 0, wx.ALL, 5)
sbSizer5.Add(bSizer9, 1, wx.EXPAND, 5)
sbSizer1.Add(sbSizer5, 1, 0, 5)
sbSizer6 = wx.StaticBoxSizer(wx.StaticBox(sbSizer1.GetStaticBox(), wx.ID_ANY, u"状态输出"), wx.VERTICAL)
self.m_textCtrl3 = wx.TextCtrl(sbSizer6.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY)
sbSizer6.Add(self.m_textCtrl3, 1, wx.ALL | wx.EXPAND, 5)
sbSizer1.Add(sbSizer6, 5, wx.EXPAND, 5)
bSizer4.Add(sbSizer1, 1, wx.EXPAND, 5)
bSizer2.Add(bSizer4, 3, wx.EXPAND, 5)
bSizer1.Add(bSizer2, 1, wx.EXPAND, 5)
self.SetSizer(bSizer1)
self.Layout()
self.Centre(wx.BOTH)
# 将各个按钮绑定事件,也就是将单独的几个程序联系到一起
self.image_cover = wx.Image(COVER, wx.BITMAP_TYPE_ANY)
self.bmp = wx.StaticBitmap(self.m_animCtrl1, -1, wx.Bitmap(self.image_cover))
self.icon = wx.Icon('D:/Drowsy_driving_dlib/picture/favicon.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(self.icon)
print("[提示]————界面初始化加载完成!")
# self.m_choice1.Bind(wx.EVT_CHOICE, self.cameraid_choice)
self.camera_button1.Bind(wx.EVT_BUTTON, self.camera_on)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Drowsy_driving.rar (21个子文件)
Drowsy_driving_dlib
picture
favicon.ico 9KB
camera.png 13KB
001.jpg 393KB
voice
alarm.wav 96KB
.idea
Drowsy_driving_dlib.iml 346B
workspace.xml 14KB
misc.xml 210B
inspectionProfiles
Project_Default.xml 2KB
profiles_settings.xml 174B
modules.xml 297B
.gitignore 184B
model
68 face landmarks.dat 95.08MB
main_app.py 578B
__pycache__
UI
xDialog.py 2KB
loginFrame.py 2KB
main_UI.py 24KB
__pycache__
guiManager.cpython-39.pyc 1KB
loginFrame.cpython-39.pyc 2KB
main_UI.cpython-39.pyc 13KB
xDialog.cpython-39.pyc 2KB
guiManager.py 749B
共 21 条
- 1
资源评论
物理系的计算机选手
- 粉丝: 1810
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- js-leetcode题解之173-binary-search-tree-iterator.js
- js-leetcode题解之172-factorial-trailing-zeroes.js
- js-leetcode题解之171-excel-sheet-column-number.js
- 安卓开发从入门到精通基础教程
- js-leetcode题解之170-two-sum-iii-data-structure-design.js
- (源码)基于Java和Python的垃圾图像分类系统.zip
- (源码)基于Spring Boot和Beetl的代码生成管理系统.zip
- (源码)基于低功耗设计的无线互呼通信系统.zip
- (源码)基于Arduino的盲人碰撞预警系统.zip
- 自己学习java安全的一些总结,主要是安全审计相关.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功