Your Name преди 1 година
ревизия
cad20878fa
променени са 100 файла, в които са добавени 908 реда и са изтрити 0 реда
  1. BIN
      手写数字识别 2/__MACOSX/._手写数字识别
  2. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._2.bmp
  3. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._MANIFEST
  4. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._build
  5. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._digit.bat
  6. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._digit.py
  7. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._digitapp
  8. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._g.png
  9. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._n3.png
  10. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._n7.png
  11. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._n9.png
  12. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._requirements.txt
  13. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._setup.py
  14. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._test_reco.py
  15. BIN
      手写数字识别 2/__MACOSX/手写数字识别/._项目文件的关系.pptx
  16. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/._lib
  17. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/._scripts-3.6
  18. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/._digitapp
  19. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitAI.py
  20. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitApp.py
  21. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitDev.py
  22. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitForm.py
  23. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitModule.py
  24. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitUI.py
  25. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._Main.py
  26. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/.___init__.py
  27. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._data
  28. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/data/.___init__.py
  29. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/data/._models.lenet
  30. BIN
      手写数字识别 2/__MACOSX/手写数字识别/build/scripts-3.6/._digit.bat
  31. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._Digit.ui
  32. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitAI.py
  33. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitApp.py
  34. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitDev.py
  35. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitForm.py
  36. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitModule.py
  37. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitUI.py
  38. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._Main.py
  39. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/.___init__.py
  40. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/.___pycache__
  41. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._data
  42. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/._tool.bat
  43. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitAI.cpython-36.pyc
  44. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitApp.cpython-36.pyc
  45. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitDev.cpython-36.pyc
  46. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitForm.cpython-36.pyc
  47. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitModule.cpython-36.pyc
  48. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitUI.cpython-36.pyc
  49. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._Main.cpython-36.pyc
  50. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/.___init__.cpython-36.pyc
  51. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/data/.___init__.py
  52. BIN
      手写数字识别 2/__MACOSX/手写数字识别/digitapp/data/._models.lenet
  53. 8 0
      手写数字识别 2/手写数字识别/.idea/.gitignore
  54. 6 0
      手写数字识别 2/手写数字识别/.idea/inspectionProfiles/profiles_settings.xml
  55. 7 0
      手写数字识别 2/手写数字识别/.idea/misc.xml
  56. 8 0
      手写数字识别 2/手写数字识别/.idea/modules.xml
  57. 12 0
      手写数字识别 2/手写数字识别/.idea/手写数字识别.iml
  58. BIN
      手写数字识别 2/手写数字识别/2.bmp
  59. 11 0
      手写数字识别 2/手写数字识别/MANIFEST
  60. 67 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/DigitAI.py
  61. 17 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/DigitApp.py
  62. 36 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/DigitDev.py
  63. 84 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/DigitForm.py
  64. 21 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/DigitModule.py
  65. 82 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/DigitUI.py
  66. 15 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/Main.py
  67. 0 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/__init__.py
  68. 0 0
      手写数字识别 2/手写数字识别/build/lib/digitapp/data/__init__.py
  69. BIN
      手写数字识别 2/手写数字识别/build/lib/digitapp/data/models.lenet
  70. 2 0
      手写数字识别 2/手写数字识别/build/scripts-3.6/digit.bat
  71. 2 0
      手写数字识别 2/手写数字识别/digit.bat
  72. 1 0
      手写数字识别 2/手写数字识别/digit.py
  73. 205 0
      手写数字识别 2/手写数字识别/digitapp/Digit.ui
  74. 67 0
      手写数字识别 2/手写数字识别/digitapp/DigitAI.py
  75. 16 0
      手写数字识别 2/手写数字识别/digitapp/DigitApp.py
  76. 39 0
      手写数字识别 2/手写数字识别/digitapp/DigitDev.py
  77. 84 0
      手写数字识别 2/手写数字识别/digitapp/DigitForm.py
  78. 21 0
      手写数字识别 2/手写数字识别/digitapp/DigitModule.py
  79. 82 0
      手写数字识别 2/手写数字识别/digitapp/DigitUI.py
  80. 15 0
      手写数字识别 2/手写数字识别/digitapp/Main.py
  81. 0 0
      手写数字识别 2/手写数字识别/digitapp/__init__.py
  82. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitAI.cpython-311.pyc
  83. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitAI.cpython-36.pyc
  84. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitAI.cpython-37.pyc
  85. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitApp.cpython-311.pyc
  86. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitApp.cpython-36.pyc
  87. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitApp.cpython-37.pyc
  88. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitDev.cpython-311.pyc
  89. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitDev.cpython-36.pyc
  90. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitDev.cpython-37.pyc
  91. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitForm.cpython-311.pyc
  92. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitForm.cpython-36.pyc
  93. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitForm.cpython-37.pyc
  94. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitModule.cpython-311.pyc
  95. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitModule.cpython-36.pyc
  96. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitModule.cpython-37.pyc
  97. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitUI.cpython-311.pyc
  98. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitUI.cpython-36.pyc
  99. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitUI.cpython-37.pyc
  100. BIN
      手写数字识别 2/手写数字识别/digitapp/__pycache__/Main.cpython-311.pyc

