fix: guard hand landmark visualization

This commit is contained in:
Tom Boullay
2026-04-29 09:52:46 +02:00
parent a8ece3a448
commit 3503ff52ed
6 changed files with 110 additions and 1 deletions
+7
View File
@@ -68,6 +68,13 @@ Server responds with detected hands:
"x": 0.5,
"y": 0.3,
"z": 0.1,
"landmarks": [
{
"x": 0.48,
"y": 0.32,
"z": 0.02
}
],
"handedness": "Right",
"isPinch": true,
"pinchDistance": 0.05,
+7 -1
View File
@@ -19,16 +19,18 @@ class HandData:
x: float
y: float
z: float
landmarks: list[dict[str, float]]
handedness: str
is_pinch: bool
pinch_distance: float
score: float
def to_payload(self) -> dict[str, float | str | bool]:
def to_payload(self) -> dict[str, float | str | bool | list[dict[str, float]]]:
return {
"x": self.x,
"y": self.y,
"z": self.z,
"landmarks": self.landmarks,
"handedness": self.handedness,
"isPinch": self.is_pinch,
"pinchDistance": self.pinch_distance,
@@ -86,6 +88,10 @@ class HandTracker:
x=index_tip.x,
y=index_tip.y,
z=index_tip.z,
landmarks=[
{"x": point.x, "y": point.y, "z": point.z}
for point in landmarks
],
handedness=handedness.category_name,
is_pinch=pinch_distance < 0.07,
pinch_distance=pinch_distance,