问题
can it be determined that where a person is i.e is he walking ? is he in elevator ? or is he climbing up the stairs ?
using android's accelerometer or is there any other way to calculate such in android ?
回答1:
You can use a combination of the accelerometer and the digital compass, in phones that have them, to determine a speed and direction as mentioned in this post.
If all you need to do is determine if the person is walking, all you need is the accelerometer. Just process its output for foot steps.
There are plenty of tutorials on the web for detecting foot steps with an accelerometer.
There an app note here: http://www.analog.com/library/analogDialogue/archives/41-03/pedometer.html that gives a decent mathematical background and an example algorithm. Its of course up to you to extract the math and rewrite it for Android (the example code is written in C). I don't currently know of an open source android library with a footstep detection algorithm.
If you implement something, I would like to get the code, don't forget to post back the results.
来源:https://stackoverflow.com/questions/3134741/using-android-accelerometer-to-calculate-distance-eleveation