Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect pattern of motion on an Android device

I want to detect a specific pattern of motion on an Android mobile phone, e.g. if I do five sit-stands.

[Note: I am currently detecting the motion but the motion in all direction is the same.]

What I need is:

  1. I need to differentiate the motion downward, upward, forward and backward.
  2. I need to find the height of the mobile phone from ground level (and the height of the person holding it).

Is there any sample project which has pattern motion detection implemented?

like image 969
Wasim Ahmed Avatar asked Mar 03 '15 09:03

Wasim Ahmed


People also ask

What are motion sensors on Android?

Depending on the device, these software-based sensors can derive their data either from the accelerometer and magnetometer or from the gyroscope. Motion sensors are useful for monitoring device movement, such as tilt, shake, rotation, or swing.

How does a phone detect movement?

Smartphones and other mobile technology identify their orientation through the use of an accelerator, a small device made up of axis-based motion sensing. The motion sensors in accelerometers can even be used to detect earthquakes, and may by used in medical devices such as bionic limbs and other artificial body parts.


2 Answers

This isn't impossible, but it may not be extremely accurate, given that the accuracy of the accelerometer and gyroscopes in phones have improved a lot.

What your app will doing is taking sensor data, and doing a regression analysis.

1) You will need to build a model of data that you classify as five sit and stands. This could be done by asking the user to do five sit and stands, or by loading the app with a more fine-tuned model from data that you've collected beforehand. There may be tricks you could do, such as loading several models of people with different heights, and asking the user to submit their own height in the app, to use the best model.

2) When run, your app will be trying to fit the data from the sensors (Android has great libraries for this), to the model that you've made. Hopefully, when the user performs five sit-stands, he will generate a set of motion data similar enough to your definition of five sit-stands that your algorithm accepts it as such.

A lot of the work here is assembling and classifying your model, and playing with it until you get an acceptable accuracy. Focus on what makes a stand-sit unique to other up and down motions - For instance, there might be a telltale sign of extending the legs in the data, followed by a different shape for straightening up fully. Or, if you expect the phone to be in the pocket, you may not have a lot of rotational motion, so you can reject test sets that registered lots of change from the gyroscope.

like image 107
Eric S. Avatar answered Oct 06 '22 12:10

Eric S.


It is impossible. You can recognize downward and upward comparing acceleration with main gravity force but how do you know is your phone is in the back pocket when you rise or just in your waving hand when you say hello? Was if 5 stand ups or 5 hellos? Forward and backward are even more unpredictable. What is forward for upside-down phone? What if forward at all from phone point of view? And ground level as well as height are completely out of measurement. Phone will move and produce accelerations in exact way for dwarf or giant - it more depends on person behavior or motionless then on height.

like image 2
Alex Avatar answered Oct 06 '22 13:10

Alex