项目总结:window QT 开发 yolov5目标检测 UI界面

代码可以看参考文:

Qt + OpenCV 部署yolov5_SongpingWang的博客-CSDN博客

一、UI设计

搞清楚QSplitter 和 Layouts ,也就是布局管理

Qt布局之QSplitter_qsplitter 样式_Quz的博客-CSDN博客

06-layouts, tabs and buddies | Qt布局 选项卡切换 和伙伴关 | 双字幕 | 国外视频

二、搞清除信号与槽函数的连接

1、用connect函数进行连接信号与槽函数

2、点击按钮转槽,不需要用connect函数连接点击信号与槽函数

 3、自己编写槽函数时候,按一定规则命名

Qt信号和槽不用connect的情况_zhanghongxia1111的博客-CSDN博客

 4、效果展示

 打开文件;加载模型

 点击开始检测

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用 PyQT5 实现 Qt 界面链接 YOLOv5 目标检测的 Python 代码示例: ```python import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QFileDialog from PyQt5.QtGui import QPixmap import cv2 from yolov5.detect import YOLOv5Detector class App(QWidget): def __init__(self): super().__init__() self.title = 'YOLOv5 Object Detection' self.left = 50 self.top = 50 self.width = 640 self.height = 480 self.image_path = '' self.initUI() def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) # 选择图像文件按钮 self.select_button = QPushButton('Select Image', self) self.select_button.move(20, 20) self.select_button.clicked.connect(self.select_image) # 显示图像 self.image_label = QLabel(self) self.image_label.move(20, 60) self.image_label.resize(600, 400) # 检测目标按钮 self.detect_button = QPushButton('Detect Objects', self) self.detect_button.move(20, 470) self.detect_button.clicked.connect(self.detect_objects) self.show() def select_image(self): options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog file_name, _ = QFileDialog.getOpenFileName(self, 'Select Image', '', 'Images (*.png *.xpm *.jpg *.bmp *.gif)', options=options) if file_name: self.image_path = file_name pixmap = QPixmap(file_name) self.image_label.setPixmap(pixmap) self.image_label.setScaledContents(True) def detect_objects(self): if not self.image_path: return detector = YOLOv5Detector() image = cv2.imread(self.image_path) result_image, _ = detector.detect(image) cv2.imwrite('result.jpg', result_image) pixmap = QPixmap('result.jpg') self.image_label.setPixmap(pixmap) self.image_label.setScaledContents(True) if __name__ == '__main__': app = QApplication(sys.argv) ex = App() sys.exit(app.exec_()) ``` 其中 `yolov5.detect` 模块的代码可以参考 YOLOv5 的官方实现。在 `detect` 函数中,需要对输入的图像进行目标检测,并返回检测结果。在本例中,我们将检测结果保存为 `result.jpg`,并在界面中显示出来。 注意,需要将模型文件和权重文件放在适当的位置,并在 `YOLOv5Detector` 类中设置正确的路径。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值