Algorithm for detecting Movement (Forward/Backward) on the iPhone?

家住魔仙堡 提交于 2019-12-25 00:48:20

问题


I would like to know whether it is possible to write code that would let you know whether the user is walking or not (with their iphone tucked in their pocket) and towards which direction they are walking.

More specifically :

  • I'm not interested in calculating distance travelled
  • I'm not interested in counting steps, etc.

What I'm interested in is detecting movement and immobility, distinguishing between the two, and also distinguishing between forward and backward movement.

I know that with the use of the compass in iPhone 4S one can detect orientation, but what about backward movement?

Let's say I start walking, then I stop and then I start walking backwards ( without taking a 360 degree turn..)

Do you think it's possible to manipulate data coming from accelerometer/gyroscope/compass in such a way as to be able to trigger events in my code accordingly?

To give you a more concrete example :

Imagine I want my iPhone(in my pocket) to start playing music as soon as (how fast could the response be really?) I start walking and then stop as soon as I stop walking. And then play a video as soon as I start walking backwards (without turning 360).


回答1:


No. There is no way to guarantee which direction the iPhone is facing, and noise in the accelerometer will prevent long-term calibration. You could nullify the noise with a 3-way gyroscope, but it takes an extremely fast processor to manage the algorithm.

You could certainly tell if the person is moving, simply by taking the sums of the accelerometer's axes and checking if it's greater than a threshold, but as to which direction, that is not a possible task. You could certainly play music while you walk, but there would be no discretion as to the direction.



来源:https://stackoverflow.com/questions/9050976/algorithm-for-detecting-movement-forward-backward-on-the-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!