WIP: refactor algo settings into modules

This commit is contained in:
lorow 2023-10-05 00:44:47 +02:00
parent c93e279157
commit ff5974ec8d
5 changed files with 406 additions and 465 deletions

View File

@ -8,342 +8,14 @@ from threading import Event
class AlgoSettingsWidget:
def __init__(
self, widget_id: EyeId, main_config: EyeTrackConfig, osc_queue: Queue
self, widget_id: EyeId, main_config: EyeTrackConfig
):
self.gui_flip_x_axis_left = f"-FLIPXAXISLEFT{widget_id}-"
self.gui_flip_x_axis_right = f"-FLIPXAXISRIGHT{widget_id}-"
self.gui_flip_y_axis = f"-FLIPYAXIS{widget_id}-"
self.gui_general_settings_layout = f"-GENERALSETTINGSLAYOUT{widget_id}-"
self.gui_osc_address = f"-OSCADDRESS{widget_id}-"
self.gui_osc_port = f"-OSCPORT{widget_id}-"
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 = f"-BLOBFALLBACK{widget_id}-"
self.gui_HSF = f"-HSF{widget_id}-"
self.gui_DADDY = f"-DADDY{widget_id}-"
self.gui_DADDYP = f"-DADDYP{widget_id}-"
self.gui_LEAPP = f"-LEAPP{widget_id}-"
self.gui_LEAP = f"-LEAP{widget_id}-"
self.gui_RANSAC3D = f"-RANSAC3D{widget_id}-"
self.gui_BLINK = f"-BLINK{widget_id}-"
self.gui_IBO = f"-IBO{widget_id}-"
self.gui_HSRAC = f"-HSRAC{widget_id}-"
self.gui_HSF_radius = f"-HSFRADIUS{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}-"
self.gui_min_cutoff = f"-MINCUTOFF{widget_id}-"
self.gui_eye_falloff = f"-EYEFALLOFF{widget_id}-"
self.gui_skip_autoradius = f"-SKIPAUTORADIUS{widget_id}-"
self.gui_HSRACP = f"-HSRACP{widget_id}-"
self.gui_RANSAC3DP = f"-RANSAC3DP{widget_id}-"
self.gui_HSFP = f"-HSFP{widget_id}-"
self.gui_BLOBP = f"-BLOBP{widget_id}-"
self.gui_thresh_add = f"-THRESHADD{widget_id}-"
self.gui_ROSC = f"-ROSC{widget_id}-"
self.gui_RANSACBLINK = f"-RANSACBLINK{widget_id}-"
self.gui_vrc_native = f"-VRCNATIVE{widget_id}-"
self.gui_circular_crop_left = f"-CIRCLECROPLEFT{widget_id}-"
self.gui_circular_crop_right = f"-CIRCLECROPRIGHT{widget_id}-"
self.gui_update_check = f"-UPDATECHECK{widget_id}-"
self.gui_threshold_slider = f"-BLOBTHRESHOLD{widget_id}-"
self.gui_HSF_radius_left = f"-HSFRADIUSLEFT{widget_id}-"
self.gui_HSF_radius_right = f"-HSFRADIUSRIGHT{widget_id}-"
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.gui_LEAP_lid = f"-LEAPLID{widget_id}-"
self.main_config = main_config
self.config = main_config.settings
self.osc_queue = osc_queue
# Define the window's contents
self.general_settings_layout = [
[
sg.Checkbox(
"",
default=self.config.gui_HSRAC,
key=self.gui_HSRAC,
background_color="#424042",
tooltip="Our flagship algorithm, utilizing both HSF and RANSAC for best tracking quality and lighting resistance.",
),
sg.Combo(
["1", "2", "3", "4", "5", "6"],
default_value=self.config.gui_HSRACP,
key=self.gui_HSRACP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("HSRAC", background_color="#424042"),
# ],
# [
sg.Checkbox(
"",
default=self.config.gui_HSF,
key=self.gui_HSF,
background_color="#424042",
tooltip="HSF Is a new, lower resolution tracking algorithim that provides excelent resilancy to lighting conditions and great speed.",
),
sg.Combo(
["1", "2", "3", "4", "5", "6"],
default_value=self.config.gui_HSFP,
key=self.gui_HSFP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithims.",
),
sg.Text("Haar Surround Feature", background_color="#424042"),
],
[
sg.Checkbox(
"",
default=self.config.gui_DADDY,
key=self.gui_DADDY,
background_color="#424042",
tooltip="DADDY Uses a Deep learning algorithm. This has a big CPU usage impact.",
),
sg.Combo(
["1", "2", "3", "4", "5", "6"],
default_value=self.config.gui_DADDYP,
key=self.gui_DADDYP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("DADDY", background_color="#424042"),
# ],
# [
sg.Checkbox(
"",
default=self.config.gui_RANSAC3D,
key=self.gui_RANSAC3D,
background_color="#424042",
tooltip="RANSAC3D provides good tracking quality, however does not do well in bad lighting conditions.",
),
sg.Combo(
["1", "2", "3", "4", "5", "6"],
default_value=self.config.gui_RANSAC3DP,
key=self.gui_RANSAC3DP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
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(
"",
default=self.config.gui_LEAP,
key=self.gui_LEAP,
background_color="#424042",
tooltip="LEAP Uses a lightweight deep learning algorithm.",
),
sg.Combo(
["1", "2", "3", "4", "5", "6"],
default_value=self.config.gui_LEAPP,
key=self.gui_LEAPP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("LEAP", background_color="#424042"),
sg.Checkbox(
"",
default=self.config.gui_BLOB,
key=self.gui_BLOB,
background_color="#424042",
tooltip="Blob tracking is the oldest and worst tracking algorithm, it provides fast, though sometimes inaccurate tracking.",
),
sg.Combo(
["1", "2", "3", "4", "5", "6"],
default_value=self.config.gui_BLOBP,
key=self.gui_BLOBP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("Blob", background_color="#424042"),
],
[sg.Text("Blink Algo Settings:", background_color="#242224")],
[
sg.Checkbox(
"Intensity Based Openness",
default=self.config.gui_IBO,
key=self.gui_IBO,
background_color="#424042",
),
sg.Checkbox(
"RANSAC Quick Blink Algo",
default=self.config.gui_RANSACBLINK,
key=self.gui_RANSACBLINK,
background_color="#424042",
),
sg.Checkbox(
"Binary Blink Algo",
default=self.config.gui_BLINK,
key=self.gui_BLINK,
background_color="#424042",
),
sg.Checkbox(
"LEAP Lid",
default=self.config.gui_LEAP_lid,
key=self.gui_LEAP_lid,
background_color="#424042",
),
],
[
sg.Text("IBO Filter Sample Size", background_color="#424042"),
sg.InputText(
self.config.ibo_filter_samples,
key=self.ibo_filter_samples,
size=(0, 10),
),
sg.Text("Calibration Samples", background_color="#424042"),
sg.InputText(
self.config.calibration_samples,
key=self.calibration_samples,
size=(0, 10),
),
sg.Text("IBO Close Threshold", background_color="#424042"),
sg.InputText(
self.config.ibo_fully_close_eye_threshold,
key=self.ibo_fully_close_eye_threshold,
size=(0, 10),
),
],
[
sg.Checkbox(
"Left Eye Circle crop",
default=self.config.gui_circular_crop_left,
key=self.gui_circular_crop_left,
background_color="#424042",
),
sg.Checkbox(
"Right Eye Circle crop",
default=self.config.gui_circular_crop_right,
key=self.gui_circular_crop_right,
background_color="#424042",
),
],
[
sg.Text(
"Advanced Tracking Algorithim Settings:", background_color="#242224"
)
],
[
sg.Checkbox(
"HSF: Skip Auto Radius",
default=self.config.gui_skip_autoradius,
key=self.gui_skip_autoradius,
background_color="#424042",
tooltip="To gain more control and possibly better tracking quality of HSF, please disable auto radius to enable manual adjustment.",
),
],
[
sg.Text("Left HSF Radius:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_HSF_radius_left,
orientation="h",
key=self.gui_HSF_radius_left,
background_color="#424042",
tooltip="Adjusts the radius parameter for HSF. Only adjust if you are having tracking issues.",
),
sg.Text("Right HSF Radius:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_HSF_radius_right,
orientation="h",
key=self.gui_HSF_radius_right,
background_color="#424042",
tooltip="Adjusts the radius parameter for HSF. Only adjust if you are having tracking issues.",
),
],
[
sg.Text("RANSAC Thresh Add", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_thresh_add,
orientation="h",
key=self.gui_thresh_add,
background_color="#424042",
tooltip="Adjusts the amount of threshold to add to RANSAC. Useful for fine tuning your setup.",
),
sg.Text("Blob Threshold", background_color="#424042"),
# TODO make this for right and left eyes? I dont know how vital that is..
sg.Slider(
range=(0, 110),
default_value=self.config.gui_threshold,
orientation="h",
key=self.gui_threshold_slider,
background_color="#424042",
tooltip="Adjusts the threshold for blob tracking.",
),
],
[
sg.Text("Min Blob Size:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_blob_minsize,
orientation="h",
key=self.gui_blob_minsize,
background_color="#424042",
tooltip="Minimum size a blob has to be for blob tracking.",
),
sg.Text("Max Blob Size:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_blob_maxsize,
orientation="h",
key=self.gui_blob_maxsize,
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",
),
],
]
self.widget_layout = [
@ -386,140 +58,5 @@ class AlgoSettingsWidget:
# If anything has changed in our configuration settings, change/update those.
changed = False
if self.config.gui_HSFP != int(values[self.gui_HSFP]):
self.config.gui_HSFP = int(values[self.gui_HSFP])
changed = True
if self.config.gui_HSF != values[self.gui_HSF]:
self.config.gui_HSF = values[self.gui_HSF]
changed = True
if self.config.gui_DADDYP != int(values[self.gui_DADDYP]):
self.config.gui_DADDYP = int(values[self.gui_DADDYP])
changed = True
if self.config.gui_DADDY != values[self.gui_DADDY]:
self.config.gui_DADDY = values[self.gui_DADDY]
changed = True
if self.config.gui_RANSAC3DP != int(
values[self.gui_RANSAC3DP]
): # TODO check that priority order is unique/auto fix it.
self.config.gui_RANSAC3DP = int(values[self.gui_RANSAC3DP])
changed = True
if self.config.gui_RANSAC3D != values[self.gui_RANSAC3D]:
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
if self.config.gui_HSRAC != values[self.gui_HSRAC]:
self.config.gui_HSRAC = values[self.gui_HSRAC]
changed = True
if self.config.gui_LEAPP != int(values[self.gui_LEAPP]):
self.config.gui_LEAPP = int(values[self.gui_LEAPP])
changed = True
if self.config.gui_LEAP != values[self.gui_LEAP]:
self.config.gui_LEAP = values[self.gui_LEAP]
changed = True
if self.config.gui_skip_autoradius != values[self.gui_skip_autoradius]:
self.config.gui_skip_autoradius = values[self.gui_skip_autoradius]
changed = True
if self.config.gui_BLINK != values[self.gui_BLINK]:
self.config.gui_BLINK = values[self.gui_BLINK]
changed = True
if self.config.gui_IBO != values[self.gui_IBO]:
self.config.gui_IBO = values[self.gui_IBO]
changed = True
if self.config.gui_RANSACBLINK != values[self.gui_RANSACBLINK]:
self.config.gui_RANSACBLINK = values[self.gui_RANSACBLINK]
changed = True
if self.config.gui_LEAP_lid != values[self.gui_LEAP_lid]:
self.config.gui_LEAP_lid = values[self.gui_LEAP_lid]
changed = True
if self.config.gui_circular_crop_left != values[self.gui_circular_crop_left]:
self.config.gui_circular_crop_left = values[self.gui_circular_crop_left]
changed = True
if self.config.gui_circular_crop_right != values[self.gui_circular_crop_right]:
self.config.gui_circular_crop_right = values[self.gui_circular_crop_right]
changed = True
if self.config.gui_HSF_radius_left != int(values[self.gui_HSF_radius_left]):
self.config.gui_HSF_radius_left = int(values[self.gui_HSF_radius_left])
changed = True
if self.config.gui_HSF_radius_right != int(values[self.gui_HSF_radius_right]):
self.config.gui_HSF_radius_right = int(values[self.gui_HSF_radius_right])
changed = True
if self.config.gui_BLOB != values[self.gui_BLOB]:
self.config.gui_BLOB = values[self.gui_BLOB]
changed = True
if self.config.gui_BLOBP != int(values[self.gui_BLOBP]):
self.config.gui_BLOBP = int(values[self.gui_BLOBP])
changed = True
if self.config.gui_threshold != values[self.gui_threshold_slider]:
self.config.gui_threshold = int(values[self.gui_threshold_slider])
changed = True
if self.config.gui_thresh_add != values[self.gui_thresh_add]:
self.config.gui_thresh_add = int(values[self.gui_thresh_add])
changed = True
if self.config.gui_blob_maxsize != values[self.gui_blob_maxsize]:
self.config.gui_blob_maxsize = values[self.gui_blob_maxsize]
changed = True
if self.config.ibo_filter_samples != int(values[self.ibo_filter_samples]):
self.config.ibo_filter_samples = int(values[self.ibo_filter_samples])
changed = True
if self.config.ibo_fully_close_eye_threshold != float(
values[self.ibo_fully_close_eye_threshold]
):
self.config.ibo_fully_close_eye_threshold = float(
values[self.ibo_fully_close_eye_threshold]
)
changed = True
if self.config.calibration_samples != int(values[self.calibration_samples]):
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()
self.osc_queue.put(EyeId.ALGOSETTINGS)

View File

@ -91,7 +91,7 @@ def main():
settings = [
SettingsWidget(EyeId.SETTINGS, config),
AlgoSettingsWidget(EyeId.ALGOSETTINGS, config, osc_queue),
AlgoSettingsWidget(EyeId.ALGOSETTINGS, config),
]
layout = [

View File

@ -0,0 +1,129 @@
from settings.modules.BaseModule import BaseSettingsModule, BaseValidationModel
import PySimpleGUI as sg
class AdvancedTrackingAlgoSettingsValidationModel(BaseValidationModel):
gui_HSF_radius: int
gui_HSF_radius_left: int
gui_HSF_radius_right: int
gui_blob_maxsize: int
gui_blob_minsize: int
gui_legacy_ransac_thresh_left: int
gui_legacy_ransac_thresh_right: int
gui_skip_autoradius: bool
gui_thresh_add: int
gui_threshold_slider: int
gui_update_check: int
class GeneralSettingsModule(BaseSettingsModule):
def __init__(self, config, widget_id, settings_base_class, **kwargs):
super().__init__(config, widget_id, settings_base_class, **kwargs)
self.validation_model = AdvancedTrackingAlgoSettingsValidationModel
self.gui_HSF_radius = f"-HSFRADIUS{widget_id}-"
self.gui_blob_maxsize = f"-BLOBMAXSIZE{widget_id}-"
self.gui_blob_minsize = f"-BLOBMINSIZE{widget_id}-"
self.gui_skip_autoradius = f"-SKIPAUTORADIUS{widget_id}-"
self.gui_thresh_add = f"-THRESHADD{widget_id}-"
self.gui_update_check = f"-UPDATECHECK{widget_id}-"
self.gui_threshold_slider = f"-BLOBTHRESHOLD{widget_id}-"
self.gui_HSF_radius_left = f"-HSFRADIUSLEFT{widget_id}-"
self.gui_HSF_radius_right = f"-HSFRADIUSRIGHT{widget_id}-"
self.gui_legacy_ransac_thresh_right = f"-THRESHRIGHT{widget_id}-"
self.gui_legacy_ransac_thresh_left = f"-THRESHLEFT{widget_id}-"
def get_layout(self):
return [
[
sg.Checkbox(
"HSF: Skip Auto Radius",
default=self.config.gui_skip_autoradius,
key=self.gui_skip_autoradius,
background_color="#424042",
tooltip="To gain more control and possibly better tracking quality of HSF, please disable auto radius to enable manual adjustment.",
),
],
[
sg.Text("Left HSF Radius:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_HSF_radius_left,
orientation="h",
key=self.gui_HSF_radius_left,
background_color="#424042",
tooltip="Adjusts the radius parameter for HSF. Only adjust if you are having tracking issues.",
),
sg.Text("Right HSF Radius:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_HSF_radius_right,
orientation="h",
key=self.gui_HSF_radius_right,
background_color="#424042",
tooltip="Adjusts the radius parameter for HSF. Only adjust if you are having tracking issues.",
),
],
[
sg.Text("RANSAC Thresh Add", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_thresh_add,
orientation="h",
key=self.gui_thresh_add,
background_color="#424042",
tooltip="Adjusts the amount of threshold to add to RANSAC. Useful for fine tuning your setup.",
),
sg.Text("Blob Threshold", background_color="#424042"),
# TODO make this for right and left eyes? I dont know how vital that is..
sg.Slider(
range=(0, 110),
default_value=self.config.gui_threshold,
orientation="h",
key=self.gui_threshold_slider,
background_color="#424042",
tooltip="Adjusts the threshold for blob tracking.",
),
],
[
sg.Text("Min Blob Size:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_blob_minsize,
orientation="h",
key=self.gui_blob_minsize,
background_color="#424042",
tooltip="Minimum size a blob has to be for blob tracking.",
),
sg.Text("Max Blob Size:", background_color="#424042"),
sg.Slider(
range=(1, 50),
default_value=self.config.gui_blob_maxsize,
orientation="h",
key=self.gui_blob_maxsize,
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",
),
],
]

View File

@ -0,0 +1,101 @@
from settings.modules.BaseModule import BaseSettingsModule, BaseValidationModel
import PySimpleGUI as sg
class BlinkAlgoSettingsValidationModel(BaseValidationModel):
gui_IBO: bool
gui_RANSACBLINK: bool
gui_BLINK: bool
gui_LEAP_lid: bool
ibo_filter_samples: int
calibration_samples: int
ibo_fully_close_eye_threshold: str
gui_circular_crop_left: bool
gui_circular_crop_right: bool
class GeneralSettingsModule(BaseSettingsModule):
def __init__(self, config, widget_id, settings_base_class, **kwargs):
super().__init__(config, widget_id, settings_base_class, **kwargs)
self.validation_model = BlinkAlgoSettingsValidationModel
self.gui_IBO = f"-IBO{widget_id}-"
self.gui_RANSACBLINK = f"-RANSACBLINK{widget_id}-"
self.gui_BLINK = f"-BLINK{widget_id}-"
self.gui_LEAP_lid = f"-LEAPLID{widget_id}-"
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_circular_crop_left = f"-CIRCLECROPLEFT{widget_id}-"
self.gui_circular_crop_right = f"-CIRCLECROPRIGHT{widget_id}-"
def get_layout(self):
return [
[
sg.Text(
"Blink Algo Settings:",
background_color="#242224",
)
],
[sg.Text("Blink Algo Settings:", background_color="#242224")],
[
sg.Checkbox(
"Intensity Based Openness",
default=self.config.gui_IBO,
key=self.gui_IBO,
background_color="#424042",
),
sg.Checkbox(
"RANSAC Quick Blink Algo",
default=self.config.gui_RANSACBLINK,
key=self.gui_RANSACBLINK,
background_color="#424042",
),
sg.Checkbox(
"Binary Blink Algo",
default=self.config.gui_BLINK,
key=self.gui_BLINK,
background_color="#424042",
),
sg.Checkbox(
"LEAP Lid",
default=self.config.gui_LEAP_lid,
key=self.gui_LEAP_lid,
background_color="#424042",
),
],
[
sg.Text("IBO Filter Sample Size", background_color="#424042"),
sg.InputText(
self.config.ibo_filter_samples,
key=self.ibo_filter_samples,
size=(0, 10),
),
sg.Text("Calibration Samples", background_color="#424042"),
sg.InputText(
self.config.calibration_samples,
key=self.calibration_samples,
size=(0, 10),
),
sg.Text("IBO Close Threshold", background_color="#424042"),
sg.InputText(
self.config.ibo_fully_close_eye_threshold,
key=self.ibo_fully_close_eye_threshold,
size=(0, 10),
),
],
[
sg.Checkbox(
"Left Eye Circle crop",
default=self.config.gui_circular_crop_left,
key=self.gui_circular_crop_left,
background_color="#424042",
),
sg.Checkbox(
"Right Eye Circle crop",
default=self.config.gui_circular_crop_right,
key=self.gui_circular_crop_right,
background_color="#424042",
),
],
]

View File

@ -0,0 +1,174 @@
from settings.modules.BaseModule import BaseSettingsModule, BaseValidationModel
import PySimpleGUI as sg
class TrackingAlgorithmValidationModel(BaseValidationModel):
gui_BLOB: bool
gui_DADDY: bool
gui_HSF: bool
gui_HSRAC: bool
gui_LEAP: bool
gui_RANSAC3D: bool
gui_legacy_ransac: bool
gui_BLOBP: int
gui_DADDYP: int
gui_HSFP: int
gui_HSRACP: int
gui_LEAPP: int
gui_RANSAC3DP: int
class GeneralSettingsModule(BaseSettingsModule):
def __init__(self, config, widget_id, settings_base_class, **kwargs):
super().__init__(config, widget_id, settings_base_class, **kwargs)
self.algo_count = ["1", "2", "3", "4", "5", "6"]
self.validation_model = TrackingAlgorithmValidationModel
self.gui_BLOB = f"-BLOBFALLBACK{widget_id}-"
self.gui_DADDY = f"-DADDY{widget_id}-"
self.gui_HSF = f"-HSF{widget_id}-"
self.gui_HSRAC = f"-HSRAC{widget_id}-"
self.gui_LEAP = f"-LEAP{widget_id}-"
self.gui_RANSAC3D = f"-RANSAC3D{widget_id}-"
self.gui_legacy_ransac = f"-LEGACYRANSACTHRESH{widget_id}-"
self.gui_BLOBP = f"-BLOBP{widget_id}-"
self.gui_DADDYP = f"-DADDYP{widget_id}-"
self.gui_HSFP = f"-HSFP{widget_id}-"
self.gui_HSRACP = f"-HSRACP{widget_id}-"
self.gui_LEAPP = f"-LEAPP{widget_id}-"
self.gui_RANSAC3DP = f"-RANSAC3DP{widget_id}-"
# TODO custom validation, make a set of values, count if there's less than overall, if yeah we have a problem
def get_layout(self):
return [
[
sg.Text(
"Tracking Algorithm Order Settings:",
background_color="#242224",
)
],
[
sg.Checkbox(
"",
default=self.config.gui_HSRAC,
key=self.gui_HSRAC,
background_color="#424042",
tooltip="Our flagship algorithm, utilizing both HSF and RANSAC for best tracking quality and lighting resistance.",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_HSRACP,
key=self.gui_HSRACP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("HSRAC", background_color="#424042"),
sg.Checkbox(
"",
default=self.config.gui_HSF,
key=self.gui_HSF,
background_color="#424042",
tooltip="HSF Is a new, lower resolution tracking algorithim that provides excelent resilancy to lighting conditions and great speed.",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_HSFP,
key=self.gui_HSFP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithims.",
),
sg.Text("Haar Surround Feature", background_color="#424042"),
],
[
sg.Checkbox(
"",
default=self.config.gui_DADDY,
key=self.gui_DADDY,
background_color="#424042",
tooltip="DADDY Uses a Deep learning algorithm. This has a big CPU usage impact.",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_DADDYP,
key=self.gui_DADDYP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("DADDY", background_color="#424042"),
# ],
# [
sg.Checkbox(
"",
default=self.config.gui_RANSAC3D,
key=self.gui_RANSAC3D,
background_color="#424042",
tooltip="RANSAC3D provides good tracking quality, however does not do well in bad lighting conditions.",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_RANSAC3DP,
key=self.gui_RANSAC3DP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
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(
"",
default=self.config.gui_LEAP,
key=self.gui_LEAP,
background_color="#424042",
tooltip="LEAP Uses a lightweight deep learning algorithm.",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_LEAPP,
key=self.gui_LEAPP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("LEAP", background_color="#424042"),
sg.Checkbox(
"",
default=self.config.gui_BLOB,
key=self.gui_BLOB,
background_color="#424042",
tooltip="Blob tracking is the oldest and worst tracking algorithm, it provides fast, though sometimes inaccurate tracking.",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_BLOBP,
key=self.gui_BLOBP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("Blob", background_color="#424042"),
],
]