-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
96 lines (75 loc) · 3.24 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
import atexit
import cProfile
import io
import pstats
import sys
import numpy as np
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from mainDir.mainUI_013 import VideoMixerUI
from mainDir.ouputs.mainOut_Viewer import CV_MainOutViewer
# Define constants for colors
WINDOW_COLOR = QColor(53, 53, 53)
TEXT_COLOR = Qt.GlobalColor.white
BASE_COLOR = QColor(42, 42, 42)
ALTERNATE_BASE_COLOR = QColor(66, 66, 66)
BRIGHT_TEXT_COLOR = Qt.GlobalColor.red
LINK_COLOR = QColor(42, 130, 218)
DISABLED_TEXT_COLOR = QColor(127, 127, 127)
DISABLED_HIGHLIGHT_COLOR = QColor(80, 80, 80)
def setPalette(app):
app.setStyle("Fusion")
dark_palette = QPalette()
# Extract repetitive setting of colors to a function
def set_color(palette, role, color):
palette.setColor(role, color)
# Normal state colors
set_color(dark_palette, QPalette.ColorRole.Window, WINDOW_COLOR)
set_color(dark_palette, QPalette.ColorRole.WindowText, TEXT_COLOR)
set_color(dark_palette, QPalette.ColorRole.Base, BASE_COLOR)
set_color(dark_palette, QPalette.ColorRole.AlternateBase, ALTERNATE_BASE_COLOR)
set_color(dark_palette, QPalette.ColorRole.ToolTipBase, TEXT_COLOR)
set_color(dark_palette, QPalette.ColorRole.ToolTipText, TEXT_COLOR)
set_color(dark_palette, QPalette.ColorRole.Text, TEXT_COLOR)
set_color(dark_palette, QPalette.ColorRole.Button, WINDOW_COLOR)
set_color(dark_palette, QPalette.ColorRole.ButtonText, TEXT_COLOR)
set_color(dark_palette, QPalette.ColorRole.BrightText, BRIGHT_TEXT_COLOR)
set_color(dark_palette, QPalette.ColorRole.Link, LINK_COLOR)
set_color(dark_palette, QPalette.ColorRole.Highlight, LINK_COLOR)
set_color(dark_palette, QPalette.ColorRole.HighlightedText, TEXT_COLOR)
# Disabled state colors
dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.WindowText, DISABLED_TEXT_COLOR)
dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Text, DISABLED_TEXT_COLOR)
dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, DISABLED_TEXT_COLOR)
dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Highlight, DISABLED_HIGHLIGHT_COLOR)
dark_palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.HighlightedText, DISABLED_TEXT_COLOR)
app.setPalette(dark_palette)
class VideoApp(QApplication):
def __init__(self, argv):
super().__init__(argv)
self.timer = QTimer()
self.mixerVideo = VideoMixerUI()
self.mixerVideo.synchObject.synch_SIGNAL.connect(self.update)
self.mainOut = CV_MainOutViewer(np.zeros((1080, 1920, 3), dtype=np.uint8))
self.mixerVideo.show()
def update(self):
dirty_frame = self.mixerVideo.getDirtyFrame()
if dirty_frame is not None:
self.mainOut.feedFrame(dirty_frame)
def main():
app = VideoApp(sys.argv)
setPalette(app)
sys.exit(app.exec())
if __name__ == "__main__":
pr = cProfile.Profile()
pr.enable()
def exit_handler():
pr.disable()
s = io.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())
atexit.register(exit_handler)
main()