BIN
手写数字识别 2/__MACOSX/._手写数字识别


BIN
手写数字识别 2/__MACOSX/手写数字识别/._2.bmp


BIN
手写数字识别 2/__MACOSX/手写数字识别/._MANIFEST


BIN
手写数字识别 2/__MACOSX/手写数字识别/._build


BIN
手写数字识别 2/__MACOSX/手写数字识别/._digit.bat


BIN
手写数字识别 2/__MACOSX/手写数字识别/._digit.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/._digitapp


BIN
手写数字识别 2/__MACOSX/手写数字识别/._g.png


BIN
手写数字识别 2/__MACOSX/手写数字识别/._n3.png


BIN
手写数字识别 2/__MACOSX/手写数字识别/._n7.png


BIN
手写数字识别 2/__MACOSX/手写数字识别/._n9.png


BIN
手写数字识别 2/__MACOSX/手写数字识别/._requirements.txt


BIN
手写数字识别 2/__MACOSX/手写数字识别/._setup.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/._test_reco.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/._项目文件的关系.pptx


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/._lib


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/._scripts-3.6


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/._digitapp


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitAI.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitApp.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitDev.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitForm.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitModule.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._DigitUI.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._Main.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/.___init__.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/._data


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/data/.___init__.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/lib/digitapp/data/._models.lenet


BIN
手写数字识别 2/__MACOSX/手写数字识别/build/scripts-3.6/._digit.bat


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._Digit.ui


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitAI.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitApp.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitDev.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitForm.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitModule.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._DigitUI.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._Main.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/.___init__.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/.___pycache__


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._data


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/._tool.bat


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitAI.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitApp.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitDev.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitForm.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitModule.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._DigitUI.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/._Main.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/__pycache__/.___init__.cpython-36.pyc


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/data/.___init__.py


BIN
手写数字识别 2/__MACOSX/手写数字识别/digitapp/data/._models.lenet


+ 8 - 0
手写数字识别 2/手写数字识别/.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 6 - 0
手写数字识别 2/手写数字识别/.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>

+ 7 - 0
手写数字识别 2/手写数字识别/.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptSettings">
+    <option name="languageLevel" value="ES6" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
手写数字识别 2/手写数字识别/.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/手写数字识别.iml" filepath="$PROJECT_DIR$/.idea/手写数字识别.iml" />
+    </modules>
+  </component>
+</project>

+ 12 - 0
手写数字识别 2/手写数字识别/.idea/手写数字识别.iml

@@ -0,0 +1,12 @@
+<?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>
+  <component name="PyDocumentationSettings">
+    <option name="format" value="PLAIN" />
+    <option name="myDocStringFormat" value="Plain" />
+  </component>
+</module>

BIN
手写数字识别 2/手写数字识别/2.bmp


+ 11 - 0
手写数字识别 2/手写数字识别/MANIFEST

@@ -0,0 +1,11 @@
+# file GENERATED by distutils, do NOT edit
+setup.py
+digitapp\DigitAI.py
+digitapp\DigitApp.py
+digitapp\DigitDev.py
+digitapp\DigitForm.py
+digitapp\DigitModule.py
+digitapp\DigitUI.py
+digitapp\Main.py
+digitapp\__init__.py
+digitapp\data\__init__.py

+ 67 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/DigitAI.py

@@ -0,0 +1,67 @@
+import cv2
+import numpy as np
+import torch
+from .DigitModule import LeNet
+import os
+
+cur_dir = os.path.dirname(__file__)
+mod_file = os.path.join(cur_dir,"data/models.lenet")
+
+class DigitRecognizier:
+    def __init__(self):
+        super(DigitRecognizier, self).__init__()
+        self.CUDA = torch.cuda.is_available()
+        self.net = LeNet(10)
+        if self.CUDA:
+            self.net.cuda()
+        state = torch.load(mod_file)
+        self.net.load_state_dict(state)
+    
+
+    def pre_image(self, img):
+        # 大小
+        img = cv2.resize(img, (28,28))
+        # 灰度
+        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+        # 小数类型
+        img = img.astype("float32")
+        # 逆转(F-> B, B->F)
+        img = 255.0 -img
+        # 去噪
+        img[img <= 150] = 0
+        cv2.imwrite("g.png", img.astype("uint8"))
+        # 转换为张量
+        img = torch.from_numpy(img).clone()
+        # 转换为N C H W
+        
+        return img
+
+    
+    def recognize(self, img):
+        result = []  # (数字,概率)
+        # 根据模型计算输出
+        p_img = self.pre_image(img)
+        if self.CUDA:
+            p_img = p_img.cuda()
+
+        predict = self.net.forward(p_img.view(1, 1, 28, 28))
+
+        pred_prob = torch.nn.functional.softmax(predict, dim=1)
+        # 计算在gpu,速度快
+        pred_prob = pred_prob[0]
+        # pred_prob = torch.squeeze(pred_prob, 0)
+        # pred_prob = pred_prob.view((pred_prob.shape[1]))
+        # 找出最大概率及其下标,判定概率
+        top1 = torch.argmax(pred_prob)
+        pro1 = pred_prob[top1]
+        result.append((top1.cpu().detach().numpy(), pro1.cpu().detach().numpy()))
+        if pro1 < 1.0:
+            # 把top1置为0,再找最大值
+            pred_prob[top1] = 0.0
+            top2 = torch.argmax(pred_prob)
+            pro2 = pred_prob[top2]
+            result.append((top2.cpu().detach().numpy(), pro2.cpu().detach().numpy()))
+
+
+        return result # 返回长度为10的概率向量
+

