mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
mommy gets divorced (renamed to LEAP)
This commit is contained in:
parent
eacaa1fbba
commit
6be461be85
@ -21,8 +21,8 @@ class AlgoSettingsWidget:
|
||||
self.gui_HSF = f"-HSF{widget_id}-"
|
||||
self.gui_DADDY = f"-DADDY{widget_id}-"
|
||||
self.gui_DADDYP = f"-DADDYP{widget_id}-"
|
||||
self.gui_MOMMYP = f"-MOMMYP{widget_id}-"
|
||||
self.gui_MOMMY = f"-MOMMY{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}-"
|
||||
@ -135,21 +135,21 @@ class AlgoSettingsWidget:
|
||||
[
|
||||
sg.Checkbox(
|
||||
"",
|
||||
default=self.config.gui_MOMMY,
|
||||
key=self.gui_MOMMY,
|
||||
default=self.config.gui_LEAP,
|
||||
key=self.gui_LEAP,
|
||||
background_color='#424042',
|
||||
tooltip="MOMMY Uses a lightweight Deep learning algorithm.",
|
||||
tooltip="LEAP Uses a lightweight deep learning algorithm.",
|
||||
),
|
||||
sg.Combo(['1', '2', '3', '4', '5'],
|
||||
default_value=self.config.gui_MOMMYP,
|
||||
key=self.gui_MOMMYP,
|
||||
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 algorithims.",
|
||||
),
|
||||
sg.Text("MOMMY", background_color='#424042'),
|
||||
sg.Text("LEAP", background_color='#424042'),
|
||||
|
||||
sg.Checkbox(
|
||||
"",
|
||||
@ -369,12 +369,12 @@ class AlgoSettingsWidget:
|
||||
self.config.gui_HSRAC = values[self.gui_HSRAC]
|
||||
changed = True
|
||||
|
||||
if self.config.gui_MOMMYP != int(values[self.gui_MOMMYP]):
|
||||
self.config.gui_MOMMYP = int(values[self.gui_MOMMYP])
|
||||
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_MOMMY != values[self.gui_MOMMY]:
|
||||
self.config.gui_MOMMY = values[self.gui_MOMMY]
|
||||
if self.config.gui_LEAP != values[self.gui_LEAP]:
|
||||
self.config.gui_LEAP = values[self.gui_LEAP]
|
||||
changed = True
|
||||
|
||||
|
||||
|
||||
@ -3,30 +3,41 @@ import numpy as np
|
||||
def BLINK(self):
|
||||
|
||||
if self.blink_clear == True:
|
||||
print('CLEARRR')
|
||||
self.max_ints = []
|
||||
self.max_int = 0
|
||||
self.frames = 0
|
||||
|
||||
intensity = np.sum(self.current_image_gray_clean)
|
||||
self.frames = self.frames + 1
|
||||
if len(str(intensity)) >= 8: # filter abnormally high values
|
||||
print('filter, assume blink')
|
||||
intensity = self.max_int + 1
|
||||
|
||||
if intensity > self.max_int:
|
||||
self.max_int = intensity
|
||||
if self.frames > 300: #TODO: test this number more (make it a setting??)
|
||||
self.max_ints.append(self.max_int)
|
||||
if intensity < self.min_int:
|
||||
self.min_int = intensity
|
||||
|
||||
if len(self.max_ints) > 1:
|
||||
if intensity > min(self.max_ints):
|
||||
blinkvalue = 0.0
|
||||
if self.calibration_frame_counter == 300:
|
||||
self.filterlist = [] #clear filter
|
||||
if len(self.filterlist) < 300:
|
||||
self.filterlist.append(intensity)
|
||||
else:
|
||||
blinkvalue = 0.7
|
||||
try:
|
||||
return blinkvalue
|
||||
except:
|
||||
return 0.7
|
||||
self.filterlist.pop(0)
|
||||
self.filterlist.append(intensity)
|
||||
|
||||
if intensity >= np.percentile(self.filterlist, 99) or intensity <= np.percentile(self.filterlist, 1): # filter abnormally high values
|
||||
# print('filter, assume blink')
|
||||
intensity = min(self.max_ints)
|
||||
|
||||
|
||||
# self.frames = self.frames + 1
|
||||
# if intensity > self.max_int:
|
||||
# self.max_int = intensity
|
||||
#@ if self.frames > 300: #TODO: test this number more (make it a setting??)
|
||||
# self.max_ints.append(self.max_int)
|
||||
# if intensity < self.min_int:
|
||||
# self.min_int = intensity
|
||||
|
||||
# if len(self.max_ints) > 1:
|
||||
# if intensity > min(self.max_ints):
|
||||
# blinkvalue = 0.0
|
||||
# else:
|
||||
# blinkvalue = 0.7
|
||||
#try:
|
||||
# return blinkvalue
|
||||
# except:
|
||||
# return 0.7
|
||||
# print(self.blinkvalue, self.max_int, self.min_int, self.frames, intensity)
|
||||
@ -154,7 +154,7 @@ class Camera:
|
||||
self.camera_status = CameraState.CONNECTED
|
||||
if self.cancellation_event.is_set(): #TODO: fix stall when app closes and cam not found
|
||||
print(f"{Fore.CYAN}[INFO] Exiting Capture thread{Fore.RESET}")
|
||||
self.done_callback("stop")
|
||||
# self.done_callback("stop")
|
||||
# print('close')
|
||||
def get_cv2_camera_picture(self, should_push):
|
||||
try:
|
||||
|
||||
@ -36,7 +36,7 @@ class EyeTrackSettingsConfig(BaseModel):
|
||||
gui_BLINK: bool = False
|
||||
gui_HSRAC: bool = True
|
||||
gui_DADDY: bool = False
|
||||
gui_MOMMY: bool = False
|
||||
gui_LEAP: bool = False
|
||||
gui_HSF_radius: int = 15
|
||||
gui_HSF_radius_left: int = 10
|
||||
gui_HSF_radius_right: int = 10
|
||||
@ -58,7 +58,7 @@ class EyeTrackSettingsConfig(BaseModel):
|
||||
gui_DADDYP: int = 3
|
||||
gui_RANSAC3DP: int = 4
|
||||
gui_BLOBP: int = 5
|
||||
gui_MOMMYP: int = 6
|
||||
gui_LEAPP: int = 6
|
||||
gui_IBO: bool = True
|
||||
gui_skip_autoradius: bool = False
|
||||
gui_thresh_add: int = 11
|
||||
|
||||
@ -16,7 +16,7 @@ class EyeInfoOrigin(Enum):
|
||||
HSF = 4
|
||||
HSRAC = 5
|
||||
DADDY = 6
|
||||
MOMMY = 7
|
||||
LEAP = 7
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@ -52,7 +52,7 @@ import importlib
|
||||
from osc import EyeId
|
||||
from osc_calibrate_filter import *
|
||||
from daddy import External_Run_DADDY
|
||||
from mommy import External_Run_MOMMY
|
||||
from leap import External_Run_LEAP
|
||||
from haar_surround_feature import External_Run_HSF
|
||||
from blob import *
|
||||
from ransac import *
|
||||
@ -101,6 +101,7 @@ class EyeProcessor:
|
||||
self.capture_event = capture_event
|
||||
self.eye_id = eye_id
|
||||
self.baseconfig = baseconfig
|
||||
self.filterlist = []
|
||||
|
||||
# Cross algo state
|
||||
self.lkg_projected_sphere = None
|
||||
@ -139,7 +140,7 @@ class EyeProcessor:
|
||||
self.er_hsf = None
|
||||
self.er_hsrac = None
|
||||
self.er_daddy = None
|
||||
self.er_mommy = None
|
||||
self.er_leap = None
|
||||
self.ibo = IntensityBasedOpeness(self.eye_id)
|
||||
self.roi_include_set = {"rotation_angle", "roi_window_x", "roi_window_y"}
|
||||
|
||||
@ -291,12 +292,12 @@ class EyeProcessor:
|
||||
def BLINKM(self):
|
||||
self.eyeopen = BLINK(self)
|
||||
|
||||
def MOMMYM(self):
|
||||
def LEAPM(self):
|
||||
self.thresh = self.current_image_gray.copy()
|
||||
self.current_image_gray, self.rawx, self.rawy, self.eyeopen = self.er_mommy.run(self.current_image_gray)
|
||||
self.current_image_gray, self.rawx, self.rawy, self.eyeopen = self.er_leap.run(self.current_image_gray)
|
||||
self.thresh = self.current_image_gray.copy()
|
||||
self.out_x, self.out_y = cal.cal_osc(self, self.rawx, self.rawy)
|
||||
self.current_algorithm = EyeInfoOrigin.MOMMY
|
||||
self.current_algorithm = EyeInfoOrigin.LEAP
|
||||
|
||||
def DADDYM(self):
|
||||
# todo: We should have a proper variable for drawing.
|
||||
@ -496,13 +497,13 @@ class EyeProcessor:
|
||||
if self.er_daddy is not None:
|
||||
self.er_daddy = None
|
||||
|
||||
if self.settings.gui_MOMMY:
|
||||
if self.er_mommy is None:
|
||||
self.er_mommy = External_Run_MOMMY()
|
||||
algolist[self.settings.gui_MOMMY] = self.MOMMYM
|
||||
if self.settings.gui_LEAP:
|
||||
if self.er_leap is None:
|
||||
self.er_leap = External_Run_LEAP()
|
||||
algolist[self.settings.gui_LEAP] = self.LEAPM
|
||||
else:
|
||||
if self.er_mommy is not None:
|
||||
self.er_mommy = None
|
||||
if self.er_leap is not None:
|
||||
self.er_leap = None
|
||||
|
||||
if self.settings.gui_RANSAC3D:
|
||||
algolist[self.settings.gui_RANSAC3DP] = self.RANSAC3DM
|
||||
|
||||
@ -19,13 +19,13 @@
|
||||
@@@@@@@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@(
|
||||
|
||||
MOMMY by: Prohurtz
|
||||
LEAP by: Prohurtz
|
||||
Algorithm App Implementation By: Prohurtz
|
||||
|
||||
Copyright (c) 2023 EyeTrackVR <3
|
||||
------------------------------------------------------------------------------------------------------
|
||||
"""
|
||||
# MOMMY = Model for Observing Mindful Movement of Your Eyes
|
||||
# LEAP = Lightweight Eyelid And Pupil
|
||||
import os
|
||||
os.environ["OMP_NUM_THREADS"] = "1"
|
||||
import onnxruntime
|
||||
@ -55,7 +55,6 @@ def run_model(input_queue, output_queue, session):
|
||||
# img_tensor.unsqueeze_(0)
|
||||
# img_np = img_tensor.numpy()
|
||||
img_np = np.array(frame)
|
||||
|
||||
# Normalize the pixel values to [0, 1] and convert the data type to float32
|
||||
img_np = img_np.astype(np.float32) / 255.0
|
||||
|
||||
@ -74,12 +73,12 @@ def run_model(input_queue, output_queue, session):
|
||||
|
||||
|
||||
|
||||
class MOMMY_C(object):
|
||||
class LEAP_C(object):
|
||||
def __init__(self):
|
||||
onnxruntime.disable_telemetry_events()
|
||||
# Config variables
|
||||
self.num_threads = 2 # Number of python threads to use (using ~1 more than needed to acheive wanted fps yeilds lower cpu usage)
|
||||
self.queue_max_size = self.num_threads + 4 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak.
|
||||
self.queue_max_size = 3 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak.
|
||||
self.model_path = 'Models/mommy062023.onnx'
|
||||
self.interval = 1 # FPS print update rate
|
||||
self.low_priority = True # set process priority to low
|
||||
@ -150,7 +149,7 @@ class MOMMY_C(object):
|
||||
if not queues[i].full():
|
||||
queues[i].put(frame)
|
||||
break
|
||||
def mommy_run(self):
|
||||
def leap_run(self):
|
||||
|
||||
img = self.current_image_gray.copy()
|
||||
img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
|
||||
@ -194,11 +193,11 @@ class MOMMY_C(object):
|
||||
frame = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
|
||||
return frame, 0, 0, 0
|
||||
|
||||
class External_Run_MOMMY(object):
|
||||
class External_Run_LEAP(object):
|
||||
def __init__(self):
|
||||
self.algo = MOMMY_C()
|
||||
self.algo = LEAP_C()
|
||||
|
||||
def run(self, current_image_gray):
|
||||
self.algo.current_image_gray = current_image_gray
|
||||
img, x, y, per = self.algo.mommy_run()
|
||||
img, x, y, per = self.algo.leap_run()
|
||||
return img, x, y, per
|
||||
Loading…
Reference in New Issue
Block a user