8
8
from babble_processor import BabbleProcessor , CamInfoOrigin
9
9
from camera import Camera , CameraState
10
10
from config import BabbleConfig
11
- from landmark_processor import LandmarkProcessor
12
11
from osc import Tab
13
12
from utils .misc_utils import PlaySound , SND_FILENAME , SND_ASYNC , list_camera_names , get_camera_index_by_name
14
13
@@ -68,16 +67,6 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
68
67
self .cam_id ,
69
68
)
70
69
71
- self .babble_landmark = LandmarkProcessor (
72
- self .config ,
73
- self .settings_config ,
74
- self .main_config ,
75
- self .cancellation_event ,
76
- self .capture_event ,
77
- self .capture_queue ,
78
- self .image_queue ,
79
- self .cam_id ,
80
- )
81
70
82
71
self .camera_status_queue = Queue (maxsize = 2 )
83
72
self .camera = Camera (
@@ -92,7 +81,7 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
92
81
93
82
self .roi_layout = [
94
83
[
95
- sg .Button ("Auto ROI " , key = self .gui_autoroi , button_color = '#539e8a' , tooltip = "Automatically set ROI" , ),
84
+ sg .Button ("Select Entire Frame " , key = self .gui_autoroi , button_color = '#539e8a' , tooltip = "Automatically set ROI" , ),
96
85
],
97
86
[
98
87
sg .Graph (
@@ -122,9 +111,10 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
122
111
],
123
112
[
124
113
sg .Button ("Start Calibration" , key = self .gui_restart_calibration , button_color = '#539e8a' ,
125
- tooltip = "Start calibration. Look all arround to all extreams without blinking until sound is heard." , ),
114
+ tooltip = "Neutural Calibration: Hold a relaxed face, press [Start Calibration] and then press [Stop Calibraion]. \n Full Calibration: Press [Start Calibration] and make as many face movements as you can until it switches back to tracking mode or press [Stop Calibration]" , disabled = True ),
115
+
126
116
sg .Button ("Stop Calibration" , key = self .gui_stop_calibration , button_color = '#539e8a' ,
127
- tooltip = "Stop calibration manualy." , ),
117
+ tooltip = "Stop calibration manualy." , disabled = True ),
128
118
],
129
119
[
130
120
sg .Checkbox (
@@ -133,6 +123,7 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
133
123
key = self .use_calibration ,
134
124
background_color = '#424042' ,
135
125
tooltip = "Checked = Calibrated model output. Unchecked = Raw model output" ,
126
+ enable_events = True
136
127
),
137
128
],
138
129
[
@@ -197,7 +188,7 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
197
188
198
189
def _movavg_fps (self , next_fps ):
199
190
self .movavg_fps_queue .append (next_fps )
200
- fps = round (sum (self .movavg_fps_queue ) / len (self .movavg_fps_queue ))
191
+ fps = round (sum (self .movavg_fps_queue ) / len (self .movavg_fps_queue ))
201
192
millisec = round ((1 / fps if fps else 0 ) * 1000 )
202
193
return f"{ fps } Fps { millisec } ms"
203
194
@@ -283,7 +274,6 @@ def render(self, window, event, values):
283
274
self .config .rotation_angle = int (values [self .gui_rotation_slider ])
284
275
changed = True
285
276
286
- #print(self.config.gui_vertical_flip)
287
277
if self .config .gui_vertical_flip != values [self .gui_vertical_flip ]:
288
278
self .config .gui_vertical_flip = values [self .gui_vertical_flip ]
289
279
changed = True
@@ -313,6 +303,17 @@ def render(self, window, event, values):
313
303
window [self .gui_roi_layout ].update (visible = True )
314
304
window [self .gui_tracking_layout ].update (visible = False )
315
305
306
+ if event == self .use_calibration :
307
+ print ("toggle event" )
308
+ if self .settings_config .use_calibration == True :
309
+ window [self .gui_restart_calibration ].update (disabled = False )
310
+ window [self .gui_stop_calibration ].update (disabled = False )
311
+ print ("Enabled" )
312
+ else :
313
+ window [self .gui_restart_calibration ].update (disabled = True )
314
+ window [self .gui_stop_calibration ].update (disabled = True )
315
+ print ("Disabled" )
316
+
316
317
if event == "{}+UP" .format (self .gui_roi_selection ):
317
318
# Event for mouse button up in ROI mode
318
319
self .is_mouse_up = True
@@ -334,19 +335,30 @@ def render(self, window, event, values):
334
335
self .x0 , self .y0 = values [self .gui_roi_selection ]
335
336
self .x1 , self .y1 = values [self .gui_roi_selection ]
336
337
338
+ if event == self .gui_autoroi :
339
+ print ("Set ROI" )
340
+ output = self .babble_cnn .get_framesize ()
341
+ self .config .roi_window_x = 0
342
+ self .config .roi_window_y = 0
343
+ self .config .roi_window_w = output [0 ]
344
+ self .config .roi_window_h = output [1 ]
345
+ self .main_config .save ()
346
+
337
347
if (event == self .gui_refresh_button ):
338
- print ("Refreshed Cameralist " )
348
+ print ("\033 [94m[INFO] Refreshed Camera List \033 [0m " )
339
349
self .camera_list = list_camera_names ()
340
350
print (self .camera_list )
341
351
window [self .gui_camera_addr ].update (values = self .camera_list )
342
352
343
353
344
354
if event == self .gui_restart_calibration :
345
- self .babble_cnn .calibration_frame_counter = 1500
346
- PlaySound ('Audio/start.wav' , SND_FILENAME | SND_ASYNC )
355
+ if values [self .use_calibration ] == True : # Don't start recording if the calibration filter is disabled.
356
+ self .babble_cnn .calibration_frame_counter = 1500
357
+ PlaySound ('Audio/start.wav' , SND_FILENAME | SND_ASYNC )
347
358
348
359
if event == self .gui_stop_calibration :
349
- self .babble_cnn .calibration_frame_counter = 0
360
+ if self .babble_cnn .calibration_frame_counter != None : # Only assign the variable if we are in calibration mode.
361
+ self .babble_cnn .calibration_frame_counter = 0
350
362
351
363
needs_roi_set = self .config .roi_window_h <= 0 or self .config .roi_window_w <= 0
352
364
0 commit comments