logic to count steps while walking using accelerometer feature in iphone

蹲街弑〆低调 提交于 2019-12-06 05:21:15

问题


How can I use the accelerometer feature in the iPhone to calculate distances while walking?


回答1:


You can't use the accelerometer to determine distance.

If I'm at rest, the accelerometer detects only acceleration due to gravity. This obviously set the walking distance to 0.

But if I'm walking at constant velocity, and start your app while walking, my acceleration is also zero, thus the accelerometer detects only acceleration due to gravity again. The situation is same as above, and the walking distance is 0, which is incorrect.

Not to mention the difficulty in dealing with changes of acceleration due to the orientation of the device.

You need Core Location to compute anything related to distance. You can use the accelerometer to implement a pedometer but that only counts steps, not distance.




回答2:


It would probably make more sense to use Core Location for this.

In fact, a sample app to calculate walking distance and speed is created in chapter 24 "iPhone Location API" of iPhone SDK Development by Bill Dudney and Chris Adamson.



来源:https://stackoverflow.com/questions/2047041/logic-to-count-steps-while-walking-using-accelerometer-feature-in-iphone

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