fix: LEAP frame and visualization

This commit is contained in:
Prohurtz 2023-11-20 13:25:53 -06:00
parent 129803bbdc
commit b4d54fcb68
3 changed files with 17 additions and 14 deletions

View File

@ -294,7 +294,7 @@ class EyeProcessor:
self.rawx, self.rawx,
self.rawy, self.rawy,
self.eyeopen, 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) # print(self.eyeopen)
if ( if (
@ -358,7 +358,7 @@ class EyeProcessor:
self.rawy, self.rawy,
self.eyeopen, self.eyeopen,
) = self.er_leap.run( ) = 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 ) # TODO: make own self var and LEAP toggle
self.thresh = self.current_image_gray.copy() self.thresh = self.current_image_gray.copy()
self.out_x, self.out_y, self.avg_velocity = cal.cal_osc( self.out_x, self.out_y, self.avg_velocity = cal.cal_osc(

View File

@ -162,12 +162,14 @@ class LEAP_C(object):
def leap_run(self): 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 = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
# img = imutils.rotate(img, angle=320) # img = imutils.rotate(img, angle=320)
img_height, img_width = img.shape[:2] # Move outside the loop img_height, img_width = img.shape[:2] # Move outside the loop
frame = cv2.resize(img, (112, 112)) frame = cv2.resize(img, (112, 112))
imgvis = self.current_image_gray.copy()
self.run_onnx_model(self.queues, self.ort_session1, frame) self.run_onnx_model(self.queues, self.ort_session1, frame)
if not self.output_queue.empty(): if not self.output_queue.empty():
@ -179,10 +181,10 @@ class LEAP_C(object):
for point in pre_landmark: for point in pre_landmark:
x, y = point x, y = point
cv2.circle( 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( cv2.circle(
img, imgvis,
tuple(int(x * img_width) for x in pre_landmark[2]), tuple(int(x * img_width) for x in pre_landmark[2]),
1, 1,
(255, 255, 0), (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, tuple(int(x*112) for x in pre_landmark[2]), 1, (255, 255, 0), -1)
cv2.circle( cv2.circle(
img, imgvis,
tuple(int(x * img_width) for x in pre_landmark[4]), tuple(int(x * img_width) for x in pre_landmark[4]),
1, 1,
(255, 255, 255), (255, 255, 255),
@ -251,17 +253,18 @@ class LEAP_C(object):
if per <= 0.2: # TODO: EXPOSE AS SETTING if per <= 0.2: # TODO: EXPOSE AS SETTING
per == 0.0 per == 0.0
# print(per) # print(per)
return frame, float(x), float(y), per return imgvis, float(x), float(y), per
frame = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) imgvis = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
return frame, 0, 0, 0 return imgvis, 0, 0, 0
class External_Run_LEAP(object): class External_Run_LEAP(object):
def __init__(self): def __init__(self):
self.algo = LEAP_C() 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 = current_image_gray
self.algo.current_image_gray_clean = current_image_gray_clean
img, x, y, per = self.algo.leap_run() img, x, y, per = self.algo.leap_run()
return img, x, y, per return img, x, y, per

View File

@ -45,13 +45,13 @@ def velocity_falloff(self, var, out_x, out_y):
if self.eye_id == EyeId.RIGHT: if self.eye_id == EyeId.RIGHT:
var.r_eye_velocity = var.average_velocity var.r_eye_velocity = var.average_velocity
if self.settings.gui_outer_side_falloff: if self.settings.gui_outer_side_falloff:
dist = abs( dist abs(np.square(var.l_eye_x - out_x) - np.square(var.left_y - out_y))
np.sqrt(
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 # 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 falloff = True
if ( if (
not self.settings.gui_left_eye_dominant not self.settings.gui_left_eye_dominant