zw996 1 год назад
Родитель
Сommit
3cb2d48d02

BIN
day04/monitor/dev/__pycache__/camera.cpython-38.pyc


+ 1 - 1
day04/monitor/dev/camera.py

@@ -19,4 +19,4 @@ class CameraDev(QThread):
             print("视频处理")
             QThread.usleep(100000)
         #self.camera.close() #关闭摄像头
-        #self.camera.release() #释放设备
+        #self.camera.release() #释放设备

BIN
day04/monitor/form/__pycache__/app.cpython-38.pyc


BIN
day04/monitor/form/__pycache__/win.cpython-38.pyc


+ 1 - 2
day04/monitor/form/app.py

@@ -6,5 +6,4 @@ class App(QApplication):
         super(App,self).__init__([])   #调用父类构造器,完成初始化
         self.win = Win()
         self.win.resize(500, 500)
-        self.win.show()
-
+        self.win.show()

+ 1 - 1
day04/monitor/form/win.py

@@ -17,4 +17,4 @@ class Win(QDialog):   #w我们实现的win扩展QDialog(新增,重载与覆
 
         self.dev = CameraDev()
 
-        self.dev.start()
+        self.dev.start()

+ 3 - 0
day05/.idea/.gitignore

@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml

+ 8 - 0
day05/.idea/day05.iml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
day05/.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 4 - 0
day05/.idea/misc.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
day05/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/day05.iml" filepath="$PROJECT_DIR$/.idea/day05.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
day05/.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>

BIN
day05/aiapp/dev/__pycache__/camera.cpython-38.pyc


+ 29 - 0
day05/aiapp/dev/camera.py

@@ -0,0 +1,29 @@
+from PyQt5.QtCore import QThread
+import cv2
+class CameraDev(QThread):
+    def __init__(self):
+        super(CameraDev, self).__init__()
+        # 1.打开摄像头
+        self.camera = cv2.VideoCapture(0,cv2.CAP_DSHOW)  #摄像头编号从0开始
+        self.isSave = False
+
+
+    #线程的任务
+    def run(self):
+        #摄像头的操作
+        # 1.打开摄像头
+        while True:
+            # 2.循环抓取视频帧
+            status,img = self.camera.read()
+            print(status,img.shape)
+            if status:
+                img = cv2.cvtColor(img,cv2.COLOR_RGB2BGR)
+                if not self.isSave:
+                    cv2.imwrite("2.jpg",img)
+                    self.isSave = True
+
+            # 3.显示到窗体
+            print("视频处理")
+            QThread.usleep(100000)
+        #self.camera.close() #关闭摄像头
+        #self.camera.release() #释放设备

BIN
day05/aiapp/frame/__pycache__/app.cpython-38.pyc


BIN
day05/aiapp/frame/__pycache__/win.cpython-38.pyc


+ 10 - 0
day05/aiapp/frame/app.py

@@ -0,0 +1,10 @@
+from PyQt5.QtWidgets import QApplication
+from aiapp.frame.win import Win
+#from monitor.form.win import Win
+class App(QApplication):
+    def __init__(self):
+        super(App,self).__init__([])   #调用父类构造器,完成初始化
+        self.win = Win()
+        self.win.resize(500, 500)
+        self.win.show()
+

+ 20 - 0
day05/aiapp/frame/win.py

@@ -0,0 +1,20 @@
+from PyQt5.QtWidgets import  QDialog
+
+from aiapp.ui.jiankong_ui import Ui_Dialog
+from aiapp.dev.camera import CameraDev
+
+class Win(QDialog):   #w我们实现的win扩展QDialog(新增,重载与覆盖over load)
+    def __init__(self):   #构造器
+        #完成数据初始化(类的实例化:对象)
+        #pass    #空语言(ui对象化)
+        super(Win, self).__init__()
+
+        self.ui = Ui_Dialog()
+
+        # 把ui绑定在Win对话框上面
+
+        self.ui.setupUi(self)
+
+        self.dev = CameraDev()
+
+        self.dev.start()

