tune AHSF more, add new LEAP model

This commit is contained in:
Prohurtz 2023-12-30 15:50:33 -08:00
parent a3d2f4b992
commit 36de6a6e22
2 changed files with 9 additions and 10 deletions

View File

@ -1006,11 +1006,11 @@ def External_Run_AHSF(frame_gray):
# frame_gray = cv2.resize(frame_gray, (100, 100)) # frame_gray = cv2.resize(frame_gray, (100, 100))
wmax = (frame_gray.shape[1] * 0.5) # likes to crash, might need more tuning still wmax = (frame_gray.shape[1] * 0.5) # likes to crash, might need more tuning still
wmin = (frame_gray.shape[1] * 0.1) wmin = (frame_gray.shape[1] * 0.08)
params = { params = {
"ratio_downsample": 0.5, "ratio_downsample": 0.5,
"use_init_rect": False, "use_init_rect": False,
"mu_outer": 200, # aprroximatly how much pupil should be in the outer rect "mu_outer": 250, # aprroximatly how much pupil should be in the outer rect
"mu_inner": 50, # aprroximatly how much pupil should be in the inner rect "mu_inner": 50, # aprroximatly how much pupil should be in the inner rect
"ratio_outer": 1.0, # rectangular ratio. 1 means square (LIKE REGULAR HSF) "ratio_outer": 1.0, # rectangular ratio. 1 means square (LIKE REGULAR HSF)
"kf": 2, # noise filter. May lose tracking if too high (or even never start) "kf": 2, # noise filter. May lose tracking if too high (or even never start)
@ -1032,8 +1032,8 @@ def External_Run_AHSF(frame_gray):
) = coarse_detection(frame_gray, params) ) = coarse_detection(frame_gray, params)
ellipse_rect, center_fitting = fine_detection(frame_gray, pupil_rect_coarse) ellipse_rect, center_fitting = fine_detection(frame_gray, pupil_rect_coarse)
except TypeError: except TypeError:
print("[WARN] AHSF NoneType Error") # print("[WARN] AHSF NoneType Error")
return frame_gray, frame_clear_resize, 0, 0, 0 return frame_gray, frame_gray, 0, 0, 0
# print(ellipse_rect) # print(ellipse_rect)
# Pupil_rect, Outer_rect, max_response, mu_inner, mu_outer = coarse_detection(frame_gray, params) # Pupil_rect, Outer_rect, max_response, mu_inner, mu_outer = coarse_detection(frame_gray, params)
image_brg = frame_gray # cv2.cvtColor(frame_gray, cv2.COLOR_GRAY2BGR) image_brg = frame_gray # cv2.cvtColor(frame_gray, cv2.COLOR_GRAY2BGR)

View File

@ -27,7 +27,6 @@ Copyright (c) 2023 EyeTrackVR <3
""" """
# LEAP = Lightweight Eyelid And Pupil # LEAP = Lightweight Eyelid And Pupil
import os import os
os.environ["OMP_NUM_THREADS"] = "1" os.environ["OMP_NUM_THREADS"] = "1"
import onnxruntime import onnxruntime
import numpy as np import numpy as np
@ -59,7 +58,7 @@ def run_model(input_queue, output_queue, session):
pre_landmark = session.run(None, ort_inputs) pre_landmark = session.run(None, ort_inputs)
pre_landmark = pre_landmark[1] pre_landmark = pre_landmark[1]
pre_landmark = np.reshape(pre_landmark, (7, 2)) pre_landmark = np.reshape(pre_landmark, (12, 2))
output_queue.put((frame, pre_landmark)) output_queue.put((frame, pre_landmark))
@ -71,10 +70,10 @@ class LEAP_C(object):
self.queue_max_size = 1 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak. self.queue_max_size = 1 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak.
if platform.system() == "Darwin": if platform.system() == "Darwin":
self.model_path = resource_path( self.model_path = resource_path(
"Models/mommy072623.onnx" "EyeTrackApp/Models/leap123023.onnx"
) # funny MacOS files issues :P ) # funny MacOS files issues :P
else: else:
self.model_path = resource_path("Models\mommy072623.onnx") self.model_path = resource_path("Models\leap123023.onnx")
self.interval = 1 # FPS print update rate self.interval = 1 # FPS print update rate
self.low_priority = True # set process priority to low (may cause issues when unfocusing? reported by one, not reproducable) self.low_priority = True # set process priority to low (may cause issues when unfocusing? reported by one, not reproducable)
self.print_fps = False self.print_fps = False
@ -82,7 +81,7 @@ class LEAP_C(object):
self.frames = 0 self.frames = 0
self.queues = [] self.queues = []
self.threads = [] self.threads = []
self.model_output = np.zeros((7, 2)) self.model_output = np.zeros((12, 2))
self.output_queue = Queue(maxsize=self.queue_max_size) self.output_queue = Queue(maxsize=self.queue_max_size)
self.start_time = time.time() self.start_time = time.time()
@ -114,7 +113,7 @@ class LEAP_C(object):
# print(np.random.rand(22, 2)) # print(np.random.rand(22, 2))
# noisy_point = np.array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]) # noisy_point = np.array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1])
self.one_euro_filter = OneEuroFilter( self.one_euro_filter = OneEuroFilter(
np.random.rand(7, 2), min_cutoff=min_cutoff, beta=beta np.random.rand(12, 2), min_cutoff=min_cutoff, beta=beta
) )
# self.one_euro_filter_open = OneEuroFilter( # self.one_euro_filter_open = OneEuroFilter(
# np.random.rand(1, 2), min_cutoff=0.01, beta=0.04 # np.random.rand(1, 2), min_cutoff=0.01, beta=0.04