This commit is contained in:
2025-11-27 21:28:10 +01:00
parent d3063a6048
commit 310997a8dd
7 changed files with 164 additions and 49 deletions

View File

@ -1,3 +1,5 @@
import math
import cv2
import numpy as np
@ -10,8 +12,27 @@ def recvall(sock, n):
data += packet
return data
def find_closest(target):
global moves
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
center = (left_hip + right_hip) / 2
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
draw = normalized_keypoints[:, :2]
return draw
def find_closest(moves, target):
return min(moves, key=lambda t: abs(t[0] - target))
def resize_with_padding(image, target_size=(640, 640)):