+ 23 - 0
day05/aiapp/main.py

@@ -0,0 +1,23 @@
+from aiapp.frame.app import App
+
+# pyuic5 -o monitor_ui.py monitor.ui
+# -o表示输出
+# monitor_ui.py表示输出文件,可以随意命名
+
+# monitor.ui我们设计的界面文件。这个文件只能翻译以后使用。
+
+# pyuic5是一个把ui文件翻译成py文件的工具
+
+app = App()
+app.exec()
+
+"""
+Python 搜索路径:处理
+    1.内部管理
+        包路径   .分割每个目录(相对路径)
+            python把工程路径设置为根路径,包的路径从根路径开始
+            from 包路径1.包路径 2. import 类 #相对绝对路径
+            from .模块 import 类
+    2.外部管理
+
+"""

BIN
day05/aiapp/ui/__pycache__/jiankong_ui.cpython-38.pyc


+ 109 - 0
day05/aiapp/ui/jiankong.ui

@@ -0,0 +1,109 @@
+<?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>627</width>
+    <height>560</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>智能交通监控系统</string>
+  </property>
+  <property name="sizeGripEnabled">
+   <bool>false</bool>
+  </property>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>140</y>
+     <width>441</width>
+     <height>241</height>
+    </rect>
+   </property>
+   <property name="styleSheet">
+    <string notr="true">border-width:2px;
+border-style:solid;
+border-color:blue;
+border-radius:10px;
+border-top-color:red;
+border-bottom-color:green;
+border-left-color:pink;
+border-right-color:black;</string>
+   </property>
+   <property name="text">
+    <string>TextLabel</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>140</x>
+     <y>460</y>
+     <width>75</width>
+     <height>23</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>抓取图像</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>100</x>
+     <y>50</y>
+     <width>241</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="font">
+    <font>
+     <family>Aparajita</family>
+     <pointsize>20</pointsize>
+    </font>
+   </property>
+   <property name="text">
+    <string>智能交通监控系统</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>500</x>
+     <y>190</y>
+     <width>54</width>
+     <height>12</height>
+    </rect>
+   </property>
+   <property name="styleSheet">
+    <string notr="true">border-width:1px;
+border-style:dotted;
+border-color:blue;
+</string>
+   </property>
+   <property name="text">
+    <string>识别信息</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="jiankong">
+   <property name="geometry">
+    <rect>
+     <x>500</x>
+     <y>240</y>
+     <width>101</width>
+     <height>121</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>显示信息</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 40 - 0
day05/aiapp/ui/jiankong_ui.py

@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'jiankong.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_Dialog(object):
+    def setupUi(self, Dialog):
+        Dialog.setObjectName("Dialog")
+        Dialog.resize(504, 470)
+        self.label = QtWidgets.QLabel(Dialog)
+        self.label.setGeometry(QtCore.QRect(30, 20, 441, 241))
+        self.label.setStyleSheet("border-width:2px;\n"
+"border-style:solid;\n"
+"border-color:blue;\n"
+"border-radius:10px;\n"
+"border-top-color:red;\n"
+"border-bottom-color:green;\n"
+"border-left-color:pink;\n"
+"border-right-color:black;")
+        self.label.setObjectName("label")
+        self.pushButton = QtWidgets.QPushButton(Dialog)
+        self.pushButton.setGeometry(QtCore.QRect(180, 360, 75, 23))
+        self.pushButton.setObjectName("pushButton")
+
+        self.retranslateUi(Dialog)
+        QtCore.QMetaObject.connectSlotsByName(Dialog)
+
+    def retranslateUi(self, Dialog):
+        _translate = QtCore.QCoreApplication.translate
+        Dialog.setWindowTitle(_translate("Dialog", "智能交通监控系统"))
+        self.label.setText(_translate("Dialog", "TextLabel"))
+        self.pushButton.setText(_translate("Dialog", "抓取图像"))