Android - 如何实现跌倒检测算法

发布于 2024-10-15 07:59:35 字数 418 浏览 8 评论 0原文

我希望能够在我的应用程序中采用相当简单的跌倒检测算法。目前,在 onSensorChanged() 中,我获取当前 x,x,z 值的绝对值,并从中减去 SensorManager.GRAVITY_EARTH (9.8 m/s)。结果值必须连续 10 次大于阈值才能设置一个标志,表明加速度计已检测到跌倒,阈值约为 8m/s。

另外,我还比较了通过阈值后手机的方向和不再通过阈值时手机的方向,这设置了另一个标志,表示方向传感器已检测到跌倒。

当两个标志都设置时,会发生一个事件来检查用户是否正常等。我的问题是阈值,当手机直立时,加速度计的绝对值约为 9.8 m/s,但当我保持不动时倾斜时速度可超过 15m/s。这会导致其他事件触发跌倒检测,如果我增加阈值以避免这种情况,它将不会检测跌倒。
任何人都可以在这里给我一些建议,告诉我应该使用哪些可能的值,或者如何改进我的方法?非常感谢。

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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

Saygoodbye 2024-10-22 07:59:35

首先,我想提醒您,您不能直接将 x、y、z 值按原样相加,您必须使用向量数学。这就是为什么您会得到超过 15 m/s 的值。只要手机不移动,矢量和就应始终约为 9.8 m/s。您可以使用 SQRT(x*x + y*y + z*z) 来计算它。如果您需要更多信息,您可以阅读有关向量数学的内容,也许 http://en.wikipedia.org/wiki/Euclidean_vector#长度 是一个好的开始。

我还建议另一种算法:在自由落体中,加速度计的所有三个 x、y、z 值都应接近于零。 (至少,这是我很久以前在学校物理课上学到的。)所以也许你可以使用一个公式,比如如果 x,y,z 的矢量和 <= 3 m/s 比你检测到自由落体。如果矢量和的值上升到超过 20 m/s,那么您就会检测到着陆。

这些阈值只是一个疯狂的猜测。也许您只是在测试应用程序中记录 x、y、z 值,然后在手机上移动,然后离线分析这些值(及其法线和向量和)的行为,以了解哪些阈值是合理的。

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.

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.

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.

故事与诗 2024-10-22 07:59:35

我实际上已经发表了一篇关于这个问题的论文。请随时查看“ifall”@ww2.cs.fsu.edu/~sposaro

我们基本上取平方根并寻找 3 件事
1. 下限突破。即坠落
2. 上门槛被打破。即撞到地面
3. 1g左右扁平,即长躺,长时间放在地上

I have acutally published a paper on this issue. Please feel free to check out "ifall" @ ww2.cs.fsu.edu/~sposaro

We basically take the root sum of squares and look for 3 things
1. Lower threshold broke. Ie fallinging
2. Upper threshold broke. Ie hitting the ground
3. Flatline around 1g, ie longlie, laying on the ground for an extended period of time

情独悲 2024-10-22 07:59:35

我忘了更新这个帖子,但 iFall 现已在 Android Market 上提供。
另请查看 ww2.cs.fsu.edu/~sposaro/iFall 了解更多信息

I forgot to update this thread, but iFall is now available on the Android Market.
Also check out ww2.cs.fsu.edu/~sposaro/iFall for more information

自此以后,行同陌路 2024-10-22 07:59:35

可以使用加速度计传感器。

将其写入传感器更改侦听器中。

if (sensor == Sensor.TYPE_ACCELEROMETER) {
        long curTime = System.currentTimeMillis();
        // only allow one update every 100ms.
        if ((curTime - lastUpdate) > 100) {
            long diffTime = (curTime - lastUpdate);
            lastUpdate = curTime;

            x = values[SensorManager.DATA_X];
            y = values[SensorManager.DATA_Y];
            z = values[SensorManager.DATA_Z];

            float speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000;
            Log.d("getShakeDetection", "speed: " + speed);
            if (speed > DashplexManager.getInstance().SHAKE_THRESHOLD) {
                result = true;
            }
            last_x = x;
            last_y = y;
            last_z = z;
        }
    }

Its possible using the Accelerometer sensor.

Write this in the sensor changed listener..

if (sensor == Sensor.TYPE_ACCELEROMETER) {
        long curTime = System.currentTimeMillis();
        // only allow one update every 100ms.
        if ((curTime - lastUpdate) > 100) {
            long diffTime = (curTime - lastUpdate);
            lastUpdate = curTime;

            x = values[SensorManager.DATA_X];
            y = values[SensorManager.DATA_Y];
            z = values[SensorManager.DATA_Z];

            float speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000;
            Log.d("getShakeDetection", "speed: " + speed);
            if (speed > DashplexManager.getInstance().SHAKE_THRESHOLD) {
                result = true;
            }
            last_x = x;
            last_y = y;
            last_z = z;
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文