working
This commit is contained in:
21
utils.py
21
utils.py
@ -15,21 +15,26 @@ def recvall(sock, n):
|
||||
def distance(p1, p2):
|
||||
return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)
|
||||
|
||||
def normalize(move):
|
||||
left_hip = move[11] # Left Hip
|
||||
right_hip = move[12] # Right Hip
|
||||
import numpy as np
|
||||
|
||||
def normalize(move):
|
||||
left_hip = move[11] # Left Hip
|
||||
right_hip = move[12] # Right Hip
|
||||
nose = move[0] # Nose (głowa)
|
||||
|
||||
# Środek bioder
|
||||
center = (left_hip + right_hip) / 2
|
||||
|
||||
# Przesunięcie względem środka
|
||||
normalized_keypoints = move - center
|
||||
distances = np.linalg.norm(normalized_keypoints[:, :2], axis=1)
|
||||
max_dist = np.max(distances)
|
||||
|
||||
if max_dist > 0:
|
||||
normalized_keypoints[:, :2] /= max_dist
|
||||
# Zamiast max_dist używamy stałej miary "rozmiaru ciała"
|
||||
body_height = np.linalg.norm(nose[:2] - center[:2]) # np. odległość biodra-głowa
|
||||
|
||||
if body_height > 0:
|
||||
normalized_keypoints[:, :2] /= body_height
|
||||
|
||||
draw = normalized_keypoints[:, :2]
|
||||
|
||||
return draw
|
||||
|
||||
def find_closest(moves, target):
|
||||
|
||||
Reference in New Issue
Block a user