spidermanYT 1 rok pred
rodič
commit
f08f3e1a8e

+ 1 - 0
day05/jkapp/app.bat

@@ -0,0 +1 @@
+python main.py

BIN
day05/jkapp/dev/__pycache__/camera.cpython-39.pyc


+ 20 - 0
day05/jkapp/dev/camera.py

@@ -0,0 +1,20 @@
+from PyQt5.QtCore import QThread
+import cv2
+# from cv2 import VideoCapture
+from PyQt5.QtCore import pyqtSignal
+class CameraDev(QThread):
+    sig_video = pyqtSignal(bytes,int,int,int)
+    def __init__(self):
+        super(CameraDev, self).__init__()
+        self.cam = cv2.VideoCapture(
+            0,cv2.CAP_DSHOW
+        )
+
+    def run(self):
+        while True:
+            # print("设备准备工作!")
+            status, img = self.cam.read()
+            if status:
+                # print(img.shape)
+                self.sig_video.emit(img.tobytes(),img.shape[0],img.shape[1],img.shape[2])
+            QThread.usleep(100000)

BIN
day05/jkapp/frame/__pycache__/app.cpython-39.pyc


BIN
day05/jkapp/frame/__pycache__/win.cpython-39.pyc


+ 7 - 0
day05/jkapp/frame/app.py

@@ -0,0 +1,7 @@
+from PyQt5.QtWidgets import QApplication
+from frame.win import Win
+class App(QApplication):
+    def __init__(self):
+        super(App,self).__init__([])
+        self.win = Win()
+        self.win.show()

+ 22 - 0
day05/jkapp/frame/win.py

@@ -0,0 +1,22 @@
+from PyQt5.QtWidgets import QDialog
+from PyQt5.QtGui import QImage
+from PyQt5.QtGui import QPixmap
+from ui.traffic_ui import Ui_traffic
+from dev.camera import CameraDev
+
+class Win(QDialog):
+    def __init__(self):
+        super(Win,self).__init__()
+        self.ui = Ui_traffic()
+        self.ui.setupUi(self)
+        self.dev = CameraDev()
+        self.dev.start()
+
+        self.dev.sig_video.connect(self.showVideo)
+
+    def showVideo(self,data,h,w,c):
+        #print("(",h,",",w,",",c,")")   
+        q_img = QImage(data, w, h, w * c,QImage.Format_BGR888)  
+        pix_img = QPixmap.fromImage(q_img)
+        self.ui.duo.setPixmap(pix_img)
+        self.ui.duo.setScaledContents(True)

+ 4 - 0
day05/jkapp/main.py

@@ -0,0 +1,4 @@
+from frame.app import App
+
+app =App()
+app.exec()

BIN
day05/jkapp/ui/__pycache__/traffic_ui.cpython-39.pyc


+ 3 - 0
day05/jkapp/ui/tools.bat

@@ -0,0 +1,3 @@
+
+@rem
+@pyuic5 -o traffic_ui.py traffic.ui

+ 48 - 0
day05/jkapp/ui/traffic.ui

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>traffic</class>
+ <widget class="QDialog" name="traffic">
+  <property name="windowModality">
+   <enum>Qt::ApplicationModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>智能交通监控系统</string>
+  </property>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>190</y>
+     <width>75</width>
+     <height>23</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>PushButton</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="duo">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>50</y>
+     <width>201</width>
+     <height>121</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>TextLabel</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 33 - 0
day05/jkapp/ui/traffic_ui.py

@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'traffic.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
+
+
+class Ui_traffic(object):
+    def setupUi(self, traffic):
+        traffic.setObjectName("traffic")
+        traffic.setWindowModality(QtCore.Qt.ApplicationModal)
+        traffic.resize(400, 300)
+        self.pushButton = QtWidgets.QPushButton(traffic)
+        self.pushButton.setGeometry(QtCore.QRect(160, 190, 75, 23))
+        self.pushButton.setObjectName("pushButton")
+        self.duo = QtWidgets.QLabel(traffic)
+        self.duo.setGeometry(QtCore.QRect(110, 50, 201, 121))
+        self.duo.setObjectName("duo")
+
+        self.retranslateUi(traffic)
+        QtCore.QMetaObject.connectSlotsByName(traffic)
+
+    def retranslateUi(self, traffic):
+        _translate = QtCore.QCoreApplication.translate
+        traffic.setWindowTitle(_translate("traffic", "智能交通监控系统"))
+        self.pushButton.setText(_translate("traffic", "PushButton"))
+        self.duo.setText(_translate("traffic", "TextLabel"))

+ 32 - 0
day05/jkapp/ui/untitled.ui

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>智能交通监控系统</string>
+  </property>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>110</y>
+     <width>121</width>
+     <height>61</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>PushButton</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>