|
|
|
|
@ -116,29 +116,49 @@ class SpecialGestureDetector:
|
|
|
|
|
intersection = line_intersection(l_el, l_wr, r_el, r_wr)
|
|
|
|
|
intersection_on_chest = False
|
|
|
|
|
if intersection is not None:
|
|
|
|
|
intersection_on_chest = (shoulder_center_y - 0.2 * torso_height < intersection[1] < hip_center_y + 0.2 * torso_height)
|
|
|
|
|
intersection_on_chest = (shoulder_center_y - 0.3 * torso_height < intersection[1] < hip_center_y + 0.3 * torso_height)
|
|
|
|
|
cross = forearms_cross and intersection_on_chest
|
|
|
|
|
if cross:
|
|
|
|
|
return 'cross'
|
|
|
|
|
|
|
|
|
|
# ---- ДОМИК ----
|
|
|
|
|
# 1. Запястья выше носа
|
|
|
|
|
wrists_above_nose = (l_wr[1] < nose[1] and r_wr[1] < nose[1])
|
|
|
|
|
## ---- ДОМИК ----
|
|
|
|
|
## 1. Запястья выше носа
|
|
|
|
|
#wrists_above_nose = (l_wr[1] < nose[1] and r_wr[1] < nose[1])
|
|
|
|
|
|
|
|
|
|
# 2. Локти выше плеч (верхняя граница плеч – min по Y среди плеч)
|
|
|
|
|
shoulders_top_y = min(l_sh[1], r_sh[1])
|
|
|
|
|
elbows_above_shoulders = (l_el[1] < shoulders_top_y and r_el[1] < shoulders_top_y)
|
|
|
|
|
## 2. Локти выше плеч (верхняя граница плеч – min по Y среди плеч)
|
|
|
|
|
#shoulders_top_y = min(l_sh[1], r_sh[1])
|
|
|
|
|
#elbows_above_shoulders = (l_el[1] < shoulders_top_y and r_el[1] < shoulders_top_y)
|
|
|
|
|
|
|
|
|
|
# 3. Расстояние между локтями > расстояние между плечами
|
|
|
|
|
elbow_distance = np.linalg.norm(l_el - r_el)
|
|
|
|
|
elbows_far_apart = elbow_distance > shoulder_width
|
|
|
|
|
## 3. Расстояние между локтями > расстояние между плечами
|
|
|
|
|
#elbow_distance = np.linalg.norm(l_el - r_el)
|
|
|
|
|
#elbows_far_apart = elbow_distance > shoulder_width
|
|
|
|
|
|
|
|
|
|
# 4. Расстояние между запястьями < половины ширины плеч
|
|
|
|
|
wrist_distance = np.linalg.norm(l_wr - r_wr)
|
|
|
|
|
wrists_near = wrist_distance < 0.5 * shoulder_width
|
|
|
|
|
## 4. Расстояние между запястьями < половины ширины плеч
|
|
|
|
|
#wrist_distance = np.linalg.norm(l_wr - r_wr)
|
|
|
|
|
#wrists_near = wrist_distance < 0.5 * shoulder_width
|
|
|
|
|
|
|
|
|
|
#dome = wrists_above_nose and elbows_above_shoulders and elbows_far_apart and wrists_near
|
|
|
|
|
#if dome:
|
|
|
|
|
#return 'dome'
|
|
|
|
|
|
|
|
|
|
# ---- ЛАДОШКА ----
|
|
|
|
|
|
|
|
|
|
r_sh_z = landmarks[idx['right_shoulder']][2]
|
|
|
|
|
r_wr_z = landmarks[idx['right_wrist']][2]
|
|
|
|
|
r_el_z = landmarks[idx['right_elbow']][2]
|
|
|
|
|
#1. правая рука почти выпрямлена
|
|
|
|
|
wrist_at_shoulder_y = abs(r_wr[1] - r_sh[1]) < 0.4 * torso_height
|
|
|
|
|
wrist_at_shoulder_x = abs(r_wr[0] - r_sh[0]) < 0.5 * shoulder_width
|
|
|
|
|
|
|
|
|
|
r_sh_z_divided = (landmarks[12][2] + landmarks[11][2])/2
|
|
|
|
|
nose_z = landmarks[0][2]
|
|
|
|
|
nose_and_sh_distance = r_sh_z_divided - nose_z
|
|
|
|
|
|
|
|
|
|
arm_forward = r_sh_z - r_wr_z
|
|
|
|
|
|
|
|
|
|
print(f"arm_forward = {round(arm_forward, 3)} and nose_and_sh_distance = {round(nose_and_sh_distance, 3)}")
|
|
|
|
|
if wrist_at_shoulder_y and wrist_at_shoulder_x and (arm_forward > 3.5*nose_and_sh_distance):
|
|
|
|
|
return "ladoshka"
|
|
|
|
|
|
|
|
|
|
dome = wrists_above_nose and elbows_above_shoulders and elbows_far_apart and wrists_near
|
|
|
|
|
if dome:
|
|
|
|
|
return 'dome'
|
|
|
|
|
|
|
|
|
|
return 'none'
|
|
|
|
|
|