feat: gui off WIP

This commit is contained in:
Prohurtz 2024-07-22 10:57:44 -05:00
parent 9b9763b132
commit 932fc782cf
2 changed files with 185 additions and 151 deletions

View File

@ -117,18 +117,18 @@ class CameraWidget:
self.roi_layout = [ self.roi_layout = [
[ [
sg.Button( # sg.Button(
"Mark Out", # "Mark Out",
key=self.gui_mask_markup, # key=self.gui_mask_markup,
button_color="#6f4ca1", # button_color="#6f4ca1",
tooltip="Mark out stuff that is not your eye.", # tooltip="Mark out stuff that is not your eye.",
), # ),
sg.Button( # sg.Button(
"Lighten", # "Lighten",
key=self.gui_mask_lighten, # key=self.gui_mask_lighten,
button_color="#6f4ca1", # button_color="#6f4ca1",
tooltip="Lighten shadowed areas.", # tooltip="Lighten shadowed areas.",
), # ),
sg.Checkbox( sg.Checkbox(
"Camera Widget Padding", "Camera Widget Padding",
default=self.config.gui_rotation_ui_padding, default=self.config.gui_rotation_ui_padding,
@ -497,23 +497,23 @@ class CameraWidget:
window[self.gui_tracking_fps].update(self._movavg_fps(self.camera.fps)) window[self.gui_tracking_fps].update(self._movavg_fps(self.camera.fps))
window[self.gui_tracking_bps].update(self._movavg_bps(self.camera.bps)) window[self.gui_tracking_bps].update(self._movavg_bps(self.camera.bps))
if event == self.gui_mask_lighten: # if event == self.gui_mask_lighten:
while True: # while True:
try: # try:
maybe_image = self.roi_queue.get(block=False) # maybe_image = self.roi_queue.get(block=False)
imgbytes = cv2.imencode(".ppm", maybe_image[0])[1].tobytes() # imgbytes = cv2.imencode(".ppm", maybe_image[0])[1].tobytes()
image = cv2.imdecode( # image = cv2.imdecode(
np.frombuffer(imgbytes, np.uint8), cv2.IMREAD_COLOR # np.frombuffer(imgbytes, np.uint8), cv2.IMREAD_COLOR
) # )
cv2.imshow("Image", image) # cv2.imshow("Image", image)
cv2.waitKey(1) # cv2.waitKey(1)
cv2.destroyAllWindows() # cv2.destroyAllWindows()
print("lighen") # print("lighen")
except Empty: #except Empty:
pass # pass
if event == self.gui_mask_markup: # if event == self.gui_mask_markup:
print("markup") # print("markup")
if self.in_roi_mode: if self.in_roi_mode:
try: try:
@ -686,6 +686,8 @@ class CameraWidget:
pass pass
else: else:
def back(*args):
pass
try: try:
window[self.gui_roi_message].update(visible=False) window[self.gui_roi_message].update(visible=False)
window[self.gui_output_graph].update(visible=False) window[self.gui_output_graph].update(visible=False)

View File

@ -38,6 +38,9 @@ from settings.algo_settings_widget import AlgoSettingsWidget
from osc.osc import OSCManager from osc.osc import OSCManager
from osc.OSCMessage import OSCMessage from osc.OSCMessage import OSCMessage
from utils.misc_utils import is_nt, resource_path from utils.misc_utils import is_nt, resource_path
import time
import cv2
import numpy as np
if is_nt: if is_nt:
from winotify import Notification from winotify import Notification
@ -258,10 +261,38 @@ def main():
background_color="#292929", background_color="#292929",
) )
while True:
print('main loop')
if config.settings.gui_disable_gui:
timeout = 10 #TODO: test this on windows, on mac im not seeing a negitive side effect
layout = [[sg.Button("Enable GUI")]]
# Create the window
window = sg.Window("Simple Button", layout)
# Event loop to process events and get the values of the inputs
while True:
event, values = window.read()
# If user closes window or clicks the button, break the loop
if event == sg.WINDOW_CLOSED:
break
elif event == "Enable GUI":
print("Button clicked!")
config.settings.gui_disable_gui = False
config.save()
break
# Close the window
window.close()
else:
timeout = 1
# GUI Render loop # GUI Render loop
while True: while True:
# First off, check for any events from the GUI # First off, check for any events from the GUI
event, values = window.read(timeout=1) # this higher timeout saves some cpu usage event, values = window.read(timeout=timeout) # this higher timeout saves some cpu usage
# If we're in either mode and someone hits q, quit immediately # If we're in either mode and someone hits q, quit immediately
if event == "Exit" or event == sg.WIN_CLOSED: if event == "Exit" or event == sg.WIN_CLOSED:
@ -379,6 +410,7 @@ def main():
window[ALGO_SETTINGS_NAME].update(visible=False) window[ALGO_SETTINGS_NAME].update(visible=False)
config.eye_display_id = EyeId.GUIOFF config.eye_display_id = EyeId.GUIOFF
config.save() config.save()
break
else: else:
# Otherwise, render all # Otherwise, render all