diff --git a/EyeTrackApp/config.py b/EyeTrackApp/config.py index 4fe0d7f..6420e3e 100644 --- a/EyeTrackApp/config.py +++ b/EyeTrackApp/config.py @@ -217,11 +217,6 @@ class EyeTrackSettingsConfig(BaseModel): gui_OutputMultiplier: float = 1 gui_use_module: bool = False - #EyeTune - gui_eyetune_maxin: float = 1 - gui_eyetune_maxout: float = 1 - gui_eyetune_maxup: float = 1 - gui_eyetune_maxdown: float = 1 #SmartInversionTracking gui_smartinversion_enabled: bool = False gui_smartinversion_select_right: bool = True diff --git a/EyeTrackApp/osc_calibrate_filter.py b/EyeTrackApp/osc_calibrate_filter.py index ac904d8..9cd05bc 100644 --- a/EyeTrackApp/osc_calibrate_filter.py +++ b/EyeTrackApp/osc_calibrate_filter.py @@ -342,15 +342,6 @@ class cal: else: out_x, out_y = velocity_falloff(self, var, out_x, out_y) - #Clamps the right eye's X values - if self.eye_id == EyeId.LEFT: - out_x = clamp(out_x, -self.settings.gui_eyetune_maxout, self.settings.gui_eyetune_maxin) - #Clamps the left eye's x values - elif self.eye_id == EyeId.RIGHT: - out_x = clamp(out_x, -self.settings.gui_eyetune_maxin, self.settings.gui_eyetune_maxout) - #Clamps both eye's Y values - out_y = clamp(out_y, -self.settings.gui_eyetune_maxdown, self.settings.gui_eyetune_maxup) - try: noisy_point = np.array([float(out_x), float(out_y)]) # fliter our values with a One Euro Filter point_hat = self.one_euro_filter(noisy_point) diff --git a/EyeTrackApp/settings/general_settings_widget.py b/EyeTrackApp/settings/general_settings_widget.py index dc2dea2..e63164e 100644 --- a/EyeTrackApp/settings/general_settings_widget.py +++ b/EyeTrackApp/settings/general_settings_widget.py @@ -31,7 +31,6 @@ from settings.BaseSettings import BaseSettingsWidget from settings.modules.GeneralSettingsModule import GeneralSettingsModule from settings.modules.OneEuroSettingsModule import OneEuroSettingsModule from settings.modules.OSCSettingsModule import OSCSettingsModule -from settings.modules.EyeTuneSettingsModule import EyeTuneSettingsModule from settings.modules.SmartInversionSettingsModule import SmartInversionSettingsModule @@ -42,6 +41,5 @@ class SettingsWidget(BaseSettingsWidget): OneEuroSettingsModule, SmartInversionSettingsModule, OSCSettingsModule, - EyeTuneSettingsModule, ] super().__init__(widget_id, main_config, settings_modules) diff --git a/EyeTrackApp/settings/modules/EyeTuneSettingsModule.py b/EyeTrackApp/settings/modules/EyeTuneSettingsModule.py deleted file mode 100644 index 6319a01..0000000 --- a/EyeTrackApp/settings/modules/EyeTuneSettingsModule.py +++ /dev/null @@ -1,74 +0,0 @@ -from pydantic import AfterValidator -from typing_extensions import Annotated - -from settings.modules.BaseModule import BaseSettingsModule, BaseValidationModel -from settings.constants import BACKGROUND_COLOR -import PySimpleGUI as sg - -from settings.modules.CommonFieldValidators import try_convert_to_float - -class EyeTuneValidationModule(BaseValidationModel): - gui_eyetune_maxin: Annotated[float, AfterValidator(try_convert_to_float)] - gui_eyetune_maxout: Annotated[float, AfterValidator(try_convert_to_float)] - gui_eyetune_maxup: Annotated[float, AfterValidator(try_convert_to_float)] - gui_eyetune_maxdown: Annotated[float, AfterValidator(try_convert_to_float)] - -class EyeTuneSettingsModule(BaseSettingsModule): - def __init__(self, config, widget_id, **kwargs): - super().__init__(config=config, widget_id=widget_id, **kwargs) - self.validation_model = EyeTuneValidationModule - self.gui_eyetune_maxin = f"-gui_eyetune_maxin{widget_id}-" - self.gui_eyetune_maxout = f"-gui_eyetune_maxout{widget_id}-" - self.gui_eyetune_maxup =f"-gui_eyetune_maxup{widget_id}-" - self.gui_eyetune_maxdown =f"-gui_eyetune_maxdown{widget_id}" - - - - def get_layout(self): - return [ - [ - sg.Text("Eye Tuning (Max Rotation):", background_color='#242224'), - ], - [ - sg.Text("In:", background_color=BACKGROUND_COLOR), - sg.InputText( - self.config.gui_eyetune_maxin, - key=self.gui_eyetune_maxin, - size=(0, 10), - tooltip=( - "Sets the maximum allowed inwards rotation" - "\nSet between 0 and 1" - ) - ), - sg.Text("Out:", background_color=BACKGROUND_COLOR), - sg.InputText( - self.config.gui_eyetune_maxout, - key=self.gui_eyetune_maxout, - size=(0, 10), - tooltip=( - "Sets the maximum allowed outwards rotation" - "\nSet between 0 and 1" - ) - ), - sg.Text("Up:", background_color=BACKGROUND_COLOR), - sg.InputText( - self.config.gui_eyetune_maxup, - key=self.gui_eyetune_maxup, - size=(0, 10), - tooltip=( - "Sets the maximum allowed upwards rotation" - "\nSet between 0 and 1" - ) - ), - sg.Text("Down:", background_color=BACKGROUND_COLOR), - sg.InputText( - self.config.gui_eyetune_maxdown, - key=self.gui_eyetune_maxdown, - size=(0, 10), - tooltip=( - "Sets the maximum allowed downwards rotation" - "\nSet between 0 and 1" - ) - ), - ], - ] \ No newline at end of file diff --git a/EyeTrackApp/settings/modules/SmartInversionSettingsModule.py b/EyeTrackApp/settings/modules/SmartInversionSettingsModule.py index dbb940c..6cf9547 100644 --- a/EyeTrackApp/settings/modules/SmartInversionSettingsModule.py +++ b/EyeTrackApp/settings/modules/SmartInversionSettingsModule.py @@ -22,9 +22,9 @@ class SmartInversionSettingsModule(BaseSettingsModule): self.validation_model = SmartInversionValidationModule self.gui_smartinversion_enabled = f"-gui_smartinversion_enabled{widget_id}-" self.gui_smartinversion_select_right = f"-gui_smartinversion_select_right{widget_id}-" - self.gui_smartinversion_frame_count =f"-gui_smartinversion_frame_count{widget_id}" - self.gui_smartinversion_smoothing_rate =f"-gui_smartinversion_smoothing_rate{widget_id}" - self.gui_smartinversion_minthresh =f"-gui_smartinversion_minthresh{widget_id}" + self.gui_smartinversion_frame_count =f"-gui_smartinversion_frame_count{widget_id}-" + self.gui_smartinversion_smoothing_rate =f"-gui_smartinversion_smoothing_rate{widget_id}-" + self.gui_smartinversion_minthresh =f"-gui_smartinversion_minthresh{widget_id}-" self.gui_smartinversion_rotation_clamp =f"-gui_smartinversion_rotation_clamp{widget_id}-" @@ -60,51 +60,47 @@ class SmartInversionSettingsModule(BaseSettingsModule): ) ], [ - sg.Text("Inwards Look Threshold", background_color=BACKGROUND_COLOR), + sg.Text("Inwards Look Threshold", background_color=BACKGROUND_COLOR,tooltip= + "Sets the minimum distance of looking in that's required before state can chaned to cross-eyed." + "\n Lower value will make cross-eye detection more sensitive." + ), sg.InputText( self.config.gui_smartinversion_minthresh, key=self.gui_smartinversion_minthresh, size=(0, 10), - tooltip=( - "Sets the minimum distance of looking in that's required before state can chaned to cross-eyed." - "\n Lower value will make cross-eye detection more sensitive." - ) ), ], [ - sg.Text("Inversion Trigger Frame Count", background_color=BACKGROUND_COLOR), + sg.Text("Inversion Trigger Frame Count", background_color=BACKGROUND_COLOR,tooltip= + "How long it takes to detect you are cross-eyed, or no longer cross-eyed." + "\n Higher number means longer duration before changing in or out of being cross-eyed state." + ), sg.InputText( self.config.gui_smartinversion_frame_count, key=self.gui_smartinversion_frame_count, size=(0, 10), - tooltip=( - "How long it takes to detect you are cross-eyed, or no longer cross-eyed." - "\n Higher number means longer duration before changing in or out of being cross-eyed state." - ) ), ], [ - sg.Text("Smoothing Decay Rate", background_color=BACKGROUND_COLOR), + sg.Text("Smoothing Decay Rate", background_color=BACKGROUND_COLOR,tooltip= + "How quickly eye smoothing decays when you enter or leave a cross-eyed state." + "\nHigher number = shorter smoothing duration." + ), sg.InputText( self.config.gui_smartinversion_smoothing_rate, key=self.gui_smartinversion_smoothing_rate, size=(0, 10), - tooltip=( - "How quickly eye smoothing decays when you enter or leave a cross-eyed state." - "\nHigher number = shorter smoothing duration." - ) ), ], [ - sg.Text("Maximum allowed cross-eye", background_color=BACKGROUND_COLOR), + sg.Text("Maximum allowed cross-eye", background_color=BACKGROUND_COLOR,tooltip= + "Defines the maximum inwards rotation that is output when cross-eyed." + "\n0 = will only look straight ahead \n0.5 = will go a little bit cross-eyed \n1 = maximum hurr durr " + ), sg.InputText( self.config.gui_smartinversion_rotation_clamp, key=self.gui_smartinversion_rotation_clamp, size=(0, 10), - tooltip=( - "Defines the maximum inwards rotation that is output when cross-eyed." - "\n0 = will only look straight ahead \n0.5 = will go a little bit cross-eyed \n1 = maximum hurr durr " - ) ), ], ] \ No newline at end of file diff --git a/EyeTrackApp/utils/smart_inversion.py b/EyeTrackApp/utils/smart_inversion.py index 7aedbe0..bf60b7c 100644 --- a/EyeTrackApp/utils/smart_inversion.py +++ b/EyeTrackApp/utils/smart_inversion.py @@ -41,10 +41,10 @@ def smart_inversion(self, var, out_x, out_y): #Checks if eyes are straight, and then sets eye gaze forward until inversion threshold is met if (0 < var.l_eye_x <= self.settings.gui_smartinversion_minthresh) and (self.settings.gui_smartinversion_minthresh <= var.r_eye_x < 0): - tracked_eye_x = 0 if not self.smartinversion_stare_ahead: self.smartinversion_smoothing_progress = 1 - self.smartinversion_is_inverted = False + self.smartinversion_is_inverted = False + tracked_eye_x = 0 self.smartinversion_stare_ahead = True #Checks if eyes are inverted, and then activates inversion if the conditions have been true for a specified number of frames. @@ -55,12 +55,15 @@ def smart_inversion(self, var, out_x, out_y): if not self.smartinversion_is_inverted: self.smartinversion_smoothing_progress = 1 self.smartinversion_normal_frame_count = 0 + self.smartinversion_is_inverted = True self.smartinversion_stare_ahead = False tracked_eye_x = 0 print(f"Inversion Activated") + elif self.smartinversion_inverted_frame_count > 0: + self.smartinversion_inverted_frame_count = 0 #Checks if the eyes are no longer inverted, and then clears inversion if the conditions haven't been true for a specified number of frames. - elif self.smartinversion_is_inverted and (not (var.l_eye_x > self.settings.gui_smartinversion_minthresh and var.r_eye_x < -self.settings.gui_smartinversion_minthresh)): + if self.smartinversion_is_inverted and (not (var.l_eye_x > self.settings.gui_smartinversion_minthresh and var.r_eye_x < -self.settings.gui_smartinversion_minthresh)): self.smartinversion_normal_frame_count = min(self.smartinversion_normal_frame_count + 1, self.settings.gui_smartinversion_frame_count) if self.smartinversion_normal_frame_count == self.settings.gui_smartinversion_frame_count: @@ -69,6 +72,8 @@ def smart_inversion(self, var, out_x, out_y): self.smartinversion_inverted_frame_count = 0 self.smartinversion_stare_ahead = False print(f"Inversion Cleared") + elif self.smartinversion_normal_frame_count > 0: + self.smartinversion_normal_frame_count = 0 out_x = tracked_eye_x out_y = tracked_eye_y diff --git a/conftest.py b/conftest.py index 653d186..dc8f541 100644 --- a/conftest.py +++ b/conftest.py @@ -75,11 +75,6 @@ def eyetrack_settings_config(): gui_vrc_native=False, gui_pupil_dilation=True, - #EyeTune - gui_eyetune_maxin=1, - gui_eyetune_maxout=1, - gui_eyetune_maxup=1, - gui_eyetune_maxdown=1, #Smart Inversion Tracking gui_smartinversion_enabled=False, gui_smartinversion_select_right=True,