-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
98 lines (82 loc) · 2.68 KB
/
main.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""This module runs the app.
Copyright 2023 Mattia Orlandi, Pierangelo Maria Rapa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import argparse
import logging
import sys
from PySide6.QtWidgets import QApplication
from biogui import MainWindow, modules
def main():
logging.basicConfig(level=logging.INFO)
# Input
parser = argparse.ArgumentParser()
parser.add_argument(
"--acq",
action="store_true",
help="Whether to add the acquisition module",
)
parser.add_argument(
"--svmTrain",
action="store_true",
help="Whether to add the SVM training module",
)
parser.add_argument(
"--svmInference",
action="store_true",
help="Whether to add the SVM inference module",
)
parser.add_argument(
"--virtHand",
action="store_true",
help="Whether to add the module for communicating with the virtual hand",
)
parser.add_argument(
"--tcpPort1",
required=False,
default=3334,
type=int,
help="Port for the first virtual hand",
)
parser.add_argument(
"--tcpPort2",
required=False,
default=3335,
type=int,
help="Port for the second virtual hand",
)
parser.add_argument(
"--gestureMapping",
required=False,
default="",
type=str,
help="Path to a JSON specifying the mapping between gesture labels and joint angles",
)
args = vars(parser.parse_args())
argConstraint = sum([bool(args["virtHand"]), bool(args["gestureMapping"])])
if argConstraint != 0 and argConstraint != 2:
parser.error("--virtHand and --gestureMapping must be given together")
# Setup application and main window
app = QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
# Add widgets
if args["acq"]:
modules.AcquisitionController(mainWin) # add acquisition module
# if args["svmTrain"]:
# svmTrainController = modules.SVMTrainController()
# svmTrainController.subscribe(mainWin)
# if args["svmInference"]:
# modules.SVMInferenceController(mainWin)
# Run event loop
sys.exit(app.exec())
if __name__ == "__main__":
main()