当前位置: 首页 > article >正文

pyQt5实现目标检测可视化001

pyQt5可视化

    • 1.实验目的
    • 2.实验环境搭建
    • 3.开始编写ui
    • 4.转为python程序
    • 5.运行窗口

1.实验目的

由于最近开题答辩,需要进行可视化展示,于是学习了qt5进行可视化界面展示,这个有点像web前端,也有点像vue,所以还是蛮好玩的,想深入学习的朋友建议多加看看B站等专门系统教学课程,少走弯路,祝学习进步,天天开心~

2.实验环境搭建

  • 深度学习环境搭建anaconda+pycharm+NVIDA显卡驱动+cuda+cudnn+ pytorch(一定要版本对应,不然bug一堆);
  • pyQt5安装移机三大工具配置,这个可以百度下,很简单;

3.开始编写ui

以一个程序为例

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>190</x>
      <y>45</y>
      <width>481</width>
      <height>61</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <family>黑体</family>
      <pointsize>26</pointsize>
     </font>
    </property>
    <property name="text">
     <string>智能动态视觉柜异物检测系统</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>800</width>
     <height>23</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

PS:记得把你的图片和你的qrc,以及*rc.py文件放一起
在这里插入图片描述

4.转为python程序

在这里插入图片描述
按照上方操作做即可,不需要自己专门去写python代码的,那些都是ui工程师做的,我们只需要在qtdesigner中布局好就ok.

5.运行窗口

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'MainWindow2.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import carbinet_rc
import exit_rc
import img1_rc
import jump_rc


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(857, 745)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setEnabled(True)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(40, 10, 551, 51))
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(36)
        self.label.setFont(font)
        self.label.setStyleSheet("color : rgb(255, 170, 255)\n"
"font: 17pt \"黑体\";")
        self.label.setObjectName("label")
        self.horizontalSlider = QtWidgets.QSlider(self.centralwidget)
        self.horizontalSlider.setGeometry(QtCore.QRect(70, 240, 160, 22))
        self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
        self.horizontalSlider.setObjectName("horizontalSlider")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(10, 240, 54, 12))
        self.label_2.setObjectName("label_2")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(280, 250, 141, 23))
        self.pushButton.setObjectName("pushButton")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(320, 80, 61, 20))
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(600, 80, 54, 12))
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(0, 160, 91, 31))
        self.label_5.setObjectName("label_5")
        self.toolButton_2 = QtWidgets.QToolButton(self.centralwidget)
        self.toolButton_2.setGeometry(QtCore.QRect(120, 170, 111, 18))
        self.toolButton_2.setObjectName("toolButton_2")
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setGeometry(QtCore.QRect(240, 120, 211, 121))
        self.label_6.setStyleSheet("background-color: rgb(85, 255, 255);")
        self.label_6.setText("")
        self.label_6.setObjectName("label_6")
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setGeometry(QtCore.QRect(530, 120, 211, 121))
        self.label_7.setStyleSheet("background-color: rgb(85, 255, 255);")
        self.label_7.setText("")
        self.label_7.setObjectName("label_7")
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setGeometry(QtCore.QRect(310, 290, 75, 23))
        self.pushButton_2.setObjectName("pushButton_2")
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setGeometry(QtCore.QRect(0, 300, 71, 16))
        self.label_8.setObjectName("label_8")
        self.horizontalSlider_2 = QtWidgets.QSlider(self.centralwidget)
        self.horizontalSlider_2.setGeometry(QtCore.QRect(70, 300, 160, 22))
        self.horizontalSlider_2.setOrientation(QtCore.Qt.Horizontal)
        self.horizontalSlider_2.setObjectName("horizontalSlider_2")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setGeometry(QtCore.QRect(760, 90, 75, 23))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/exit/exit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.pushButton_3.setIcon(icon)
        self.pushButton_3.setObjectName("pushButton_3")
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setGeometry(QtCore.QRect(0, -40, 871, 711))
        self.label_9.setText("")
        self.label_9.setPixmap(QtGui.QPixmap(":/img1/img1.jpg"))
        self.label_9.setObjectName("label_9")
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setGeometry(QtCore.QRect(100, 390, 121, 23))
        self.pushButton_4.setStyleSheet("icon:url(:/jump/jump.png)")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/jump/jump.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.pushButton_4.setIcon(icon1)
        self.pushButton_4.setObjectName("pushButton_4")
        self.label_10 = QtWidgets.QLabel(self.centralwidget)
        self.label_10.setGeometry(QtCore.QRect(20, 390, 61, 20))
        self.label_10.setObjectName("label_10")
        self.label_9.raise_()
        self.label.raise_()
        self.horizontalSlider.raise_()
        self.label_2.raise_()
        self.pushButton.raise_()
        self.label_3.raise_()
        self.label_4.raise_()
        self.label_5.raise_()
        self.toolButton_2.raise_()
        self.label_6.raise_()
        self.label_7.raise_()
        self.pushButton_2.raise_()
        self.label_8.raise_()
        self.horizontalSlider_2.raise_()
        self.pushButton_3.raise_()
        self.pushButton_4.raise_()
        self.label_10.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 857, 23))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)

        self.retranslateUi(MainWindow)
        self.pushButton_3.clicked.connect(MainWindow.close) # type: ignore
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label.setText(_translate("MainWindow", "智能视觉柜动态识别系统"))
        self.label_2.setText(_translate("MainWindow", "IOU:"))
        self.pushButton.setText(_translate("MainWindow", "上传图片/视频"))
        self.label_3.setText(_translate("MainWindow", "图片展示区"))
        self.label_4.setText(_translate("MainWindow", "识别结果"))
        self.label_5.setText(_translate("MainWindow", "请选择权重文件:"))
        self.toolButton_2.setText(_translate("MainWindow", "请选择权重文件"))
        self.pushButton_2.setText(_translate("MainWindow", "拍照"))
        self.label_8.setText(_translate("MainWindow", "Confidence:"))
        self.pushButton_3.setText(_translate("MainWindow", "退出系统"))
        self.pushButton_4.setText(_translate("MainWindow", "1.视频检测页面"))
        self.label_10.setText(_translate("MainWindow", "其他页面:"))

