Android的 - 如何处理跌倒检测算法如何处理、算法、Android

2023-09-05 07:53:54 作者:战犯心上人

我希望能够拥有一个相当简单的跌倒检测算法在我的应用程序。此刻在onSensorChanged(),我得到的当前x,X,Z的值的绝对值,并从该中减去SensorManager.GRAVITY_EARTH(9.8米/秒)。所得到的值必须大于一个阈值的10倍连续设置一个标记,一个下降已经由加速度计检测到的,阈值是约8米/秒。

I want to be able to feature a fairly simple fall detection algorithm in my application. At the moment in onSensorChanged(), I am getting the absolute value of the current x,x,z values and subtracting SensorManager.GRAVITY_EARTH (9.8 m/s) from this. The resulting value has to be bigger than a threshold value 10 times in a row to set a flag saying a fall has been detected by the accelerometer, the threshold value is about 8m/s.

另外我尽快比较手机的方向作为门槛已经过去了,它当阈值不再被通过orienation,这台另一标志并称方向传感器检测到的下降。

Also I'm comparing the orientation of the phone as soon as the threshold has been passed and the orienation of it when the threshold is no longer being passed, this sets another flag saying the orientation sensor has detected a fall.

当两个标志都设置了,在事件发生的检查方法是用户的确定,等等等等,我的问题是与阈值,当手机直举起加速度的绝对值约为9.8米/秒,但是当我拿着它仍然在一个角度可以超过15M /秒。这是造成其他事件来触发跌倒检​​测,如果我提高了门槛,避免这种情况,也不会检测坠落。 任何人都可以给我一些建议这里我应该使用或如何甚至改善我的方法是什么可能的值?非常感谢。

When both flags are set, an event occurs to check is user ok, etc etc. My problem is with the threshold, when the phone is held straight up the absolute value of accelerometer is about 9.8 m/s, but when i hold it still at an angle it can be over 15m/s. This is causing other events to trigger the fall detection, and if i increase the threshold to avoid that, it won't detect falls. Can anyone give me some advice here with what possible values i should use or how to even improve my method? Many thanks.

推荐答案

首先,我要提醒你,你不能只是添加X,Y,Z值加在一起,因为它们是,你必须使用矢量数学。这就是为什么你会得到超过15米/秒的值。只要手机是不动的,矢量和应始终是约9.8米/秒。您计算使用SQRT(X * X + Y * Y + Z * Z)它。如果您需要了解更多信息,您可以阅读有关矢量数学,也许http://en.wikipedia.org/wiki/Euclidean_vector#Length是一个好的开始吧。

First, I want to remind you that you cannot just add the x, y, z values together as they are, you have to use vector mathematics. This is why you get values of over 15 m/s. As long as the phone is not moving, the vector sum should always be about 9.8 m/s. You calculate it using SQRT(x*x + y*y + z*z). If you need more information, you can read about vector mathematics, maybe http://en.wikipedia.org/wiki/Euclidean_vector#Length is a good start for it.

我也建议另一种算法:在自由下落,所有三个将x,y的,加速度计的z值应接近于零。 (至少,这就是我在物理课很久以前在学校里学到的。)因此,也许你可以用一个公式一样,如果对X,Y,Z其中矢量和= 3米/秒比你检测到自由落体。而如果矢量和,然后上升到一个值超过20米/秒,比你检测到降落。

I also suggest another algorithm: In free fall, all three of the x,y,z values of the accelerometer should be near zero. (At least, that's what I learned in physics classes a long time ago in school.) So maybe you can use a formula like if the vector sum of x,y,z <= 3 m/s than you detect a free fall. And if the vector sum then raises to a value over 20 m/s, than you detect the landing.

这些阈值只是胡乱猜测。也许你只是记录了X,Y,在测试应用程序z值,再左右移动电话,然后分析下线值(和它们的正常和矢量和)的行为得到一个感觉,为此阈值是合理的。

Those thresholds are just a wild guess. Maybe you just record the x,y,z values in a test application, and then move around the phone, and then analyze offline how the values (and their normal and vector sum) behave to get a feeling for which thresholds are sensible.