From b4d54fcb6895a6b24f97a5558a7d32f196b14680 Mon Sep 17 00:00:00 2001 From: Prohurtz <48768484+RedHawk989@users.noreply.github.com> Date: Mon, 20 Nov 2023 13:25:53 -0600 Subject: [PATCH] fix: LEAP frame and visualization --- EyeTrackApp/eye_processor.py | 4 ++-- EyeTrackApp/leap.py | 19 +++++++++++-------- EyeTrackApp/utils/eye_falloff.py | 8 ++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/EyeTrackApp/eye_processor.py b/EyeTrackApp/eye_processor.py index f64af00..f78ec78 100644 --- a/EyeTrackApp/eye_processor.py +++ b/EyeTrackApp/eye_processor.py @@ -294,7 +294,7 @@ class EyeProcessor: self.rawx, self.rawy, self.eyeopen, - ) = self.er_leap.run(self.current_image_gray_clean) + ) = self.er_leap.run(self.current_image_gray, self.current_image_gray_clean) # print(self.eyeopen) if ( @@ -358,7 +358,7 @@ class EyeProcessor: self.rawy, self.eyeopen, ) = self.er_leap.run( - self.current_image_gray_clean + self.current_image_gray, self.current_image_gray_clean ) # TODO: make own self var and LEAP toggle self.thresh = self.current_image_gray.copy() self.out_x, self.out_y, self.avg_velocity = cal.cal_osc( diff --git a/EyeTrackApp/leap.py b/EyeTrackApp/leap.py index f5faf7f..c663a21 100644 --- a/EyeTrackApp/leap.py +++ b/EyeTrackApp/leap.py @@ -162,12 +162,14 @@ class LEAP_C(object): def leap_run(self): - img = self.current_image_gray.copy() + img = self.current_image_gray_clean.copy() + img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB) # img = imutils.rotate(img, angle=320) img_height, img_width = img.shape[:2] # Move outside the loop frame = cv2.resize(img, (112, 112)) + imgvis = self.current_image_gray.copy() self.run_onnx_model(self.queues, self.ort_session1, frame) if not self.output_queue.empty(): @@ -179,10 +181,10 @@ class LEAP_C(object): for point in pre_landmark: x, y = point cv2.circle( - img, (int(x * img_width), int(y * img_height)), 2, (0, 0, 50), -1 + imgvis, (int(x * img_width), int(y * img_height)), 2, (0, 0, 50), -1 ) cv2.circle( - img, + imgvis, tuple(int(x * img_width) for x in pre_landmark[2]), 1, (255, 255, 0), @@ -190,7 +192,7 @@ class LEAP_C(object): ) # cv2.circle(img, tuple(int(x*112) for x in pre_landmark[2]), 1, (255, 255, 0), -1) cv2.circle( - img, + imgvis, tuple(int(x * img_width) for x in pre_landmark[4]), 1, (255, 255, 255), @@ -251,17 +253,18 @@ class LEAP_C(object): if per <= 0.2: # TODO: EXPOSE AS SETTING per == 0.0 # print(per) - return frame, float(x), float(y), per + return imgvis, float(x), float(y), per - frame = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) - return frame, 0, 0, 0 + imgvis = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) + return imgvis, 0, 0, 0 class External_Run_LEAP(object): def __init__(self): self.algo = LEAP_C() - def run(self, current_image_gray): + def run(self, current_image_gray, current_image_gray_clean): self.algo.current_image_gray = current_image_gray + self.algo.current_image_gray_clean = current_image_gray_clean img, x, y, per = self.algo.leap_run() return img, x, y, per diff --git a/EyeTrackApp/utils/eye_falloff.py b/EyeTrackApp/utils/eye_falloff.py index 61769aa..d918fd1 100644 --- a/EyeTrackApp/utils/eye_falloff.py +++ b/EyeTrackApp/utils/eye_falloff.py @@ -45,13 +45,13 @@ def velocity_falloff(self, var, out_x, out_y): if self.eye_id == EyeId.RIGHT: var.r_eye_velocity = var.average_velocity if self.settings.gui_outer_side_falloff: - dist = abs( - np.sqrt( - abs(np.square(var.l_eye_x - out_x) - np.square(var.left_y - out_y)) + dist abs(np.square(var.l_eye_x - out_x) - np.square(var.left_y - out_y)) ) ) # print(dist, "r") # TODO remove once testing is done - if dist > self.settings.gui_eye_dominant_diff_thresh: + if dist > self.s = abs( + np.sqrt( + ettings.gui_eye_dominant_diff_thresh: falloff = True if ( not self.settings.gui_left_eye_dominant