test: new calibration method for leap

This commit is contained in:
Prohurtz 2024-03-27 09:52:16 -05:00
parent ec1d4c8056
commit bcc48a67d1

View File

@ -208,7 +208,6 @@ class LEAP_C(object):
x3, y3 = pre_landmark[4] x3, y3 = pre_landmark[4]
x4, y4 = pre_landmark[2] x4, y4 = pre_landmark[2]
euclidean_dist_open = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
# d = area / euclidean_dist_width # d = area / euclidean_dist_width
# print(area) # print(area)
@ -216,9 +215,12 @@ class LEAP_C(object):
distance = math.dist(pre_landmark[1], pre_landmark[3]) distance = math.dist(pre_landmark[1], pre_landmark[3])
# d = distance / eyesize_dist # d = distance / eyesize_dist
d = math.dist(pre_landmark[1], pre_landmark[3]) d1 = math.dist(pre_landmark[1], pre_landmark[3])
# d2 = math.dist(pre_landmark[2], pre_landmark[4])
# d = d + d2 d2 = math.dist(pre_landmark[2], pre_landmark[4])
d = (d1 + d2) / 2
# by averaging both sets we can get less error? i think part of why 1 eye is better than the other is because we only considered one offset points.
# considering both should smooth things out between eyes
try: try:
if d >= np.percentile( if d >= np.percentile(
@ -253,16 +255,16 @@ class LEAP_C(object):
per = 1 - per per = 1 - per
per = min(per, 1.0) per = min(per, 1.0)
print( # print(
" open distance", # " open distance",
normal_open, # normal_open,
"current ", # "current ",
d, # d,
"calibrated: ", # "calibrated: ",
per, # per,
"old calib", # "old calib",
oldper, # oldper,
) # )
except: except:
per = 0.8 per = 0.8
@ -271,7 +273,6 @@ class LEAP_C(object):
# print(d, per) # print(d, per)
x = pre_landmark[6][0] x = pre_landmark[6][0]
y = pre_landmark[6][1] y = pre_landmark[6][1]
frame = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
# per = d - 0.1 # per = d - 0.1
self.last_lid = per self.last_lid = per