如何在Android中使用加速计来算一步 [英] how to count step using accelerometer in android

查看:99
本文介绍了如何在Android中使用加速计来算一步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计数没有步骤而走。所以,我使用加速度计。在上面的代码,我得到加速度传感器的x,y,z值。这是我迄今所做的。我的问题是由X,Y,Z如何计算步数而走? 我得到以下code从链接

i need to count no of steps while walking. so that i am using accelerometer. in the above coding i get accelerometer sensor's x,y,z values. this is i have done so far. my problems is by the x,y,z how to count steps while walking? i get the following code from the link

<一个href="http://pedometer.google$c$c.com/svn/trunk/src/name/bagi/levente/pedometer/Pedometer.java">http://pedometer.google$c$c.com/svn/trunk/src/name/bagi/levente/pedometer/Pedometer.java

我的code:

 import android.app.Activity;
 import android.content.Context;
 import android.os.Bundle;
 import android.widget.TextView;
 import android.widget.Toast;

 public class Accelerometer extends Activity implements AccelerometerListener {

private static Context CONTEXT;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    CONTEXT = this;
}

protected void onResume() {
    super.onResume();
    if (AccelerometerManager.isSupported()) {
        AccelerometerManager.startListening(this);
    }
}

protected void onDestroy() {
    super.onDestroy();
    if (AccelerometerManager.isListening()) {
        AccelerometerManager.stopListening();
    }

}

public static Context getContext() {
    return CONTEXT;
}

/**
 * onShake callback
 */
public void onShake(float force) {
    Toast.makeText(this, "Phone shaked : " + force, 1000).show();
}

/**
 * onAccelerationChanged callback
 */
public void onAccelerationChanged(float x, float y, float z) {
    ((TextView) findViewById(R.id.x)).setText(String.valueOf(x));
    ((TextView) findViewById(R.id.y)).setText(String.valueOf(y));
    ((TextView) findViewById(R.id.z)).setText(String.valueOf(z));
}

 }

请帮我。

推荐答案

您不会在这里找到一个简单的code仅计算步骤(它实在是太复杂)。但有信息在那里,如果你有兴趣:

You will not find here a simple code to just count steps (it is just too complex). But there's info out there if you're interested:

  • 有良好的图表和步骤分析<一href="http://www.google.com/url?sa=t&source=web&cd=2&sqi=2&ved=0CCcQFjAB&url=http%3A%2F%2Fwww.analog.com%2Fstatic%2Fimported-files%2Fapplication_notes%2F47076299220991AN_900.pdf&rct=j&q=accelerometer%20pedometer%20algorithm&ei=19rdTZLCEonUgAfXvZTMCg&usg=AFQjCNG7XDAlXCpr7S3WXg7WTygCdse7Rg&sig2=Klz7aL-g-DqomdDbLfOk2g&cad=rja">here (PDF格式)。

您可以在这里找到一个更正式的刊物:<一href="http://portal.acm.org/citation.cfm?id=1554235">http://portal.acm.org/citation.cfm?id=1554235

You can find a more formal publication here: http://portal.acm.org/citation.cfm?id=1554235

如果你想创建一个敏感的计步器(建议老人),我建议你从本文开始: <一href="http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4575030">http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4575030

And if you want to create a sensitive pedometer (proposed for the elderly), I suggest you to start from this paper: http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4575030

这篇关于如何在Android中使用加速计来算一步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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