From 79647ad024d124a988f42f56cac228e35a132392 Mon Sep 17 00:00:00 2001 From: Prohurtz <48768484+RedHawk989@users.noreply.github.com> Date: Mon, 19 Dec 2022 18:13:56 -0800 Subject: [PATCH] add algo toggles and rename blob --- EyeTrackApp/config.py | 4 +++- EyeTrackApp/eye_processor.py | 20 ++++++++++++-------- EyeTrackApp/settings_widget.py | 20 +++++++++++++++++--- EyeTrackApp/teyetrack_settings.json | 1 + 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 EyeTrackApp/teyetrack_settings.json diff --git a/EyeTrackApp/config.py b/EyeTrackApp/config.py index 28a3fdd..2e15a46 100644 --- a/EyeTrackApp/config.py +++ b/EyeTrackApp/config.py @@ -22,7 +22,9 @@ class EyeTrackSettingsConfig(BaseModel): gui_flip_x_axis_left: bool = False gui_flip_x_axis_right: bool = False gui_flip_y_axis: bool = False - gui_blob_fallback: bool = True + gui_RANSAC3D: bool = True + gui_HSF: bool = True + gui_BLOB: bool = True gui_min_cutoff: str = "0.0004" gui_speed_coefficient: str = "0.9" gui_osc_address: str = "127.0.0.1" diff --git a/EyeTrackApp/eye_processor.py b/EyeTrackApp/eye_processor.py index f194ca7..3ad255e 100644 --- a/EyeTrackApp/eye_processor.py +++ b/EyeTrackApp/eye_processor.py @@ -934,7 +934,7 @@ class EyeProcessor: ) return True - def blob_tracking_fallback(self): + def BLOB(self): # define circle if self.config.gui_circular_crop: if self.cct == 0: @@ -1356,8 +1356,8 @@ class EyeProcessor: # If we have no convex maidens, we have no pupil, and can't progress from here. Dump back to # using blob tracking. if len(convex_hulls) == 0: - if self.settings.gui_blob_fallback: - self.blob_tracking_fallback() + if self.settings.gui_BLOB: + self.BLOB() else: print("[INFO] Blob fallback disabled. Assuming blink.") self.output_images_and_update(thresh, EyeInformation(InformationOrigin.RANSAC, 0, 0, 0, True)) @@ -1375,7 +1375,7 @@ class EyeProcessor: largest_hull.reshape(-1, 2) ) except: - f = 1 + f = True # Get axis and angle of the ellipse, using pupil labs 2d algos. The next bit of code ranges # from somewhat to completely magic, as most of it happens in native libraries (hence passing @@ -1458,13 +1458,14 @@ class EyeProcessor: # Shove a concatenated image out to the main GUI thread for rendering self.output_images_and_update(thresh, output_info) except: - f = 1 + f = True return f def run(self): while True: + f = False # Check to make sure we haven't been requested to close if self.cancellation_event.is_set(): print("Exiting Tracking thread") @@ -1496,9 +1497,12 @@ class EyeProcessor: try: - f = self.RANSAC3D() - if f == 1 and self.settings.gui_blob_fallback: #if a fail has been reported and other algo is enabled, use it. - self.gui_blob_fallback() + if self.settings.gui_RANSAC3D: #for now ransac goes first + f == self.RANSAC3D() + if f and self.settings.gui_HSF: #if a fail has been reported and other algo is enabled, use it. + f == self.HSF() + if f and self.settings.gui_blob_fallback: + f == self.BLOB() except: print("[WARN] ALL ALGORITHIMS HAVE FAILED OR ARE DISABLED.") diff --git a/EyeTrackApp/settings_widget.py b/EyeTrackApp/settings_widget.py index 3245796..a15d6c3 100644 --- a/EyeTrackApp/settings_widget.py +++ b/EyeTrackApp/settings_widget.py @@ -20,7 +20,9 @@ class SettingsWidget: self.gui_osc_receiver_port = f"OSCRECEIVERPORT{widget_id}-" self.gui_osc_recenter_address = f"OSCRECENTERADDRESS{widget_id}-" self.gui_osc_recalibrate_address = f"OSCRECALIBRATEADDRESS{widget_id}-" - self.gui_blob_fallback = f"-BLOBFALLBACK{widget_id}-" + self.gui_BLOB = f"-BLOBFALLBACK{widget_id}-" + self.gui_HSF = f"-HSF{widget_id}-" + self.gui_RANSAC3D = f"-RANSAC3D{widget_id}-" self.gui_blob_maxsize = f"-BLOBMAXSIZE{widget_id}-" self.gui_blob_minsize = f"-BLOBMINSIZE{widget_id}-" self.gui_speed_coefficient = f"-SPEEDCOEFFICIENT{widget_id}-" @@ -76,9 +78,21 @@ class SettingsWidget: ], [sg.Checkbox( + "RANSAC 3D", + default=self.config.gui_RANSAC3D, + key=self.gui_RANSAC3D, + background_color='#424042', + ), + sg.Checkbox( + "Haar Surround Feature", + default=self.config.gui_HSF, + key=self.gui_HSF, + background_color='#424042', + ), + sg.Checkbox( "Blob Fallback", - default=self.config.gui_blob_fallback, - key=self.gui_blob_fallback, + default=self.config.gui_BLOB, + key=self.gui_BLOB, background_color='#424042', ), ], diff --git a/EyeTrackApp/teyetrack_settings.json b/EyeTrackApp/teyetrack_settings.json new file mode 100644 index 0000000..f955458 --- /dev/null +++ b/EyeTrackApp/teyetrack_settings.json @@ -0,0 +1 @@ +{"version": 1, "right_eye": {"threshold": 53, "rotation_angle": 334, "roi_window_x": 134, "roi_window_y": 104, "roi_window_w": 132, "roi_window_h": 77, "focal_length": 30, "capture_source": "http://192.168.0.238/", "gui_circular_crop": false}, "left_eye": {"threshold": 82, "rotation_angle": 46, "roi_window_x": 117, "roi_window_y": 118, "roi_window_w": 120, "roi_window_h": 154, "focal_length": 30, "capture_source": "http://192.168.0.62", "gui_circular_crop": false}, "settings": {"gui_flip_x_axis_left": false, "gui_flip_x_axis_right": false, "gui_flip_y_axis": false, "gui_blob_fallback": true, "gui_min_cutoff": "0.0004", "gui_speed_coefficient": "0.9", "gui_osc_address": "127.0.0.1", "gui_osc_port": 9000, "gui_osc_receiver_port": 9001, "gui_osc_recenter_address": "/avatar/parameters/etvr_recenter", "gui_osc_recalibrate_address": "/avatar/parameters/etvr_recalibrate", "gui_blob_maxsize": 25.0, "gui_blob_minsize": 10.0, "gui_recenter_eyes": false, "gui_eye_falloff": false, "tracker_single_eye": 0, "gui_blink_sync": false}, "eye_display_id": 2} \ No newline at end of file