Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fitness Motion Recognition with Android Wear

Fitness Motion Recognition with Android Wear

Counting is what computers do best and we should let them do it whenever possible. That's true for spreadsheets and it's true for fitness. Wearables exist to count your steps, measure the distance you run, and track how your pulse races after a workout. So why are we still counting pushups, situps, and burpees like they did in the Stone Age?

In this presentation, I will talk about the steps necessary to implement this kind of motion recognition on Android Wear:

- Measuring the motion being recorded by the device
- Deriving a pattern that represents the motion you want to recognize
- Implementing the pattern recognition in the most battery-efficient manner possible

Edward Dale

June 05, 2015
Tweet

More Decks by Edward Dale

Other Decks in Technology

Transcript

  1. Defining the problem scope • Segmenting exercise from non-exercise •

    Recognizing which exercise is being performed • Counting repetitions • Online © Edward Dale, 2015 4
  2. Defining the problem scope • Segmenting exercise from non-exercise •

    Recognizing which exercise is being performed • Counting repetitions • Online © Edward Dale, 2015 5
  3. Defining the problem scope • Segmenting exercise from non-exercise •

    Recognizing which exercise is being performed • Counting repetitions • Online © Edward Dale, 2015 6
  4. Defining the problem scope • Segmenting exercise from non-exercise •

    Recognizing which exercise is being performed • Counting repetitions ! • Online © Edward Dale, 2015 7
  5. Defining the problem scope • Segmenting exercise from non-exercise •

    Recognizing which exercise is being performed • Counting repetitions ! • Online ! © Edward Dale, 2015 8
  6. Pushup Sensors • Proximity (Sensor.TYPE_PROXIMITY) • Rotation (Sensor.TYPE_GAME_ROTATION_VECTOR, Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, Sensor.TYPE_GYROSCOPE,

    Sensor.TYPE_ROTATION_VECTOR) • Acceleration (Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_LINEAR_ACCELERATION, Sensor.TYPE_GRAVITY) © Edward Dale, 2015 15
  7. Pushup Sensors • Proximity (Sensor.TYPE_PROXIMITY) • Rotation (Sensor.TYPE_GAME_ROTATION_VECTOR, Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, Sensor.TYPE_GYROSCOPE,

    Sensor.TYPE_ROTATION_VECTOR) • Acceleration (Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_LINEAR_ACCELERATION, Sensor.TYPE_GRAVITY) ! © Edward Dale, 2015 16
  8. Acceleration Sensors TYPE_ACCELEROMETER uses the accelerometer and only the accelerometer.

    It returns raw accelerometer events, with minimal or no processing at all. TYPE_LINEAR_ACCELERATION and TYPE_GRAVITY ... are "fused" sensors — Mathias Agopian on android-developers Always returns 3 components of acceleration vector © Edward Dale, 2015 17
  9. Acceleration Vector What to do with acceleration direction? Pushup acceleration

    happens in primary one direction Ignore acceleration direction and just use magnitude © Edward Dale, 2015 18
  10. Not so fast Still have to count But there are

    well-known algorithms for that Google: Online peak detection algorithm © Edward Dale, 2015 21
  11. Peakdet A point is considered a maximum peak if it

    has the maximal value, and was preceded (to the left) by a value lower by DELTA. -- http://www.billauer.co.il/peakdet.html © Edward Dale, 2015 22
  12. Peakdet • Online ! • Efficient ! • Sensitive to

    DELTA parameter " © Edward Dale, 2015 25
  13. Battery Efficiency • Analyze fewer samples • Do less analysis

    per sample • Analyze sample on the phone • Choose less power-hungry sensors • Watch the Power Optimization for Android talk from day 1 © Edward Dale, 2015 26
  14. Battery Efficiency Analyze fewer samples • Register for sensor updates

    with lowest sampling frequency necessary • SENSOR_DELAY_NORMAL (5Hz) • SENSOR_DELAY_UI (15Hz) • SENSOR_DELAY_GAME (50Hz) • SENSOR_DELAY_FASTEST (~∞Hz) © Edward Dale, 2015 27
  15. Battery Efficiency Analyze fewer samples • Register for sensor updates

    with lowest sampling frequency necessary • Also possible to suggest your own sampling frequency • Just a suggestion to the device © Edward Dale, 2015 28
  16. Battery Efficiency Do less analysis per sample • Choose an

    efficient algorithm • Peakdet is relatively efficient • More efficient than algorithms using derivates © Edward Dale, 2015 29
  17. Battery Efficiency Analyze samples on the phone Just use the

    watch as a wearable sensor that sends data to be analyzed on the phone. © Edward Dale, 2015 30
  18. Battery Efficiency Choose Less Power-Hungry Sensors • Sensor power drain

    will differ on different hardware • Ask the sensor how much power the sensor uses Sensor.getPower() © Edward Dale, 2015 31
  19. Links • Walk Detection and Step Counting on Unconstrained Smartphones

    • RecoFit: Using a Wearable Sensor to Find, Recognize, and Count Repetitive Exercises • Sample Project © Edward Dale, 2015 33