feat: AHSFRAC

This commit is contained in:
Prohurtz 2023-11-11 16:02:30 -06:00
parent f539b02388
commit bdc91313fe
4 changed files with 1141 additions and 17 deletions

1049
EyeTrackApp/AHSF.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,12 +17,12 @@ class EyeTrackCameraConfig(BaseModel):
roi_window_h: int = 240
focal_length: int = 30
capture_source: Union[int, str, None] = None
calib_XMAX: Union[int, None] = None
calib_XMIN: Union[int, None] = None
calib_YMAX: Union[int, None] = None
calib_YMIN: Union[int, None] = None
calib_XOFF: Union[int, None] = None
calib_YOFF: Union[int, None] = None
calib_XMAX: Union[float, None] = None
calib_XMIN: Union[float, None] = None
calib_YMAX: Union[float, None] = None
calib_YMIN: Union[float, None] = None
calib_XOFF: Union[float, None] = None
calib_YOFF: Union[float, None] = None
class EyeTrackSettingsConfig(BaseModel):
@ -34,7 +34,8 @@ class EyeTrackSettingsConfig(BaseModel):
gui_BLOB: bool = False
gui_BLINK: bool = False
gui_HSRAC: bool = False
gui_AHSF: bool = True
gui_AHSFRAC: bool = True
gui_AHSF: bool = False
gui_DADDY: bool = False
gui_LEAP: bool = False
gui_HSF_radius: int = 15
@ -52,13 +53,14 @@ class EyeTrackSettingsConfig(BaseModel):
gui_recenter_eyes: bool = False
tracker_single_eye: int = 0
gui_threshold: int = 65
gui_AHSFP: int = 1
gui_HSRACP: int = 2
gui_HSFP: int = 3
gui_DADDYP: int = 4
gui_RANSAC3DP: int = 5
gui_BLOBP: int = 6
gui_LEAPP: int = 7
gui_AHSFRACP: int = 1
gui_AHSFP: int = 2
gui_HSRACP: int = 3
gui_HSFP: int = 4
gui_DADDYP: int = 5
gui_RANSAC3DP: int = 6
gui_BLOBP: int = 7
gui_LEAPP: int = 8
gui_IBO: bool = True
gui_skip_autoradius: bool = False
gui_thresh_add: int = 11

View File

@ -379,6 +379,46 @@ class EyeProcessor:
)
self.current_algorithm = EyeInfoOrigin.DADDY
def AHSFRACM(self):
if self.eye_id in [EyeId.LEFT] and self.settings.gui_circular_crop_left:
self.current_image_gray, self.cct = circle_crop(
self.current_image_gray, self.xc, self.yc, self.cc_radius, self.cct
)
else:
pass
if self.eye_id in [EyeId.RIGHT] and self.settings.gui_circular_crop_right:
self.current_image_gray, self.cct = circle_crop(
self.current_image_gray, self.xc, self.yc, self.cc_radius, self.cct
)
else:
pass
self.hasrac_en = True
self.current_image, self.rawx, self.rawy, self.radius = External_Run_AHSF(
self.current_image_gray
)
self.thresh = self.current_image_gray
(
self.rawx,
self.rawy,
self.thresh,
ranblink,
self.pupil_width,
self.pupil_height,
) = RANSAC3D(self, True)
if self.settings.gui_RANSACBLINK: # might be redundant
self.eyeopen = ranblink
# print("RANBLINK", ranblink)
# print(self.radius)
# if self.prev_x is None:
# self.prev_x = self.rawx
# self.prev_y = self.rawy
self.out_x, self.out_y, self.avg_velocity = cal.cal_osc(
self, self.rawx, self.rawy
)
self.current_algorithm = EyeInfoOrigin.HSRAC
def HSRACM(self):
if self.eye_id in [EyeId.LEFT] and self.settings.gui_circular_crop_left:
self.current_image_gray, self.cct = circle_crop(
@ -486,7 +526,7 @@ class EyeProcessor:
)
else:
pass
self.current_image, self.rawx, self.rawy = External_Run_AHSF(
self.current_image, self.rawx, self.rawy, self.radius = External_Run_AHSF(
self.current_image_gray
)
self.thresh = self.current_image_gray
@ -545,6 +585,11 @@ class EyeProcessor:
if self.failed == 5 and self.sixthalgo != None:
self.sixthalgo()
if self.failed == 6 and self.seventhalgo != None:
self.seventhalgo()
if self.failed == 7 and self.eigth != None:
self.eigthalgo()
else:
self.failed = 0 # we have reached last possible algo and it is disabled, move to first algo
@ -559,15 +604,18 @@ class EyeProcessor:
self.fithalgo = None
self.sixthalgo = None
self.seventhalgo = None
algolist = [None, None, None, None, None, None, None]
self.eigthalgo = None
algolist = [None, None, None, None, None, None, None, None, None]
# clear HSF values when page is opened to correctly reflect setting changes
self.er_hsf = None
# algolist[self.settings.gui_HSFP] = self.HSFM
# set algo priorities
if self.settings.gui_AHSFRAC:
algolist[self.settings.gui_AHSFRACP] = self.AHSFRACM
if self.settings.gui_AHSF:
print("yippee")
algolist[self.settings.gui_HSFP] = self.AHSFM
if self.settings.gui_HSF:
@ -644,6 +692,8 @@ class EyeProcessor:
self.fourthalgo,
self.fithalgo,
self.sixthalgo,
self.seventhalgo,
self.eighthalgo,
) = algolist
f = True

