-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
60 lines (48 loc) · 1.85 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import sys
from PyQt5.QtWidgets import QApplication, QWidget
import PyQt5.QtWidgets as qt
import util
from database import ops
import gui
from gui.interface import TabActivationListener
class MyWindow(QWidget):
def __init__(self) -> None:
super().__init__()
self.ui = self.init_ui()
self.setGeometry(0, 0, 800, 600)
def init_ui(self):
db_client = ops.DBClient("./database/db/data.db")
detector = util.HandDetector(maxHands=1)
fps_calc = util.FPSCalculator()
gesture_model_path = "./model/sign_classifier/sign_classifier_app.h5"
tab_widget = qt.QTabWidget(self)
self.tabs = [
gui.TabApp(db_client, detector, gesture_model_path),
gui.TabGenDataset(
db_client, detector, fps_calc
),
gui.TabTrainModel(
db_client, detector, fps_calc, gesture_model_path
),
gui.TabEditConfig(db_client),
]
tab_widget.addTab(self.tabs[0], "app")
tab_widget.addTab(self.tabs[1], "添加新手势数据集")
tab_widget.addTab(self.tabs[2], "训练模型")
tab_widget.addTab(self.tabs[3], "配置手势动作")
tab_widget.currentChanged.connect(self.tab_widget_change)
layout = qt.QVBoxLayout()
layout.addWidget(tab_widget)
self.setLayout(layout)
def tab_widget_change(self, idx:int):
listener: TabActivationListener = self.tabs[idx]
listener.on_tab_activated()
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MyWindow()
# db_client = ops.DBClient("./database/db/data.db")
# # detector = util.HandDetector(maxHands=1)
# # w = gui.TabApp(db_client, detector, "./model/sign_classifier/sign_classifier_app.h5")
# w = gui.TabEditConfig(db_client)
w.show()
app.exec()