fix: head gesture detection biased toward 'yes' (#555)#573
Open
thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
Open
fix: head gesture detection biased toward 'yes' (#555)#573thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
Conversation
5d758a8 to
66d2b4d
Compare
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.
closes #555
the problem
old detectGestures() checked vertical first. if vertical extremes (peaks+troughs) reached the required count and confidence passed the threshold, it returned "yes" immediately, never even computing horizontal confidence. only if vertical didnt reach the count OR didnt pass the threshold did it look at horizontal.
so any motion that bled into the vertical buffer enough to clear the threshold won, even if the horizontal motion was clearly stronger. simplest repro: look slightly down and shake your head. natural neck biomechanics couple yaw with a bit of pitch wobble, the wobble accumulates enough vertical extremes to pass, "yes detected" even though the user is shaking "no".
the fix
compute both confidences, take the higher one. only emit a gesture if the higher confidence is above the threshold, and pick the direction (yes/no) based on which side won.
isolationFactor inside calculateConfidenceScore already penalises bleed (vertical amplitude vs horizontal amplitude and vice versa), so when motion is dominantly horizontal, the horizontal score outpaces the vertical score even if both pass the count threshold.
what this does NOT fix
if you're at extreme poses where the bleed dominates (headstand, lying on side and nodding), you can theoretically still confuse it. but the data going into the detector is already head-relative angular rates, so the ear-axis is the ear-axis no matter how youre oriented. couldnt repro at any normal pose, would need actual headstand testing to find a real failure case. left out of this PR.
test
repro on old build: tilt head down, shake → "yes" fires. on this branch the same motion correctly fires "no" (or nothing if the confidence is too low). couldnt find any case where a real "yes" nod gets misread as "no" with the new logic.