-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard_video.py
85 lines (63 loc) · 2.61 KB
/
dashboard_video.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
#!/usr/bin/python
# needs to be BEFORE QT
from gstreamer_window import GstreamerWindow
# now we can import QT
from PyQt5.QtWidgets import QApplication, QDesktopWidget, QFileDialog
from PyQt5 import QtWidgets, Qt
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import dark_style
import sys
from collections import deque
import numpy as np
import yaml
import pyqtgraph as pg
import gstreamer_plots
import win_layout
# for having a control-c
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
def main():
if not "yaml" in sys.argv[-1]:
print('usage: {} robot.yaml layout.yaml'.format(sys.argv[0]))
sys.exit(1)
conf = yaml.full_load(open(sys.argv[-2]))
layout = yaml.full_load(open(sys.argv[-1]))
app = QApplication(sys.argv)
dark_style.dark_style(app)
screen_size = QDesktopWidget().screenGeometry()
print('creating gplots...')
gplots = gstreamer_plots.GstreamerPlots(conf, standalone=True)
print('gplots created')
gplots.setGeometry(layout['gstreamer_plots']['x'], layout['gstreamer_plots']['y'],
layout['gstreamer_plots']['width'], layout['gstreamer_plots']['height'])
if conf['window_border'] == False:
gplots.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
gplots.show()
list_video = []
for camera in conf['gstreamer']:
port = conf['gstreamer'][camera]['port']
name = conf['gstreamer'][camera]['name']
layout_x = layout[camera]['x']
layout_y = layout[camera]['y']
layout_width = layout[camera]['width']
layout_height = layout[camera]['height']
video = GstreamerWindow(conf, gplots, camera)
video.setGeometry(layout_x, layout_y, layout_width, layout_height)
if conf['window_border'] == False:
video.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
video.setWindowTitle("Video from " + conf['gstreamer_ip'] + ' ' + name)
list_video.append(video)
for video in list_video:
video.show()
gplots.setWindowTitle("Gstreamer from "+ conf['gstreamer_ip'])
def save_windows_pos(file_name):
for camera in range(len(conf['gstreamer'])):
file_name = win_layout.save_window_pos(list_video[camera], 'camera_'+str(camera + 1), file_name)
win_layout.save_window_pos(gplots, 'gstreamer_plots', file_name)
gplots.button_save_layout.clicked.connect(lambda : save_windows_pos(sys.argv[-1]))
gplots.button_save_layout_as.clicked.connect(lambda : save_windows_pos(''))
app.exec_()
if __name__ == '__main__':
main()