Android的加速度性能分析 [英] Android Accelerometer Profiling

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

问题描述

我写了一个简单的活动是一个 SensorEventListener Sensor.TYPE_ACCELEROMETER

在我的 onSensorChanged(SensorEvent事件)我只是挑 X,Y,Z 格式的值,​​并写入它们到一个文件。

添加到这个 X,Y,Z 是一个标签,这个标签是专门针对我执行活动。 所以它的 X,Y,Z,标签

像这样我得到我的活动资料。希望有对数据采集后执行什么操作的建议,以去除噪声,并获得最佳的数据为活动

此数据收集的主要目的是建立基于神经网络库(NeuroPh为Android)链接用户活动检测中的应用。

解决方案

只是为了好玩我在几个星期前写了一个计步器,它本来可以检测到你所提到的三项活动。我想提出以下意见:

  1. 在除了 Sensor.TYPE_ACCELEROMETER ,Android的也有 Sensor.TYPE_GRAVITY Sensor.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的各个值将不会被任何使用。相反,你得看看向量的长度,即开方(X * X + Y * Y + Z * Z),它是独立于设备方向。
  3. 您只需要平滑数据如果你已经将它变成一些东西,对噪声敏感。相反,我会说,数据是数据,而如果你使用的是没有对噪声敏感,因此不需要对数据进行平滑机制,你会得到最好的结果。根据定义,平滑丢弃数据。你要设计一个算法,需要在嘈杂的数据,另一端输出,另一端的电流活动,所以不要prejudge是否有必要包括平滑作为算法
  4. 的一部分这里是开方的曲线图(X * X + Y * Y + Z * Z)从Sensor.TYPE_加速度计,当我建立我的计步器,我记录下来。该图显示,当我走了100步测量的读数。绿线是开方(X * X + Y * Y + Z * Z),蓝线是指数加权移动平均绿线,让我的绿线的平均水平,而红线表明我的算法计算步骤。我能仅仅通过寻找最大和最小值,当绿线穿过蓝线来算的步骤。我没有使用任何平滑或快速傅立叶变换。根据我的经验,对于这样的事情最简单的算法往往效果最好,因为虽然复杂的工作,可能会在某些情况下,它是很难predict他们会如何表现在所有情况。和鲁棒性是任何算法的一个重要特点: - )

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

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

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.

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. 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(X*X+Y*Y+Z*Z) 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(X*X+Y*Y+Z*Z) 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(X*X+Y*Y+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天全站免登陆