if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

在这里插入图片描述


http://www.kler.cn/a/449911.html

相关文章:

  • C/C++基础错题归纳
  • 【086】基于51单片机电子音乐门铃【Proteus仿真+Keil程序+报告+原理图】
  • taiwindcss
  • ChatGPT之父:奥尔特曼
  • Linux中的 read() 函数的介绍及使用实例
  • 代码随想录D24-25 回溯算法03-04 Python
  • 基于Spring Boot的旅游推荐系统
  • Linux下mysql 8.0安装教程
  • [LeetCode-Python版] 定长滑动窗口8——2461. 长度为 K 子数组中的最大和
  • Windows和Linux安全配置和加固
  • [Effective C++]条款38-39 复合和private继承
  • IT运维的365天--021 服务器上的dns设置后不起作用
  • aws(学习笔记第十九课) 使用ECS和Fargate进行容器开发
  • 云计算中的容器技术(如Docker)是什么?
  • 一些elasticsearch重要概念与配置参数
  • webview和H5来实现的android短视频(短剧)音视频播放依赖控件
  • 动手学深度学习11.2. 凸性-笔记练习(PyTorch)
  • 一篇文章学会HTML
  • 最适合智能体的身份认证技术:对比OpenID Connect、API keys、did:wba
  • 类class:继承类后同名方法是覆盖还是去哪了呢,类中this指向问题等
  • 汽车IVI中控开发入门及进阶(44):杰发科智能座舱芯片
  • 【CSS】优化动画性能
  • rk3568制冷项目驱动开发流程汇总(只适用于部分模块CIF DVP等,自用)
  • 【计算机视觉基础CV-图像分类】05 - 深入解析ResNet与GoogLeNet:从基础理论到实际应用
  • 【时间之外】IT人求职和创业应知【74】-运维机器人
  • 基于微信小程序的国产动漫论坛系统