Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holistic solution hand_detections_from_pose_to_rects_calculator edge cases #5373

Open
AmitMY opened this issue May 3, 2024 · 1 comment
Open
Assignees
Labels
task:holistic landmarker Issues related to MediaPipe Holistic Landmarker type:bug Bug in the Source Code of MediaPipe Solution

Comments

@AmitMY
Copy link

AmitMY commented May 3, 2024

Solution

Holistic

Describe the actual behavior

When using the holistic solution, the calculator first estimates the body pose and three points for each hand (wrist, index mcp and pinky mcp) - then, it estimates a rectangle of the hand area of interest, which should cover the full hand, to be sent for hand keypoints.
https://github.com/google/mediapipe/blob/master/mediapipe/modules/holistic_landmark/calculators/hand_detections_from_pose_to_rects_calculator.cc#L110-L121

There are some edge cases that in my view, do not create correct hand rects, and so fail to estimate the hands.
This happens when the hand estimation is off, or when the plane of the hands (the triangle created by the three points of interest) lies directly perpendicular to the camera. When this happens, the "area" of interest is tiny and so the crop will be wrong.

Hands model

If we look at the hands model that uses hand detection, it works well enough:

hands.mp4

Pose model

The pose model also works well enough, correctly predicting the general hand position

pose.mp4

Holistic model (pose + area + hands)

Holistic model works really well when parallel to the camera, but not when parallel to the floor.

holistic.mp4

If I recreate the holistic ROI cropping behavior (without rotation, and with rotation), I get the following. Note how the crop goes crazy.

crops
crops (1)

Describe the expected behavior

I expect that the area of interest will always be correct if the hand estimation is correct, and if not, the hand model will be activated using the hand detection model as a backup.

Possible solution

Before the recroping model

  1. If the hand pose estimation is bad, use the hands detection model
  2. In the area-of-interest calculation, separate two cases based on the hand plane (calculation of the normal are trivial):
    a. if the hand plane is parallel to the camera, do as you do now
    b. if the hand plane is perpendicular to the camera, use a different calculation.
  3. generic solution, would be to learn a tiny regression model, from the hand points (4 points in total) to the hand crop as predicted by the hand detection model. This is generic since it can just train on data, and is probably the best area of interest because it will predict similar bounding boxes to how the keypoints model was trained.
@AmitMY AmitMY added the type:bug Bug in the Source Code of MediaPipe Solution label May 3, 2024
@kuaashish kuaashish assigned kuaashish and unassigned ayushgdev May 6, 2024
@kuaashish kuaashish added the task:holistic landmarker Issues related to MediaPipe Holistic Landmarker label May 6, 2024
@AmitMY
Copy link
Author

AmitMY commented May 6, 2024

Alright, here is a solution

Optimizing_Hand_Area_Detection_in_MediaPipe_Holistic.pdf

https://github.com/sign-language-processing/mediapipe-hand-crop-fix

I would have preferred to write a mathematical solution, so it would be easy to contribute in a PR, but ended up with a model that is very extremely lightweight.

Would be happy to know what you think, and if you could optimize this. (and train on a larger dataset)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task:holistic landmarker Issues related to MediaPipe Holistic Landmarker type:bug Bug in the Source Code of MediaPipe Solution
Projects
None yet
Development

No branches or pull requests

3 participants