mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

add SMOOTH_LANDMARKS option to solutions.hands to reduce jitter

Open willanie opened this issue 3 years ago • 9 comments

Im running mediapipe on windows10 with the python api Im using a logitech webcam for real time input. I am using the python examples provided in the mediapipe docs.
The solutions.hands is successfully tracking hands consistently. Unfortunately there is a very noticeable amount of landmark jitter even when the hands are not moving.

In an attempt to resolve the jitter I switched to the solutions.holistic which has a SMOOTH_LANDMARKS option. Using the holistic solution did reduce the landmark jitter but the hand tracking failed more often than the hands solution.

This post is a feature request to add SMOOTH_LANDMARKS to solutions.hands

willanie avatar May 17 '22 16:05 willanie

Hi @willanie , SMOOTH_LANDMARKS, this line https://github.com/google/mediapipe/blob/710fb3de58dc10b7bc75f9cb758300c9016a5e4f/mediapipe/modules/pose_landmark/pose_landmark_model_loader.pbtxt#L21 specifies the default selection in the SwitchContainer. A value of 1 points to the middle one (0, 1, 2), which is "mediapipe/modules/pose_landmark/pose_landmark_full.tflite

sureshdagooglecom avatar May 18 '22 09:05 sureshdagooglecom

Hi @sureshdagooglecom, I took a look at the link you supplied. Could you please explain how that block of code is related to SMOOTH_LANDMARKS

here is my hands init parameter settings

with mp_hands.Hands( model_complexity=0, static_image_mode=False, max_num_hands=2, min_detection_confidence=0.5, min_tracking_confidence=0.5) as hands:

when I add this to the hands init SMOOTH_LANDMARKS=True,

I get this python error

TypeError: Hands.init() got an unexpected keyword argument 'SMOOTH_LANDMARKS'

I took a look at the code in the link below and it has these comments but I dont understand how to engage filtering in the hands solution

MediaPipe graph to filter landmarks temporally (across packets with

incremental timestamps) to reduce jitter.

https://github.com/google/mediapipe/blob/710fb3de58dc10b7bc75f9cb758300c9016a5e4f/mediapipe/modules/pose_landmark/pose_landmark_filtering.pbtxt

willanie avatar May 18 '22 14:05 willanie

Hi @willanie , The Hand's init method now has 5 params (see https://github.com/google/mediapipe/blob/master/mediapipe/python/solutions/hands.py#L89) and the third parameter is model_complexity, which is an int. Please modify your code accordingly.

sureshdagooglecom avatar May 20 '22 04:05 sureshdagooglecom

Hi @sureshdagooglecom ,

I'm using the following solutions.hands paramaters with mp_hands.Hands( model_complexity=1, static_image_mode=False, max_num_hands=2, min_detection_confidence=0.5, min_tracking_confidence=0.5) as hands:

The hand and fingers track very well. Setting model_complexity to 1 does seem to reduce the jitter slightly. But there is still quite a lot of landmark jitter when the hand is moving very little, as you can see in this movie.

https://user-images.githubusercontent.com/4933879/169457295-48cfe6e1-2c1c-4a05-8c02-e61ddec3515c.mp4

I've begun investigating implementing one euro temporal filtering but it introduces lag issues.

willanie avatar May 20 '22 05:05 willanie

Hi @sureshdagooglecom , Solutions.hands offers impressively reliable consistency in tracking hand and finger motion. Unfortunately, the amplitude of landmark jitter is an issue that makes it unusable for smooth motion data source.

willanie avatar May 26 '22 15:05 willanie

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Jun 02 '22 16:06 google-ml-butler[bot]

Im surprised this feature request has been marked as stale. Landmark jittering is a major issue. Although the overall tracking capability is impressive, It makes mediapipe unusable in my opinion. The SMOOTH_LANDMARKS feature is available in solutions.holistic. Why is it not available in solutions.hands?

willanie avatar Jun 02 '22 17:06 willanie

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Jun 09 '22 17:06 google-ml-butler[bot]

I've begun investigating implementing one euro temporal filtering but it introduces lag issues.

@willanie have you been able to implement this filtering? I'm also trying to fix the jitter with filtering, however, at the moment I only have an implementation with FFTs that works on a recorded clip, i.e. as a form of post-processing. As a next step I want to try to apply the FFT with a sliding window (or something of this sort)

koegl avatar Jun 28 '22 12:06 koegl

@willanie @koegl did you have any success with jitter reduce? I use one-euro-filter that helps a little, but Mediapipe hands is still unusable to me at this stage because of jitter.

wearitar avatar Aug 25 '22 20:08 wearitar

one-euro-filter

what is that one-euro-filter?

vsatyamesc avatar Nov 14 '22 15:11 vsatyamesc

@willanie,

This is part of Face Landmarker Tasks API. Please go through the our new solutions and let us know if you encounter the similar jitter behaviour.

kuaashish avatar Jun 16 '23 06:06 kuaashish

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Jun 24 '23 02:06 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar Jul 03 '23 02:07 github-actions[bot]