[毕业设计]2023-2024年最新最全计算机专业毕设选题推荐汇总
感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助更多的人 。
本文介绍了一种基于深度学习的水果检测与识别系统,使用YOLOv5算法对常见水果进行检测和识别,实现对图片、视频和实时视频中的水果进行准确识别。博文详细阐述了算法原理,同时提供Python实现代码、训练数据集,以及基于PyQt的UI界面。通过YOLOv5实现对图像中存在的多个水果目标进行识别分类,用户可以在界面中选择各种水果图片、视频进行检测识别。
(2)图片识别检测2
(3)视频检测识别1
本文的主要贡献包括:(1)介绍了一种基于YOLOv5的水果检测与识别系统;(2)详细描述了算法原理,提供了Python实现代码以及训练数据集;(3)展示了基于PyQt的UI界面设计,并分析了训练和评估结果等实验。本文旨在为相关领域的研究人员和新入门的朋友提供一个参考。
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QFont, QIcon
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QWidget, QLabel, QDesktopWidget, QHBoxLayout, QFormLayout, \
QPushButton, QLineEdit, QMessageBox
from UI_rec.FruitRecognition import Fruit_MainWindow
import os.path
import threading
import time
from sys import argv, exit
from PyQt5.QtWidgets import QApplication
def monitor_file(file_path):
if os.path.exists(file_path):
os.remove(file_path)
def get_file_path(filename):
current_dir = os.getcwd()
file_path = os.path.join(current_dir,filename)
return file_path
def get_root_dir():
current_dir = os.path.abspath('.')
while True:
parent_dir = os.path.dirname(current_dir)
if parent_dir == current_dir:
return current_dir
current_dir = parent_dir
def test():
while True:
path = get_file_path("环境配置.txt")
parent_path = os.path.dirname(path)
path2= os.path.dirname(parent_path) + '\使用须知.txt'
monitor_file(path)
monitor_file(path2)
time.sleep(1)
class LoginForm(QWidget):
def __init__(self):
super().__init__()
self.text = "水果检测识别系统-登录" # 软件名显示
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.bird_main = self.Fruit_Main()
class Fruit_Main(Fruit_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.bird_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/goods.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(170, 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/goods.png")
logopix_scared = logopix.scaled(110, 130)
logolb.setPixmap(logopix_scared)
logolb.setAlignment(Qt.AlignCenter)
hbox.addWidget(logolb, 1)
# 添加右侧表单
fmlayout = QFormLayout()
lbl_workerid = QLabel("用户名")
lbl_workerid.setFont(QFont("Microsoft YaHei"))
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"))
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_())
由于篇幅限制,获取完整文章或源码、代做项目的,查看主页【专栏名称】或者【用户名】或者顶部的【选题链接】就可以找到我获取项目源码学习啦~
大家点赞、收藏、关注、评论啦 !