Android - 如何处理跌倒检测算法 [英] Android - How to approach fall detection algorithm

查看:69
本文介绍了Android - 如何处理跌倒检测算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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 m/s 的值的原因.只要手机不移动,矢量总和应该始终约为 9.8 m/s.您可以使用 SQRT(x*x + y*y + z*z) 计算它.如果你需要更多的信息,你可以阅读向量数学,也许 http://en.wikipedia.org/wiki/Euclidean_vector#长度是一个好的开始.

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 m/s 比你检测到自由落体.如果矢量和随后增加到超过 20 m/s 的值,那么您就会检测到着陆.

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.

这篇关于Android - 如何处理跌倒检测算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