+ 17 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/DigitApp.py

@@ -0,0 +1,17 @@
+"""
+"""
+from PyQt5.QtWidgets import QApplication
+from .DigitForm import DigitForm
+import sys 
+
+class DigitApp(QApplication):
+    """
+    """
+    def __init__(self):
+        """
+        """
+        super(DigitApp, self).__init__(sys.argv)
+        # 创建应用主窗体
+        self.dlg = DigitForm()
+        self.dlg.show()
+    

+ 36 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/DigitDev.py

@@ -0,0 +1,36 @@
+from PyQt5.QtCore import QThread, pyqtSignal
+import cv2
+
+class DigitDev(QThread):
+    
+    signal_video = pyqtSignal(int, int, int, bytes)
+
+    def __init__(self):
+        super(DigitDev, self).__init__()
+        self.is_over = False
+        # 初始化设备
+        self.dev = cv2.VideoCapture(0, cv2.CAP_DSHOW)
+
+
+    def run(self):
+        while not self.is_over:
+            # 图像抓取
+            status, image = self.dev.read()
+            # 状态判定
+            if not status:
+                self.dev.release()
+                self.exit(0)
+            # 如果抓取图像成功,发送
+            shape = image.shape
+            image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
+            self.signal_video.emit(shape[0], shape[1], shape[2], image.tobytes())
+            # 视觉暂停
+            QThread.usleep(100000)
+
+    def close(self):
+        self.is_over = True
+        while self.isRunning():
+            pass
+        # 释放设备
+        if self.dev.isOpened():
+            self.dev.release()

+ 84 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/DigitForm.py

@@ -0,0 +1,84 @@
+from PyQt5.QtWidgets import QDialog
+from PyQt5.QtGui import QImage, QPixmap
+import sys
+from .DigitUI import Ui_Digit
+from .DigitDev import DigitDev
+from .DigitAI import DigitRecognizier
+import cv2
+import numpy as np
+
+class DigitForm(QDialog):
+    def __init__(self):
+        super(DigitForm, self).__init__()
+        # 加载UI(先设计好)
+        # 创建对象
+        self.ui = Ui_Digit()
+        # 使用setupUi绑定对话框(父窗体)
+        self.ui.setupUi(self)
+        # AI识别对象
+        self.reco = DigitRecognizier()
+        # 创建视频对象
+        self.dev = DigitDev()
+        self.dev.signal_video.connect(self.show_video)
+        self.dev.start()
+
+
+
+    # 覆盖QDialog原来两个我们不需要的默认功能
+    def keyPressEvent(self, e):
+        pass
+
+
+    def closeEvent(self, e):
+        # 完成一些需要的释放工作
+        self.dev.close()
+        sys.exit(0)
+
+    # UI中的两个槽函数
+    def capture_image(self):
+        # 抓取图像
+        self.capture_data = self.buffer_data
+        self.capture_shape = self.buffer_shape
+        # 显示抓取的图像
+        # byte -> QImage
+        h, w, ch = self.capture_shape
+        image = QImage(self.capture_data, w, h, w*ch, QImage.Format_BGR888)
+        # QImage -> QPixmap
+        pixmap = QPixmap.fromImage(image)
+        # QPixmap -> QLabel 
+        self.ui.lbl_image.setPixmap(pixmap)
+        self.ui.lbl_image.setScaledContents(True)
+
+    def digit_recognize(self):
+        # 已知
+        # self.capture_data
+        # self.capture_shape
+        # 准备:训练好的手写字符模型:models.lenet:LeNet-5
+        # 实现与模型一致的 神经网络结构(层数,层类型,每层参数一致)
+        # 利用神经网络结构,识别图片
+        image = np.ndarray(
+            shape=self.capture_shape,    # 构建图像矩阵的形状
+            dtype=np.uint8,
+            buffer=self.buffer_data
+        )
+
+        result = self.reco.recognize(image)
+        self.ui.lbl_top1.setText(F"<font size=20 color=red><b><strong>{result[0][0]}</strong><b></font>")
+        self.ui.lbl_prob1.setText(F"{result[0][1]:3.2f}")
+        if len(result) == 2:
+            self.ui.lbl_top2.setText(F"{result[1][0]}")
+            self.ui.lbl_prob2.setText(F"{result[1][1]:3.2f}")
+        else:
+            self.ui.lbl_top2.setText("--")
+            self.ui.lbl_prob2.setText("--")
+
+    def show_video(self, h, w, ch, data):
+        self.buffer_data = data
+        self.buffer_shape = (h, w, ch)
+        # byte -> QImage
+        image = QImage(data, w, h, w*ch, QImage.Format_RGB888)
+        # QImage -> QPixmap
+        pixmap = QPixmap.fromImage(image)
+        # QPixmap -> QLabel 
+        self.ui.lbl_video.setPixmap(pixmap)
+        self.ui.lbl_video.setScaledContents(True)

