如何在Android中使用加速计来算一步如何在、Android、计来算

由网友(搭个云梯接近你/)分享简介:我需要计数没有步骤而走。所以,我使用加速度计。在上面的代码,我得到加速度传感器的x,y,z值。这是我迄今所做的。我的问题是由X,Y,Z如何计算步数而走?我得到以下code从链接i need to count no of steps while walking. so that i am using accelero...

我需要计数没有步骤而走。所以,我使用加速度计。在上面的代码,我得到加速度传感器的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

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:

有良好的图表和步骤分析here (PDF格式)。

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

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

如果你想创建一个敏感的计步器(建议老人),我建议你从本文开始: 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

阅读全文

相关推荐

最新文章