Skip to content

fix: head gesture detection biased toward 'yes' (#555)#573

Open
thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
thisisAcidic:fix-head-gesture-vertical-bias
Open

fix: head gesture detection biased toward 'yes' (#555)#573
thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
thisisAcidic:fix-head-gesture-vertical-bias

Conversation

@thisisAcidic
Copy link
Copy Markdown
Contributor

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.

val maxConfidence = max(verticalConfidence, horizontalConfidence)
if (maxConfidence < minConfidenceThreshold) return null
return verticalConfidence >= horizontalConfidence

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.

@thisisAcidic thisisAcidic marked this pull request as ready for review May 3, 2026 15:04
@thisisAcidic thisisAcidic force-pushed the fix-head-gesture-vertical-bias branch from 5d758a8 to 66d2b4d Compare May 4, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Head Gestures not registering "No" Gesture

1 participant