+ 21 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/DigitModule.py

@@ -0,0 +1,21 @@
+import torch.nn as nn     # 神经网络的层的实现:卷积层
+import torch.nn.functional as fu
+
+class LeNet(nn.Module):
+    def __init__(self, cls_num=10):
+        super(LeNet, self).__init__()
+        self.conv1 = nn.Conv2d(1, 6, 5, padding=2)  
+        self.conv2 = nn.Conv2d(6, 16, 5)
+        self.fc1 = nn.Linear(16 * 5 * 5,  120)
+        self.fc2 = nn.Linear(120, 84) 
+        self.fc3 = nn.Linear(84, cls_num)
+    
+    def forward(self, x):
+        y = fu.max_pool2d(fu.relu(self.conv1(x)), (2, 2))
+        y = fu.max_pool2d(fu.relu(self.conv2(y)), (2, 2))
+        # 格式转换
+        y = y.view(y.size()[0], -1)
+        y = fu.relu(self.fc1(y))
+        y = fu.relu(self.fc2(y))
+        y = self.fc3(y)
+        return y

+ 82 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/DigitUI.py

@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'Digit.ui'
+#
+# Created by: PyQt5 UI code generator 5.14.1
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+
+class Ui_Digit(object):
+    def setupUi(self, Digit):
+        Digit.setObjectName("Digit")
+        Digit.resize(921, 259)
+        Digit.setStyleSheet("QPushButton{\n"
+"    border-style:solid;\n"
+"    border-width:1px;\n"
+"    border-radius:8px;\n"
+"    border-top-color:#FFFFFF;\n"
+"    border-bottom-color:#888888;\n"
+"    border-left-color:#FFFFFF;\n"
+"    border-right-color:#888888;\n"
+"}\n"
+"QLabel#lbl_top1,#lbl_top2{\n"
+"    color:red;\n"
+"    font-size:24px;\n"
+"}\n"
+"QLabel#lbl_prob1,#lbl_prob2{\n"
+"    color:blue;\n"
+"}")
+        self.lbl_video = QtWidgets.QLabel(Digit)
+        self.lbl_video.setGeometry(QtCore.QRect(10, 10, 320, 240))
+        self.lbl_video.setFrameShape(QtWidgets.QFrame.Box)
+        self.lbl_video.setFrameShadow(QtWidgets.QFrame.Raised)
+        self.lbl_video.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_video.setObjectName("lbl_video")
+        self.btn_capture = QtWidgets.QPushButton(Digit)
+        self.btn_capture.setGeometry(QtCore.QRect(340, 120, 93, 28))
+        self.btn_capture.setObjectName("btn_capture")
+        self.lbl_image = QtWidgets.QLabel(Digit)
+        self.lbl_image.setGeometry(QtCore.QRect(450, 77, 160, 120))
+        self.lbl_image.setFrameShape(QtWidgets.QFrame.Box)
+        self.lbl_image.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_image.setObjectName("lbl_image")
+        self.btn_recognize = QtWidgets.QPushButton(Digit)
+        self.btn_recognize.setGeometry(QtCore.QRect(630, 120, 92, 28))
+        self.btn_recognize.setObjectName("btn_recognize")
+        self.lbl_top1 = QtWidgets.QLabel(Digit)
+        self.lbl_top1.setGeometry(QtCore.QRect(740, 60, 60, 60))
+        self.lbl_top1.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_top1.setObjectName("lbl_top1")
+        self.lbl_top2 = QtWidgets.QLabel(Digit)
+        self.lbl_top2.setGeometry(QtCore.QRect(740, 150, 60, 60))
+        self.lbl_top2.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_top2.setObjectName("lbl_top2")
+        self.lbl_prob1 = QtWidgets.QLabel(Digit)
+        self.lbl_prob1.setGeometry(QtCore.QRect(830, 74, 80, 28))
+        self.lbl_prob1.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_prob1.setObjectName("lbl_prob1")
+        self.lbl_prob2 = QtWidgets.QLabel(Digit)
+        self.lbl_prob2.setGeometry(QtCore.QRect(830, 165, 80, 26))
+        self.lbl_prob2.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_prob2.setObjectName("lbl_prob2")
+
+        self.retranslateUi(Digit)
+        self.btn_capture.clicked.connect(Digit.capture_image)
+        self.btn_recognize.clicked.connect(Digit.digit_recognize)
+        QtCore.QMetaObject.connectSlotsByName(Digit)
+
+    def retranslateUi(self, Digit):
+        _translate = QtCore.QCoreApplication.translate
+        Digit.setWindowTitle(_translate("Digit", "手写数字识别程序"))
+        self.lbl_video.setText(_translate("Digit", "<font size=20 color=blue><b>视频显示区域</b></font>"))
+        self.btn_capture.setText(_translate("Digit", "抓取图像"))
+        self.lbl_image.setText(_translate("Digit", "抓取的图像"))
+        self.btn_recognize.setText(_translate("Digit", "数组识别"))
+        self.lbl_top1.setText(_translate("Digit", "top1"))
+        self.lbl_top2.setText(_translate("Digit", "top2"))
+        self.lbl_prob1.setText(_translate("Digit", "prob1"))
+        self.lbl_prob2.setText(_translate("Digit", "prob2"))

