diff --git a/EyeTrackApp/algo_settings_widget.py b/EyeTrackApp/algo_settings_widget.py index e1d8942..3cbfaf1 100644 --- a/EyeTrackApp/algo_settings_widget.py +++ b/EyeTrackApp/algo_settings_widget.py @@ -52,7 +52,9 @@ class AlgoSettingsWidget: self.ibo_filter_samples = f"-IBOFILTERSAMPLE{widget_id}-" self.calibration_samples = f"-CALIBRATIONSAMPLES{widget_id}-" self.ibo_fully_close_eye_threshold = f"-CLOSETHRESH{widget_id}-" - + self.gui_legacy_ransac = f"-LEGACYRANSACTHRESH{widget_id}-" + self.gui_legacy_ransac_thresh_right = f"-THRESHRIGHT{widget_id}-" + self.gui_legacy_ransac_thresh_left = f"-THRESHLEFT{widget_id}-" self.main_config = main_config self.config = main_config.settings self.osc_queue = osc_queue @@ -133,6 +135,12 @@ class AlgoSettingsWidget: tooltip="Select the priority of eyetracking algorithms.", ), sg.Text("RANSAC 3D", background_color='#424042'), + sg.Checkbox( + "Legacy RANSAC Thresh", + default=self.config.gui_legacy_ransac, + key=self.gui_legacy_ransac, + background_color='#424042', + ), ], [ sg.Checkbox( @@ -301,8 +309,27 @@ class AlgoSettingsWidget: background_color='#424042', tooltip="Maximum size a blob can be for blob tracking.", ), - ], + [ + sg.Text("Right Eye Thresh:", background_color='#424042'), + sg.Slider( + range=(1, 120), + default_value=self.config.gui_legacy_ransac_thresh_right, + orientation="h", + key=self.gui_legacy_ransac_thresh_right, + background_color='#424042', + tooltip="Threshold for right eye, legacy RANSAC only", + ), + sg.Text("Left Eye Thresh:", background_color='#424042'), + sg.Slider( + range=(1, 120), + default_value=self.config.gui_legacy_ransac_thresh_left, + orientation="h", + key=self.gui_legacy_ransac_thresh_left, + background_color='#424042', + tooltip="Threshold for left eye, legacy RANSAC only", + ), + ], ] @@ -364,6 +391,10 @@ class AlgoSettingsWidget: self.config.gui_RANSAC3D = values[self.gui_RANSAC3D] changed = True + if self.config.gui_legacy_ransac != values[self.gui_legacy_ransac]: + self.config.gui_legacy_ransac = values[self.gui_legacy_ransac] + changed = True + if self.config.gui_HSRACP != int(values[self.gui_HSRACP]): self.config.gui_HSRACP = int(values[self.gui_HSRACP]) changed = True @@ -444,6 +475,14 @@ class AlgoSettingsWidget: self.config.calibration_samples = int(values[self.calibration_samples]) changed = True + if self.config.gui_legacy_ransac_thresh_left != int(values[self.gui_legacy_ransac_thresh_left]): + self.config.gui_legacy_ransac_thresh_left = int(values[self.gui_legacy_ransac_thresh_left]) + changed = True + + if self.config.gui_legacy_ransac_thresh_right != int(values[self.gui_legacy_ransac_thresh_right]): + self.config.gui_legacy_ransac_thresh_right = int(values[self.gui_legacy_ransac_thresh_right]) + changed = True + if changed: self.main_config.save() # print(self.main_config) diff --git a/EyeTrackApp/config.py b/EyeTrackApp/config.py index d0a0f3b..357a840 100644 --- a/EyeTrackApp/config.py +++ b/EyeTrackApp/config.py @@ -75,6 +75,10 @@ class EyeTrackSettingsConfig(BaseModel): osc_left_eye_close_address: str = "/avatar/parameters/LeftEyeLidExpandedSqueeze" osc_invert_eye_close: bool = False gui_RANSACBLINK: bool = True + gui_legacy_ransac: bool = False + gui_legacy_ransac_thresh_right: int = 80 + gui_legacy_ransac_thresh_left: int = 80 + class EyeTrackConfig(BaseModel): diff --git a/EyeTrackApp/ransac.py b/EyeTrackApp/ransac.py index 51d7c54..db9c6d2 100644 --- a/EyeTrackApp/ransac.py +++ b/EyeTrackApp/ransac.py @@ -221,8 +221,14 @@ def RANSAC3D(self, hsrac_en): # crop 15% sqare around min_loc # frame_gray = frame_gray[max_loc[1] - maxloc1_hf:max_loc[1] + maxloc1_hf, # max_loc[0] - maxloc0_hf:max_loc[0] + maxloc0_hf] - - threshold_value = min_val + self.settings.gui_thresh_add + if self.settings.gui_legacy_ransac: + if self.eye_id in [EyeId.LEFT]: + threshold_value = self.settings.gui_legacy_ransac_thresh_right + else: + threshold_value = self.settings.gui_legacy_ransac_thresh_right + else: + threshold_value = min_val + self.settings.gui_thresh_add + _, thresh = cv2.threshold(frame_gray, threshold_value, 255, cv2.THRESH_BINARY) try: opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel)