Android : Android accelerometer - Detecting a human jump

on Saturday, August 9, 2014


I'm currently almost done developing my first app on android, except the human jump detection seems to be too slow/inaccurate for my desire. I have used a seekbar for changing the sensitivity, however I just believe my algorithm for detection is inefficient. I tried searching everywhere for proper jump detection, but had no luck. It seems to boil down to some good ol' physics and math.


This is my algorithm (from inside the onsensorchange listener) for when the phone in the pocket is upwards, by the way, sensitivity is 0-100, but defaults at 50:


if(phonePosition=="UP"){



if(event.values[1]>(15-(sensitivity-50)/10)){
inAir=true;
}
if(inAir&&event.values[1]<(5+(sensitivity-50)/10)){
freeFall=true;
}
if(freeFall&&event.values[1]>(13-(sensitivity-50)/10)){
rebound=true;
}
if(rebound&&event.values[1]<(10+(sensitivity-50)/10)&&event.values[1]>(1-(sensitivity-50)/10))
{
sp.play(beep1,1,1,0,0,1);
jumpCount++;
inAir=false;
freeFall=false;
rebound=false;
}

jumps.setText(Integer.toString(jumpCount));

}


Here is a chart of xyz values of some jumps if it may help: http://pastebin.com/DtTC3DnL


0 comments:

Post a Comment