[毕业设计]2023-2024年最新最全计算机专业毕设选题推荐汇总
基于YOLOv5的疲劳驾驶检测系统使用深度学习技术检测常见驾驶图片、视频和实时视频中的疲劳行为,识别其闭眼、打哈欠等结果并记录和保存,以防止交通事故发生。本文详细介绍疲劳驾驶检测系统实现原理的同时,给出Python的实现代码、训练数据集以及PyQt的UI界面。在界面中可以选择各种图片、视频进行检测识别,可对图像中存在的多个目标进行识别分类。
(1)检测平台首页
基于YOLOv5的疲劳驾驶检测系统应用深度学习技术检测常见驾驶过程中可能存在的疲劳驾驶行为,包括闭眼、打哈欠、正常等常见行为,以方便对驾驶员的安全驾驶进行监测分析;系统采用登录注册进行用户管理;对于图片、视频和摄像头捕获的实时画面,系统可检测画面中的疲劳驾驶行为;系统支持结果记录、展示和保存,每次检测的结果记录在表格中。对此这里给出博主设计的界面,同款的简约风,功能也可以满足图片、视频和摄像头的识别检测,
# -*- coding: utf-8 -*-
"""
运行主程序:DrowsinessLoginUI.py (包含登录界面)
"""
import os
import sys
import os.path
import threading
import time
from sys import argv, exit
from PyQt5.QtWidgets import QApplication
from DrowsinessDetecting import Drowsiness_MainWindow
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QFont, QIcon
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtWidgets import QWidget, QLabel, QDesktopWidget, QHBoxLayout, QFormLayout, \
QPushButton, QLineEdit, QMessageBox
from UI_rec.DrowsinessDetecting import Drowsiness_MainWindow
class LoginForm(QWidget):
def __init__(self):
super().__init__()
self.text = "基于YOLOv5的疲劳驾驶检测系统"
self.led_workerid = QLineEdit()
self.led_pwd = QLineEdit()
self.btn_login = QPushButton("登录")
self.btn_reg = QPushButton("注册")
self.initUI()
self.btn_login.clicked.connect(self.do_login)
self.btn_reg.clicked.connect(self.do_reg)
self.pwd_name_ini = {"admin": "123456", "test": "123456"}
self.sign_main = self.Drowsiness_Main()
class Drowsiness_Main(Drowsiness_MainWindow):
pass
def do_reg(self):
name_edit = self.led_workerid.text()
pwd_edit = self.led_pwd.text()
if name_edit != "" and pwd_edit != "":
if name_edit not in self.pwd_name_ini.keys():
self.pwd_name_ini.update({name_edit: pwd_edit})
QMessageBox.about(self, "注册信息",
"用户 " + name_edit + " 已注册成功!\n\n请重新进入登录界面")
else:
QMessageBox.about(self, "注册信息",
"用户 " + name_edit + " 已经被注册过!\n\n请重新输入用户信息")
else:
QMessageBox.about(self, "注册信息",
"您的信息填写不全!\n请重新输入用户名和密码")
def do_login(self):
name_edit = self.led_workerid.text()
pwd_edit = self.led_pwd.text()
if name_edit != "" and pwd_edit != "":
if name_edit in self.pwd_name_ini.keys():
ini_pwd = self.pwd_name_ini[name_edit]
if pwd_edit == ini_pwd:
# QMessageBox.about(self, "登录信息",
# "用户 " + name_edit + " 已成功登录!\n\n点击确定启动界面程序")
# self.close()
# QtWidgets.QApplication.processEvents()
# os.system("python runMain.py")
self.hide()
# win = Bird_MainWindow()
self.sign_main.show()
else:
QMessageBox.about(self, "登录信息",
"用户 " + name_edit + " 密码不正确!\n\n请重新输入密码")
else:
QMessageBox.about(self, "登录信息",
"用户 " + name_edit + " 未经过注册!\n\n请重新输入用户信息")
else:
QMessageBox.about(self, "登录信息",
"您的信息填写不全!\n请重新输入用户名和密码")
def initUI(self):
"""
初始化UI
:return:
"""
self.setObjectName("loginWindow")
self.setStyleSheet('#loginWindow{background-color:white}')
self.setFixedSize(650, 400)
self.setWindowTitle("登录-")
self.setWindowIcon(QIcon('icons/sign.png'))
# 添加顶部logo图片
pixmap = QPixmap("icons/back.png")
scaredPixmap = pixmap.scaled(650, 180)
label = QLabel(self)
label.setPixmap(scaredPixmap)
# 绘制顶部文字
lbl_logo = QLabel(self)
lbl_logo.setText(self.text)
lbl_logo.setStyleSheet("QWidget{color:white;font-weight:600;background: transparent;font-size:30px;}")
lbl_logo.setFont(QFont("Microsoft YaHei"))
lbl_logo.move(100, 70)
lbl_logo.setAlignment(Qt.AlignCenter)
lbl_logo.raise_()
# 登录表单内容部分
login_widget = QWidget(self)
login_widget.move(0, 160)
login_widget.setGeometry(0, 160, 650, 260)
hbox = QHBoxLayout()
# 添加左侧logo
logolb = QLabel(self)
logopix = QPixmap("icons/sign.png")
logopix_scared = logopix.scaled(130, 130)
logolb.setPixmap(logopix_scared)
logolb.setAlignment(Qt.AlignCenter)
hbox.addWidget(logolb, 1)
# 添加右侧表单
fmlayout = QFormLayout()
lbl_workerid = QLabel("用户名:")
lbl_workerid.setFont(QFont("Microsoft YaHei"))
lbl_workerid.setStyleSheet("color:blue")
self.led_workerid.setFixedWidth(270)
self.led_workerid.setFixedHeight(38)
self.led_workerid.setFont(QFont("Microsoft YaHei"))
self.led_workerid.setPlaceholderText("用户名/账号")
lbl_pwd = QLabel("密 码:")
lbl_pwd.setFont(QFont("Microsoft YaHei"))
lbl_pwd.setStyleSheet("color:blue")
self.led_pwd.setEchoMode(QLineEdit.Password)
self.led_pwd.setFixedWidth(270)
self.led_pwd.setFixedHeight(38)
self.led_pwd.setFont(QFont("Microsoft YaHei"))
self.led_pwd.setPlaceholderText("密码")
self.btn_reg.setFixedWidth(130)
self.btn_reg.setFixedHeight(40)
self.btn_reg.setFont(QFont("Microsoft YaHei"))
self.btn_reg.setObjectName("reg_btn")
# btn_reg.setStyleSheet("#reg_btn{background-color:#2c7adf;color:#fff;border:5px;border-radius:4px;}")
self.btn_login.setFixedWidth(130)
self.btn_login.setFixedHeight(40)
self.btn_login.setFont(QFont("Microsoft YaHei"))
self.btn_login.setObjectName("login_btn")
fmlayout.addRow(lbl_workerid, self.led_workerid)
fmlayout.addRow(lbl_pwd, self.led_pwd)
# fmlayout.addWidget(btn_login)
flyout2 = QHBoxLayout()
flyout2.addWidget(self.btn_reg)
flyout2.addWidget(self.btn_login)
fmlayout.addItem(flyout2)
# flyout2.setHorizontalSpacing(20)
flyout2.setSpacing(12)
hbox.setAlignment(Qt.AlignCenter)
# 调整间距
fmlayout.setHorizontalSpacing(20)
fmlayout.setVerticalSpacing(12)
hbox.addLayout(fmlayout, 2)
login_widget.setLayout(hbox)
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = LoginForm()
ex.show()
sys.exit(app.exec_())
由于篇幅限制,获取完整文章或源码、代做项目的,查看主页【专栏名称】或者【用户名】或者顶部的【选题链接】就可以找到我获取项目源码学习啦~
大家点赞、收藏、关注、评论啦 !