如何计算距离走在android的同时?走在、距离、android

2023-09-05 05:58:00 作者:谁能给我一个拥抱

我正在开发一个演示我的应用程序,其中有命名为开始和停止两个按钮。当用户点击开始,他将开始步行。我想要做的就是让这个当用户点击停止,那么演示将计算出他的开始和停止之间的距离。如果用户pressed开始和pressedSTOP不以单一的步骤,那么它必须显示0公里或0米。我没有任何想法,我应该如何开始这一点;请提出一个建议。

I am developing a demo for my app, in which there are two buttons named as "START" and "STOP". When user taps on "START" he will start walking. What I want to do is make it so that when users tap "STOP" then the demo will calculate his distance between "START" and "STOP". If the user pressed "START" and pressed "STOP" without taking a single step, then it must show 0km or 0m. I don't have any idea how I should start this; please make a suggestion.

推荐答案

一去了解它使用加速度计数据的方式。您的应用程序应该连续记录后用户presses开始按钮,在加速度计数据。当用户需要一个步骤中,您将看到您的数据峰值。应用这些数据的过滤器,并要能够检测的合理的精度所采取的步骤的数目。由步长乘以它,你应该得到的距离近似前往。以用户作为输入参数的高度。步长是围绕一个人的0.45 *高。由于这种方法不依赖于GPS的,它也将在室内工作。 编辑: 你需要使用加速度计值,所有三个轴,使之完全独立的设备orientation.You可以用X ^ 2 + Y ^ 2 + Z ^ 2

One way to go about it is using the accelerometer data. Your app should continuously record the accelerometer data after the user presses the Start button. You will observe a peak in your data whenever the user takes a step. Apply a filter on this data, and you shall be able to detect the number of steps taken with reasonable accuracy. Multiply it by the step length and you should get an approximation of the distance travelled. Take height of the user as an input argument. Step length is around 0.45*Height of a person. Since this approach is independent of GPS, It will also work indoors. You'll need to use the accelerometer values for all three axes to make it fairly independent of the device orientation.You can go with x^2 + y^2 + z^2