Android 加速度计分析 [英] Android Accelerometer Profiling

查看:18
本文介绍了Android 加速度计分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个简单的活动,它是 Sensor.TYPE_ACCELEROMETERSensorEventListener.

I have written a simple Activity which is a SensorEventListener for Sensor.TYPE_ACCELEROMETER.

在我的 onSensorChanged(SensorEvent event) 中,我只是选择 X,Y,Z 格式的值并将它们写入文件.

In my onSensorChanged(SensorEvent event) i just pick the values in X,Y,Z format and write them on to a file.

添加到此 X,Y,Z 是一个标签,该标签特定于我正在执行的活动.所以它的 X,Y,Z,label

Added to this X,Y,Z is a label, the label is specific to the activity i am performing. so its X,Y,Z,label

这样我就获得了我的活动资料.想对收集数据后执行哪些操作提出建议,以消除噪音并为活动获得最佳数据.

Like this i obtain my activity profile. Would like to have suggestions on what operations to perform after data collection so as to remove noise and get the best data for an activity.

此数据收集的主要目的是使用神经网络库(Android 版NeuroPh)构建用户活动检测应用程序Link.

The main intent of this data collection is to construct a user activity detection application using neural network library (NeuroPh for Android) Link.

推荐答案

几周前我写了一个计步器只是为了好玩,它本来可以检测你提到的三个活动.我会进行以下观察:

Just for fun I wrote a pedometer a few weeks ago, and it would have been able to detect the three activities that you mentioned. I'd make the following observations:

  1. 除了 Sensor.TYPE_ACCELEROMETER,Android 还有 Sensor.TYPE_GRAVITYSensor.TYPE_LINEAR_ACCELERATION代码>.如果您记录所有三个值,那么您会注意到 TYPE_ACCELEROMETER 的值始终等于 TYPE_GRAVITY 和 TYPE_LINEAR_ACCELERATION 的值之和.onSensorChanged(…) 方法首先为您提供 TYPE_ACCELEROMETER,然后是 TYPE_GRAVITY 和 TYPE_LINEAR_ACCELERATION,它们是将加速度计读数拆分为重力和非重力加速度的内部方法的结果.鉴于您对活动引起的加速度而不是重力引起的加速度感兴趣,您可能会发现 TYPE_LINEAR_ACCELERATION 更适合您的需要.
  2. 无论您使用什么传感器,X、Y、Z您正在测量的将取决于设备的方向.但是,为了检测您提到的活动,结果不能取决于例如无论用户是纵向还是横向握持设备,或者设备是平放还是垂直,因此 X、Y 和 Z 的各个值都没有任何用处.相反,您必须查看向量的长度,即 sqrt(XX+YY+ZZ),它与设备方向无关.
  3. 如果您将数据输入到对噪音敏感的东西中,您只需要平滑数据.相反,我会说数据就是数据,如果您使用对噪声不敏感的机制,因此不需要平滑数据,您将获得最佳结果.根据定义,平滑是丢弃数据.您想设计一种算法,在一端接收噪声数据并在另一端输出当前活动,因此不要预先判断是否有必要将平滑作为该算法的一部分
  4. 这里是我在构建计步器时记录的 Sensor.TYPE_ ACCELEROMETER 中 sqrt(XX+YY+ZZ) 的图表.图表显示了我走 100 步时测量的读数.绿线是 sqrt(XX+YY+Z*Z),蓝线是 绿线的指数加权移动平均线,它给出了绿线的平均水平,红线显示了我的算法计数步骤.我能够通过查找最大值和最小值以及绿线何时穿过蓝线来计算步数.我没有使用任何平滑或快速傅立叶变换.根据我的经验,对于这类事情,最简单的算法通常效果最好,因为尽管复杂的算法在某些情况下可能有效,但很难预测它们在所有情况下的表现.鲁棒性是任何算法的重要特征:-).
  1. In addition to Sensor.TYPE_ACCELEROMETER, Android also has Sensor.TYPE_GRAVITY and Sensor.TYPE_LINEAR_ACCELERATION. If you log the values of all three, then you notice that the values of TYPE_ACCELEROMETER are always equal to the sum of the values of TYPE_GRAVITY and TYPE_LINEAR_ACCELERATION. The onSensorChanged(…) method first gives you TYPE_ACCELEROMETER, followed by TYPE_GRAVITY and TYPE_LINEAR_ACCELERATION which are the results of its internal methodology of splitting the accelerometer readings into gravity and the acceleration that's not due to gravity. Given that you're interested in the acceleration due to activities, rather than the acceleration due to gravity, you may find TYPE_LINEAR_ACCELERATION is better for what you need.
  2. Whatever sensors you use, the X, Y, Z that you're measuring will depend on the orientation of the device. However, for detecting the activities that you mention, the result can't depend on e.g. whether the user is holding the device in a portrait or landscape position, or whether the device is flat or vertical, so the individual values of X, Y and Z won't be any use. Instead you'll have to look at the length of the vector, i.e. sqrt(XX+YY+ZZ) which is independent of the device orientation.
  3. You only need to smooth the data if you're feeding it into something which is sensitive to noise. Instead, I'd say that the data is the data, and you'll get the best results if you use mechanisms which aren't sensitive to noise and hence don't need the data to be smoothed. By definition, smoothing is discarding data. You want to design an algorithm that takes noisy data in at one end and outputs the current activity at the other end, so don't prejudge whether it's necessary to include smoothing as part of that algorithm
  4. Here is a graph of sqrt(XX+YY+ZZ) from Sensor.TYPE_ ACCELEROMETER which I recorded when I was building my pedometer. The graphs shows the readings measured when I walked for 100 steps. The green line is sqrt(XX+YY+Z*Z), the blue line is an exponentially weighted moving average of the green line which gives me the average level of the green line, and the red line shows my algorithm counting steps. I was able to count the steps just by looking for the maximum and minimums and when the green line crosses the blue line. I didn't use any smoothing or Fast Fourier Transforms. In my experience, for this sort of thing the simplest algorithms often work best, because although complex ones might work in some situations it's harder to predict how they'll behave in all situations. And robustness is a vital characteristic of any algorithm :-).

这篇关于Android 加速度计分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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