-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathALWindow.py
More file actions
114 lines (81 loc) · 3.78 KB
/
ALWindow.py
File metadata and controls
114 lines (81 loc) · 3.78 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import argparse
import logging
import socket
from mmengine.config import Config
from pathlib import Path
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QWidget
from windows.main_window import ALMainWindow
from windows.detection_window import ALDetWindow
def parse_args():
parser = argparse.ArgumentParser('Use AlanLiangs Viewer')
parser.add_argument('--main_window_config', type=str, help='path to which config you use',
default='./configs/main_window/main_window.py')
parser.add_argument('--det_task_config', type=str, help='path to which config you use',
default='./configs/detection_window/detection_window.py')
parser.add_argument('--experiments', type=str, help='path to where you store your OpenPCDet experiments',
default=str(Path.home() / 'repositories/PCDet/output'))
args = parser.parse_args()
return args
class ALWindow(QMainWindow):
def __init__(self, main_window_config, det_task_config) -> None:
super(ALWindow, self).__init__()
self.main_window_config = main_window_config
self.det_task_config = det_task_config
host_name = socket.gethostname()
if host_name == 'Liang':
self.monitor = QDesktopWidget().screenGeometry(1)
self.monitor.setHeight(int(0.2 * self.monitor.height()))
self.monitor.setWidth(int(0.4 * self.monitor.width()))
else:
self.monitor = QDesktopWidget().screenGeometry(0)
self.monitor.setHeight(int(0.3 * self.monitor.height()))
self.monitor.setWidth(int(0.3 * self.monitor.width()))
self.setGeometry(self.monitor)
self.setAcceptDrops(True)
self.centerWidget = QWidget()
self.setCentralWidget(self.centerWidget)
self.layout = QGridLayout()
self.main_window = ALMainWindow(cfg=self.main_window_config)
self.det_window = ALDetWindow(self.main_window, det_task_config=self.det_task_config)
self.image_label = QLabel()
self.image_label.setAlignment(Qt.AlignCenter)
self.main_window_btn = QPushButton("open main window")
self.det_task_btn = QPushButton("3D detection task")
self.sem_task_btn = QPushButton("3D segmentation task")
self.init_window()
def init_window(self):
self.centerWidget.setLayout(self.layout)
self.layout.addWidget(self.image_label, 0, 0, 1, 3)
self.width, self.height = self.image_label.width(), self.image_label.height()
pixmap = QPixmap(str('pics/AlanLiang.png'))
pixmap = pixmap.scaled(self.width, self.height, Qt.KeepAspectRatio)
self.image_label.setPixmap(pixmap)
self.layout.addWidget(self.main_window_btn, 1, 0)
self.layout.addWidget(self.det_task_btn, 1, 1)
self.layout.addWidget(self.sem_task_btn, 1, 2)
self.main_window_btn.clicked.connect(self.open_main_window)
self.det_task_btn.clicked.connect(self.detection_task)
self.sem_task_btn.clicked.connect(self.segmentation_task)
def open_main_window(self):
self.main_window.reset()
self.main_window.show()
def detection_task(self):
self.det_window.show()
def segmentation_task(self):
pass
def main():
args = parse_args()
# Load config
main_window_config = Config.fromfile(args.main_window_config)
det_task_config = Config.fromfile(args.det_task_config)
app = QtWidgets.QApplication([])
window = ALWindow(main_window_config=main_window_config, det_task_config=det_task_config)
window.show()
app.exec_()
if __name__ == '__main__':
logging.basicConfig(format='%(message)s', level=logging.INFO)
main()