Skip to content

Commit

Permalink
feat: pupil dilation initial imp
Browse files Browse the repository at this point in the history
  • Loading branch information
RedHawk989 committed Oct 5, 2023
1 parent e694054 commit 6200ddf
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
16 changes: 15 additions & 1 deletion EyeTrackApp/algo_settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
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_pupil_dilation = f"-EBPD{widget_id}-"
self.gui_LEAP_lid = f"-LEAPLID{widget_id}-"
self.main_config = main_config
self.config = main_config.settings
Expand Down Expand Up @@ -188,7 +189,7 @@ def __init__(
),
sg.Text("Blob", background_color="#424042"),
],
[sg.Text("Blink Algo Settings:", background_color="#242224")],
[sg.Text("Eyelid Algo Settings:", background_color="#242224")],
[
sg.Checkbox(
"Intensity Based Openness",
Expand Down Expand Up @@ -249,6 +250,15 @@ def __init__(
background_color="#424042",
),
],
[sg.Text("Pupil Dilation Algo Settings:", background_color="#242224")],
[
sg.Checkbox(
"Ellipse Based Pupil Dilation",
default=self.config.gui_pupil_dilation,
key=self.gui_pupil_dilation,
background_color="#424042",
)
],
[
sg.Text(
"Advanced Tracking Algorithim Settings:", background_color="#242224"
Expand Down Expand Up @@ -444,6 +454,10 @@ def render(self, window, event, values):
self.config.gui_IBO = values[self.gui_IBO]
changed = True

if self.config.gui_pupil_dilation != values[self.gui_pupil_dilation]:
self.config.gui_pupil_dilation = values[self.gui_pupil_dilation]
changed = True

if self.config.gui_RANSACBLINK != values[self.gui_RANSACBLINK]:
self.config.gui_RANSACBLINK = values[self.gui_RANSACBLINK]
changed = True
Expand Down
2 changes: 1 addition & 1 deletion EyeTrackApp/camera_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def render(self, window, event, values):

graph.draw_circle(
(eye_info.x * -100, eye_info.y * -100),
15],
eye_info.pupil_dilation * 25,
fill_color="black",
line_color="white",
)
Expand Down
1 change: 1 addition & 0 deletions EyeTrackApp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class EyeTrackSettingsConfig(BaseModel):
gui_osc_vrcft_v1: bool = False
gui_osc_vrcft_v2: bool = False
gui_vrc_native: bool = True
gui_pupil_dilation: bool = True


class EyeTrackConfig(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion EyeTrackApp/eye.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from enum import Enum, IntEnum


class EyeId(IntEnum):
RIGHT = 0
LEFT = 1
Expand All @@ -24,5 +25,5 @@ class EyeInfo:
info_type: EyeInfoOrigin
x: float
y: float
pupil_dialation: float
pupil_dilation: float
blink: float
22 changes: 12 additions & 10 deletions EyeTrackApp/eye_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,18 @@ def capture_crop_rotate_image(self):

def UPDATE(self):
# print(self.eyeopen)
self.pupil_dilation = self.ebpd.intense(
self.pupil_width,
self.pupil_height,
self.rawx,
self.rawy,
self.current_image_white,
self.settings.ibo_filter_samples,
self.settings.ibo_average_output_samples,
)
print(self.pupil_dilation)
if self.settings.gui_pupil_dilation:
self.pupil_dilation = self.ebpd.intense(
self.pupil_width,
self.pupil_height,
self.rawx,
self.rawy,
self.current_image_white,
self.settings.ibo_filter_samples,
self.settings.ibo_average_output_samples,
)
else:
self.pupil_dilation = 0.5

if self.settings.gui_BLINK:
self.eyeopen = BLINK(self)
Expand Down
12 changes: 10 additions & 2 deletions EyeTrackApp/osc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def eyelid_transformer(self, eye_blink):
se = False


def output_osc(eye_x, eye_y, eye_blink, last_blink, self):
def output_osc(eye_x, eye_y, eye_blink, last_blink, pupil_dilation, self):
print(pupil_dilation)
global se
# self.config.gui_osc_vrcft_v2
# self.config.gui_osc_vrcft_v1
Expand Down Expand Up @@ -303,7 +304,14 @@ def run(self):
except:
continue

output_osc(eye_info.x, eye_info.y, eye_info.blink, last_blink, self)
output_osc(
eye_info.x,
eye_info.y,
eye_info.blink,
last_blink,
eye_info.pupil_dilation,
self,
)


class VRChatOSCReceiver:
Expand Down

0 comments on commit 6200ddf

Please sign in to comment.