+ 15 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/Main.py

@@ -0,0 +1,15 @@
+"""
+Date: 2020-05-22
+Author: Louis Young
+Usage: 主程序(抓取视频,并截图,然后调用数字识别模块,完成手写数字的智能识别)
+"""
+
+from .DigitApp import DigitApp
+import sys
+
+# 1. 创建应用
+app_digit = DigitApp() 
+# 2. 启动应用的消息监控循环
+status = app_digit.exec()
+# 3. 应用结束的时候,返回状态码给系统
+sys.exit(status)

+ 0 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/__init__.py


+ 0 - 0
手写数字识别 2/手写数字识别/build/lib/digitapp/data/__init__.py


BIN
手写数字识别 2/手写数字识别/build/lib/digitapp/data/models.lenet


+ 2 - 0
手写数字识别 2/手写数字识别/build/scripts-3.6/digit.bat

@@ -0,0 +1,2 @@
+@python -m digitapp.Main
+

+ 2 - 0
手写数字识别 2/手写数字识别/digit.bat

@@ -0,0 +1,2 @@
+@python -m digitapp.Main
+

+ 1 - 0
手写数字识别 2/手写数字识别/digit.py

@@ -0,0 +1 @@
+import digitapp.Main

+ 205 - 0
手写数字识别 2/手写数字识别/digitapp/Digit.ui

@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Digit</class>
+ <widget class="QDialog" name="Digit">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>921</width>
+    <height>259</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>手写数字识别程序</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">QPushButton{
+	border-style:solid;
+	border-width:1px;
+	border-radius:8px;
+	border-top-color:#FFFFFF;
+	border-bottom-color:#888888;
+	border-left-color:#FFFFFF;
+	border-right-color:#888888;
+}
+QLabel#lbl_top1,#lbl_top2{
+	color:red;
+	font-size:24px;
+}
+QLabel#lbl_prob1,#lbl_prob2{
+	color:blue;
+}</string>
+  </property>
+  <widget class="QLabel" name="lbl_video">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>10</y>
+     <width>320</width>
+     <height>240</height>
+    </rect>
+   </property>
+   <property name="frameShape">
+    <enum>QFrame::Box</enum>
+   </property>
+   <property name="frameShadow">
+    <enum>QFrame::Raised</enum>
+   </property>
+   <property name="text">
+    <string>&lt;font size=20 color=blue&gt;&lt;b&gt;视频显示区域&lt;/b&gt;&lt;/font&gt;</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="btn_capture">
+   <property name="geometry">
+    <rect>
+     <x>340</x>
+     <y>120</y>
+     <width>93</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>抓取图像</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="lbl_image">
+   <property name="geometry">
+    <rect>
+     <x>450</x>
+     <y>77</y>
+     <width>160</width>
+     <height>120</height>
+    </rect>
+   </property>
+   <property name="frameShape">
+    <enum>QFrame::Box</enum>
+   </property>
+   <property name="text">
+    <string>抓取的图像</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="btn_recognize">
+   <property name="geometry">
+    <rect>
+     <x>630</x>
+     <y>120</y>
+     <width>92</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>数组识别</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="lbl_top1">
+   <property name="geometry">
+    <rect>
+     <x>740</x>
+     <y>60</y>
+     <width>60</width>
+     <height>60</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>top1</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+  <widget class="QLabel" name="lbl_top2">
+   <property name="geometry">
+    <rect>
+     <x>740</x>
+     <y>150</y>
+     <width>60</width>
+     <height>60</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>top2</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+  <widget class="QLabel" name="lbl_prob1">
+   <property name="geometry">
+    <rect>
+     <x>830</x>
+     <y>74</y>
+     <width>80</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>prob1</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+  <widget class="QLabel" name="lbl_prob2">
+   <property name="geometry">
+    <rect>
+     <x>830</x>
+     <y>165</y>
+     <width>80</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>prob2</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>btn_capture</sender>
+   <signal>clicked()</signal>
+   <receiver>Digit</receiver>
+   <slot>capture_image()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>387</x>
+     <y>137</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>391</x>
+     <y>195</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>btn_recognize</sender>
+   <signal>clicked()</signal>
+   <receiver>Digit</receiver>
+   <slot>digit_recognize()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>671</x>
+     <y>128</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>673</x>
+     <y>184</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>capture_image()</slot>
+  <slot>digit_recognize()</slot>
+ </slots>
+</ui>

