an actuall cpu perf increase

This commit is contained in:
Prohurtz 2023-12-19 14:50:39 -08:00
parent 49675dc672
commit 43e86c2ae8
2 changed files with 7 additions and 2 deletions

View File

@ -47,6 +47,7 @@ class CameraWidget:
self.configl = main_config.left_eye self.configl = main_config.left_eye
self.configr = main_config.right_eye self.configr = main_config.right_eye
self.settings = main_config.settings self.settings = main_config.settings
self.update_wait_count = 100
if self.eye_id == EyeId.RIGHT: if self.eye_id == EyeId.RIGHT:
self.config = main_config.right_eye self.config = main_config.right_eye
elif self.eye_id == EyeId.LEFT: elif self.eye_id == EyeId.LEFT:
@ -311,6 +312,7 @@ class CameraWidget:
if event == self.gui_tracking_button: if event == self.gui_tracking_button:
print("\033[94m[INFO] Moving to tracking mode\033[0m") print("\033[94m[INFO] Moving to tracking mode\033[0m")
self.update_wait_count = 100
self.in_roi_mode = False self.in_roi_mode = False
self.camera.set_output_queue(self.capture_queue) self.camera.set_output_queue(self.capture_queue)
window[self.gui_roi_layout].update(visible=False) window[self.gui_roi_layout].update(visible=False)
@ -318,6 +320,7 @@ class CameraWidget:
if event == self.gui_roi_button: if event == self.gui_roi_button:
print("\033[94m[INFO] Move to roi mode\033[0m") print("\033[94m[INFO] Move to roi mode\033[0m")
self.update_wait_count = 100
self.in_roi_mode = True self.in_roi_mode = True
self.camera.set_output_queue(self.roi_queue) self.camera.set_output_queue(self.roi_queue)
window[self.gui_roi_layout].update(visible=True) window[self.gui_roi_layout].update(visible=True)
@ -425,6 +428,8 @@ class CameraWidget:
window[self.gui_output_graph].update(visible=False) window[self.gui_output_graph].update(visible=False)
return return
try: try:
if self.update_wait_count >= 0:
self.update_wait_count = self.update_wait_count - 1
window[self.gui_roi_message].update(visible=False) window[self.gui_roi_message].update(visible=False)
window[self.gui_output_graph].update(visible=True) window[self.gui_output_graph].update(visible=True)
(maybe_image, eye_info) = self.image_queue.get(block=False) (maybe_image, eye_info) = self.image_queue.get(block=False)
@ -478,5 +483,4 @@ class CameraWidget:
if eye_info.info_type != EyeInfoOrigin.FAILURE: if eye_info.info_type != EyeInfoOrigin.FAILURE:
self.osc_queue.put((self.eye_id, eye_info)) self.osc_queue.put((self.eye_id, eye_info))
except Empty: except Empty:
time.sleep(0.01)
pass pass

View File

@ -192,7 +192,7 @@ def main():
# 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=0.1) event, values = window.read(timeout=2)
# 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:
@ -278,6 +278,7 @@ def main():
config.save() config.save()
else: else:
# print('size of queue: ', osc_queue.qsize())
# Otherwise, render all # Otherwise, render all
for eye in eyes: for eye in eyes:
if eye.started(): if eye.started():