Add minimum inwards threshold

This commit is contained in:
Blabzillaweasel 2025-02-08 21:40:40 +13:00
parent 1b7e3d88ff
commit 9331a5dca4
4 changed files with 21 additions and 4 deletions

View File

@ -220,9 +220,10 @@ class EyeTrackSettingsConfig(BaseModel):
#SmartInversionTracking
gui_smartinversion_enabled: bool = False
gui_smartinversion_select_right: bool = True
gui_smartinversion_thresh: float = 0.25
gui_smartinversion_frame_count: int = 10
gui_smartinversion_thresh: float = 0.4
gui_smartinversion_frame_count: int = 30
gui_smartinversion_smoothing_rate: float = 0.025
gui_smartinversion_minthresh: float = 0.3
class EyeTrackConfig(BaseModel):
version: int = 1

View File

@ -14,6 +14,7 @@ class SmartInversionValidationModule(BaseValidationModel):
gui_smartinversion_thresh: Annotated[float, AfterValidator(try_convert_to_float)]
gui_smartinversion_frame_count: Annotated[int, AfterValidator(try_convert_to_int)]
gui_smartinversion_smoothing_rate: Annotated[float, AfterValidator(try_convert_to_float)]
gui_smartinversion_minthresh: Annotated[float, AfterValidator(try_convert_to_float)]
class SmartInversionSettingsModule(BaseSettingsModule):
def __init__(self, config, widget_id, **kwargs):
@ -24,6 +25,8 @@ class SmartInversionSettingsModule(BaseSettingsModule):
self.gui_smartinversion_thresh = f"-gui_smartinversion_thresh{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}"
def get_layout(self):
@ -68,6 +71,18 @@ class SmartInversionSettingsModule(BaseSettingsModule):
)
),
],
[
sg.Text("Inwards Look Threshold", background_color=BACKGROUND_COLOR),
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.InputText(

View File

@ -38,7 +38,7 @@ def smart_inversion(self, var, out_x, out_y):
#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 > 0 and var.r_eye_x < 0) or
not (var.l_eye_x > self.settings.gui_smartinversion_minthresh and var.r_eye_x < -self.settings.gui_smartinversion_minthresh) or
abs(var.l_eye_x - var.r_eye_x) <= self.settings.gui_smartinversion_thresh
):

View File

@ -78,9 +78,10 @@ def eyetrack_settings_config():
#Smart Inversion Tracking
gui_smartinversion_enabled=False,
gui_smartinversion_select_right=True,
gui_smartinversion_thresh=0.5,
gui_smartinversion_thresh=0.4,
gui_smartinversion_frame_count=10,
gui_smartinversion_smoothing_rate=0.025,
gui_smartinversion_minthresh=0.3,
)