+ 67 - 0
手写数字识别 2/手写数字识别/digitapp/DigitAI.py

@@ -0,0 +1,67 @@
+import cv2
+import numpy as np
+import torch
+from .DigitModule import LeNet
+import os
+
+cur_dir = os.path.dirname(__file__)
+mod_file = os.path.join(cur_dir,"data/models.lenet")
+
+class DigitRecognizier:
+    def __init__(self):
+        super(DigitRecognizier, self).__init__()
+        self.CUDA = torch.cuda.is_available()
+        self.net = LeNet(10)
+        if self.CUDA:
+            self.net.cuda()
+        state = torch.load(mod_file, map_location='cpu')
+        self.net.load_state_dict(state)
+    
+
+    def pre_image(self, img):
+        # 大小
+        img = cv2.resize(img, (28,28))
+        # 灰度
+        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+        # 小数类型
+        img = img.astype("float32")
+        # 逆转(F-> B, B->F)
+        img = 255.0 -img
+        # 去噪
+        img[img <= 150] = 0
+        cv2.imwrite("g.png", img.astype("uint8"))
+        # 转换为张量
+        img = torch.from_numpy(img).clone()
+        # 转换为N C H W
+        
+        return img
+
+    
+    def recognize(self, img):
+        result = []  # (数字,概率)
+        # 根据模型计算输出
+        p_img = self.pre_image(img)
+        if self.CUDA:
+            p_img = p_img.cuda()
+
+        predict = self.net.forward(p_img.view(1, 1, 28, 28))
+
+        pred_prob = torch.nn.functional.softmax(predict, dim=1)
+        # 计算在gpu,速度快
+        pred_prob = pred_prob[0]
+        # pred_prob = torch.squeeze(pred_prob, 0)
+        # pred_prob = pred_prob.view((pred_prob.shape[1]))
+        # 找出最大概率及其下标,判定概率
+        top1 = torch.argmax(pred_prob)
+        pro1 = pred_prob[top1]
+        result.append((top1.cpu().detach().numpy(), pro1.cpu().detach().numpy()))
+        if pro1 < 1.0:
+            # 把top1置为0,再找最大值
+            pred_prob[top1] = 0.0
+            top2 = torch.argmax(pred_prob)
+            pro2 = pred_prob[top2]
+            result.append((top2.cpu().detach().numpy(), pro2.cpu().detach().numpy()))
+
+
+        return result # 返回长度为10的概率向量
+

+ 16 - 0
手写数字识别 2/手写数字识别/digitapp/DigitApp.py

@@ -0,0 +1,16 @@
+"""
+"""
+from PyQt5.QtWidgets import QApplication
+from .DigitForm import DigitForm
+import sys
+
+class DigitApp(QApplication):
+    """
+    """
+    def __init__(self):
+        """
+        """
+        super(DigitApp, self).__init__(sys.argv)
+        # 创建应用主窗体
+        self.dlg = DigitForm()
+        self.dlg.show()

+ 39 - 0
手写数字识别 2/手写数字识别/digitapp/DigitDev.py

@@ -0,0 +1,39 @@
+from PyQt5.QtCore import QThread, pyqtSignal
+import cv2
+
+class DigitDev(QThread):
+    
+    signal_video = pyqtSignal(int, int, int, bytes)
+
+    def __init__(self):
+        super(DigitDev, self).__init__()
+        self.is_over = False
+        # 初始化设备
+        # self.dev = cv2.VideoCapture(0, cv2.CAP_DSHOW)
+        self.dev = cv2.VideoCapture(0)
+        print("dev = " + str(self.dev))
+
+
+    def run(self):
+        while not self.is_over:
+            # 图像抓取
+            status, image = self.dev.read()
+            print("image = " + str(image))
+            # 状态判定
+            if not status:
+                self.dev.release()
+                self.exit(0)
+            # 如果抓取图像成功,发送
+            shape = image.shape
+            image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
+            self.signal_video.emit(shape[0], shape[1], shape[2], image.tobytes())
+            # 视觉暂停
+            QThread.usleep(100000)
+
+    def close(self):
+        self.is_over = True
+        while self.isRunning():
+            pass
+        # 释放设备
+        if self.dev.isOpened():
+            self.dev.release()

+ 84 - 0
手写数字识别 2/手写数字识别/digitapp/DigitForm.py