View File

@ -12,10 +12,12 @@ class TrackingAlgorithmValidationModel(BaseValidationModel):
gui_AHSF: bool
gui_LEAP: bool
gui_RANSAC3D: bool
gui_AHSFRAC: bool
gui_legacy_ransac: bool
gui_BLOBP: int
gui_DADDYP: int
gui_AHSFRACP: int
gui_HSFP: int
gui_AHSFP: int
gui_HSRACP: int
@ -32,6 +34,7 @@ class TrackingAlgorithmValidationModel(BaseValidationModel):
self.gui_HSRACP,
self.gui_LEAPP,
self.gui_RANSAC3DP,
self.gui_AHSFRACP,
]
algos_set = set(algos_list)
if len(algos_set) != len(algos_list):
@ -50,6 +53,7 @@ class TrackingAlgorithmModule(BaseSettingsModule):
self.gui_HSRAC = f"-HSRAC{widget_id}-"
self.gui_LEAP = f"-LEAP{widget_id}-"
self.gui_AHSF = f"-AHSF{widget_id}-"
self.gui_AHSFRAC = f"-gui_AHSFRAC{widget_id}-"
self.gui_RANSAC3D = f"-RANSAC3D{widget_id}-"
self.gui_legacy_ransac = f"-LEGACYRANSACTHRESH{widget_id}-"
@ -60,6 +64,7 @@ class TrackingAlgorithmModule(BaseSettingsModule):
self.gui_LEAPP = f"-LEAPP{widget_id}-"
self.gui_AHSFP = f"-AHSFP{widget_id}-"
self.gui_RANSAC3DP = f"-RANSAC3DP{widget_id}-"
self.gui_AHSFRACP = f"-gui_AHSFRACP{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):
@ -71,6 +76,24 @@ class TrackingAlgorithmModule(BaseSettingsModule):
)
],
[
sg.Checkbox(
"",
default=self.config.gui_AHSFRAC,
key=self.gui_AHSFRAC,
background_color="#424042",
tooltip="Flagship hybrid algo",
),
sg.Combo(
self.algo_count,
default_value=self.config.gui_AHSFRACP,
key=self.gui_AHSFRACP,
background_color="#424042",
text_color="white",
button_arrow_color="black",
button_background_color="#6f4ca1",
tooltip="Select the priority of eyetracking algorithms.",
),
sg.Text("ASHSFRAC", background_color="#424042"),
sg.Checkbox(
"",
default=self.config.gui_AHSF,