feat: add MediaPipe hand landmark support#2283
Open
tarunbommawar27 wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (82%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #2283 +/- ##
=======================================
Coverage 82% 82%
=======================================
Files 66 66
Lines 9082 9084 +2
=======================================
+ Hits 7412 7418 +6
+ Misses 1670 1666 -4 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds MediaPipe hand-landmark support to the key_points module by introducing a dedicated hand skeleton and extending MediaPipe result parsing to handle both current and legacy hand outputs.
Changes:
- Added
Skeleton.HAND(21 vertices / 20 edges) and ensured it is discoverable via existing vertex/edge-count lookup maps. - Extended
KeyPoints.from_mediapipe()to parsehand_landmarksandmulti_hand_landmarks, and to default missing per-landmark visibility to1.0. - Updated test helpers and expanded unit tests to cover the new hand skeleton and MediaPipe hand parsing.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/supervision/key_points/skeletons.py |
Adds the new Skeleton.HAND edge definition and relies on existing lookup-map construction. |
src/supervision/key_points/core.py |
Extends from_mediapipe() to support hand landmarks and makes confidence extraction more robust. |
tests/helpers.py |
Adds a fake landmark type without visibility and extends fake MediaPipe results to include hand-related fields. |
tests/key_points/test_core.py |
Adds MediaPipe hand-landmark parsing test cases. |
tests/key_points/test_skeletons.py |
Adds tests validating the hand skeleton definition and exact edge list. |
Comment on lines
535
to
537
| Creates a `sv.KeyPoints` instance from a | ||
| [MediaPipe](https://github.com/google-ai-edge/mediapipe) | ||
| pose landmark detection inference result. |
Comment on lines
+778
to
797
| ( | ||
| _FakeMediapipeResults( | ||
| multi_hand_landmarks=[ | ||
| _FakeMediapipePose( | ||
| landmarks=[ | ||
| _FakeMediapipeLandmarkWithoutVisibility(0.1, 0.2), | ||
| _FakeMediapipeLandmarkWithoutVisibility(0.3, 0.4), | ||
| ] | ||
| ) | ||
| ] | ||
| ), | ||
| (100, 200), | ||
| _create_key_points( | ||
| xy=[[[10.0, 40.0], [30.0, 80.0]]], | ||
| confidence=[[1.0, 1.0]], | ||
| class_id=None, | ||
| ), | ||
| ), | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting
Description
Adds support for MediaPipe hand landmarks in the key points module.
This PR adds a new
Skeleton.HANDdefinition for MediaPipe's 21 hand landmarks and extendsKeyPoints.from_mediapipe()to parse hand landmark outputs from both current and legacy MediaPipe result formats.Type of Change
Motivation and Context
MediaPipe hand landmarks contain 21 keypoints per hand. The existing
Skeletonenum supported COCO, GHUM, and FaceMesh skeletons, but did not include a hand skeleton. This meantEdgeAnnotatorcould not automatically draw hand landmark connections.KeyPoints.from_mediapipe()also handled pose and face landmarks, but did not handle hand landmarks. This PR adds support for bothhand_landmarksandmulti_hand_landmarks.Closes #2170
Changes Made
Added
Skeleton.HANDwith 21 vertices and 20 MediaPipe hand landmark edgesAdded automatic lookup support through existing
SKELETONS_BY_VERTEX_COUNTandSKELETONS_BY_EDGE_COUNTExtended
KeyPoints.from_mediapipe()to support:hand_landmarksmulti_hand_landmarksUpdated MediaPipe fake test helpers to support hand landmark test cases
Added tests for the hand skeleton definition and MediaPipe hand landmark parsing
Made MediaPipe confidence extraction robust by defaulting missing
visibilityvalues to1.0Testing
Commands run:
Result:
Google Colab (optional)
Not applicable.
Screenshots/Videos (optional)
Not applicable.
Additional Notes
The skeleton edges use 1-based indexing to match the existing
EdgeAnnotatorbehavior, which subtracts1before indexing into keypoint arrays.