@@ -0,0 +1,84 @@
+from PyQt5.QtWidgets import QDialog
+from PyQt5.QtGui import QImage, QPixmap
+import sys
+from .DigitUI import Ui_Digit
+from .DigitDev import DigitDev
+from .DigitAI import DigitRecognizier
+import cv2
+import numpy as np
+
+class DigitForm(QDialog):
+    def __init__(self):
+        super(DigitForm, self).__init__()
+        # 加载UI(先设计好)
+        # 创建对象
+        self.ui = Ui_Digit()
+        # 使用setupUi绑定对话框(父窗体)
+        self.ui.setupUi(self)
+        # AI识别对象
+        self.reco = DigitRecognizier()
+        # 创建视频对象
+        self.dev = DigitDev()
+        self.dev.signal_video.connect(self.show_video)
+        self.dev.start()
+
+
+
+    # 覆盖QDialog原来两个我们不需要的默认功能
+    def keyPressEvent(self, e):
+        pass
+
+
+    def closeEvent(self, e):
+        # 完成一些需要的释放工作
+        self.dev.close()
+        sys.exit(0)
+
+    # UI中的两个槽函数
+    def capture_image(self):
+        # 抓取图像
+        self.capture_data = self.buffer_data
+        self.capture_shape = self.buffer_shape
+        # 显示抓取的图像
+        # byte -> QImage
+        h, w, ch = self.capture_shape
+        image = QImage(self.capture_data, w, h, w*ch, QImage.Format_BGR888)
+        # QImage -> QPixmap
+        pixmap = QPixmap.fromImage(image)
+        # QPixmap -> QLabel 
+        self.ui.lbl_image.setPixmap(pixmap)
+        self.ui.lbl_image.setScaledContents(True)
+
+    def digit_recognize(self):
+        # 已知
+        # self.capture_data
+        # self.capture_shape
+        # 准备:训练好的手写字符模型:models.lenet:LeNet-5
+        # 实现与模型一致的 神经网络结构(层数,层类型,每层参数一致)
+        # 利用神经网络结构,识别图片
+        image = np.ndarray(
+            shape=self.capture_shape,    # 构建图像矩阵的形状
+            dtype=np.uint8,
+            buffer=self.buffer_data
+        )
+
+        result = self.reco.recognize(image)
+        self.ui.lbl_top1.setText(F"<font size=20 color=red><b><strong>{result[0][0]}</strong><b></font>")
+        self.ui.lbl_prob1.setText(F"{result[0][1]:3.2f}")
+        if len(result) == 2:
+            self.ui.lbl_top2.setText(F"{result[1][0]}")
+            self.ui.lbl_prob2.setText(F"{result[1][1]:3.2f}")
+        else:
+            self.ui.lbl_top2.setText("--")
+            self.ui.lbl_prob2.setText("--")
+
+    def show_video(self, h, w, ch, data):
+        self.buffer_data = data
+        self.buffer_shape = (h, w, ch)
+        # byte -> QImage
+        image = QImage(data, w, h, w*ch, QImage.Format_RGB888)
+        # QImage -> QPixmap
+        pixmap = QPixmap.fromImage(image)
+        # QPixmap -> QLabel 
+        self.ui.lbl_video.setPixmap(pixmap)
+        self.ui.lbl_video.setScaledContents(True)

+ 21 - 0
手写数字识别 2/手写数字识别/digitapp/DigitModule.py

@@ -0,0 +1,21 @@
+import torch.nn as nn     # 神经网络的层的实现:卷积层
+import torch.nn.functional as fu
+
+class LeNet(nn.Module):
+    def __init__(self, cls_num=10):
+        super(LeNet, self).__init__()
+        self.conv1 = nn.Conv2d(1, 6, 5, padding=2)  
+        self.conv2 = nn.Conv2d(6, 16, 5)
+        self.fc1 = nn.Linear(16 * 5 * 5,  120)
+        self.fc2 = nn.Linear(120, 84) 
+        self.fc3 = nn.Linear(84, cls_num)
+    
+    def forward(self, x):
+        y = fu.max_pool2d(fu.relu(self.conv1(x)), (2, 2))
+        y = fu.max_pool2d(fu.relu(self.conv2(y)), (2, 2))
+        # 格式转换
+        y = y.view(y.size()[0], -1)
+        y = fu.relu(self.fc1(y))
+        y = fu.relu(self.fc2(y))
+        y = self.fc3(y)
+        return y

+ 82 - 0
手写数字识别 2/手写数字识别/digitapp/DigitUI.py

@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'Digit.ui'
+#
+# Created by: PyQt5 UI code generator 5.14.1
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+
+class Ui_Digit(object):
+    def setupUi(self, Digit):
+        Digit.setObjectName("Digit")
+        Digit.resize(921, 259)
+        Digit.setStyleSheet("QPushButton{\n"
+"    border-style:solid;\n"
+"    border-width:1px;\n"
+"    border-radius:8px;\n"
+"    border-top-color:#FFFFFF;\n"
+"    border-bottom-color:#888888;\n"
+"    border-left-color:#FFFFFF;\n"
+"    border-right-color:#888888;\n"
+"}\n"
+"QLabel#lbl_top1,#lbl_top2{\n"
+"    color:red;\n"
+"    font-size:24px;\n"
+"}\n"
+"QLabel#lbl_prob1,#lbl_prob2{\n"
+"    color:blue;\n"
+"}")
+        self.lbl_video = QtWidgets.QLabel(Digit)
+        self.lbl_video.setGeometry(QtCore.QRect(10, 10, 320, 240))
+        self.lbl_video.setFrameShape(QtWidgets.QFrame.Box)
+        self.lbl_video.setFrameShadow(QtWidgets.QFrame.Raised)
+        self.lbl_video.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_video.setObjectName("lbl_video")
+        self.btn_capture = QtWidgets.QPushButton(Digit)
+        self.btn_capture.setGeometry(QtCore.QRect(340, 120, 93, 28))
+        self.btn_capture.setObjectName("btn_capture")
+        self.lbl_image = QtWidgets.QLabel(Digit)
+        self.lbl_image.setGeometry(QtCore.QRect(450, 77, 160, 120))
+        self.lbl_image.setFrameShape(QtWidgets.QFrame.Box)
+        self.lbl_image.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_image.setObjectName("lbl_image")
+        self.btn_recognize = QtWidgets.QPushButton(Digit)
+        self.btn_recognize.setGeometry(QtCore.QRect(630, 120, 92, 28))
+        self.btn_recognize.setObjectName("btn_recognize")
+        self.lbl_top1 = QtWidgets.QLabel(Digit)
+        self.lbl_top1.setGeometry(QtCore.QRect(740, 60, 60, 60))
+        self.lbl_top1.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_top1.setObjectName("lbl_top1")
+        self.lbl_top2 = QtWidgets.QLabel(Digit)
+        self.lbl_top2.setGeometry(QtCore.QRect(740, 150, 60, 60))
+        self.lbl_top2.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_top2.setObjectName("lbl_top2")
+        self.lbl_prob1 = QtWidgets.QLabel(Digit)
+        self.lbl_prob1.setGeometry(QtCore.QRect(830, 74, 80, 28))
+        self.lbl_prob1.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_prob1.setObjectName("lbl_prob1")
+        self.lbl_prob2 = QtWidgets.QLabel(Digit)
+        self.lbl_prob2.setGeometry(QtCore.QRect(830, 165, 80, 26))
+        self.lbl_prob2.setAlignment(QtCore.Qt.AlignCenter)
+        self.lbl_prob2.setObjectName("lbl_prob2")
+
+        self.retranslateUi(Digit)
+        self.btn_capture.clicked.connect(Digit.capture_image)
+        self.btn_recognize.clicked.connect(Digit.digit_recognize)
+        QtCore.QMetaObject.connectSlotsByName(Digit)
+
+    def retranslateUi(self, Digit):
+        _translate = QtCore.QCoreApplication.translate
+        Digit.setWindowTitle(_translate("Digit", "手写数字识别程序"))
+        self.lbl_video.setText(_translate("Digit", "<font size=20 color=blue><b>视频显示区域</b></font>"))
+        self.btn_capture.setText(_translate("Digit", "抓取图像"))
+        self.lbl_image.setText(_translate("Digit", "抓取的图像"))
+        self.btn_recognize.setText(_translate("Digit", "数组识别"))
+        self.lbl_top1.setText(_translate("Digit", "top1"))
+        self.lbl_top2.setText(_translate("Digit", "top2"))
+        self.lbl_prob1.setText(_translate("Digit", "prob1"))
+        self.lbl_prob2.setText(_translate("Digit", "prob2"))

+ 15 - 0
手写数字识别 2/手写数字识别/digitapp/Main.py

@@ -0,0 +1,15 @@
+"""
+Date: 2020-05-22
+Author: Louis Young
+Usage: 主程序(抓取视频,并截图,然后调用数字识别模块,完成手写数字的智能识别)
+"""
+
+from .DigitApp import DigitApp
+import sys
+
+# 1. 创建应用
+app_digit = DigitApp() 
+# 2. 启动应用的消息监控循环
+status = app_digit.exec()
+# 3. 应用结束的时候,返回状态码给系统
+sys.exit(status)

+ 0 - 0
手写数字识别 2/手写数字识别/digitapp/__init__.py


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitAI.cpython-311.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitAI.cpython-36.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitAI.cpython-37.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitApp.cpython-311.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitApp.cpython-36.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitApp.cpython-37.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitDev.cpython-311.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitDev.cpython-36.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitDev.cpython-37.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitForm.cpython-311.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitForm.cpython-36.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitForm.cpython-37.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitModule.cpython-311.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitModule.cpython-36.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitModule.cpython-37.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitUI.cpython-311.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitUI.cpython-36.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/DigitUI.cpython-37.pyc


BIN
手写数字识别 2/手写数字识别/digitapp/__pycache__/Main.cpython-311.pyc


Някои файлове не бяха показани, защото твърде много файлове са промени