Detect person's fall with Android

别来无恙 提交于 2020-03-13 06:36:08

问题


Good morning,

I'm new in Android development, before I deveped some application/website in C#/ASP.NET with Microsoft SQL Server. Now I've to develop a Android application to detect when I person falls down and send an alarm. I found an examples like this:

public class MainActivity extends Activity implements SensorEventListener{
    private SensorManager sensorManager;
    TextView text_X;
    TextView text_Y;
    TextView text_Z;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        sensorManager.registerListener(this, sensorManager.getDefaultSensor( Sensor.TYPE_ACCELEROMETER ),SensorManager.SENSOR_DELAY_NORMAL );
        //Collegamento con le textView del layout
        text_X=(TextView)findViewById(R.id.txtXValue);
        text_Y=(TextView)findViewById(R.id.txtYValue);
        text_Z=(TextView)findViewById(R.id.txtZValue);
    }

    @Override
    public void onSensorChanged(SensorEvent event) {
        if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
            //L'accelerometro ha cambiato stato
            mostraValori(event);
        }

    }   

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }

    private void mostraValori(SensorEvent event){
        float[] valori=event.values;//array che contiene i valori dell'accelerometro
        //modifica del valore delle textView

        text_X.setText("Valore X: "+valori[0]);
        text_Y.setText("Valore Y: "+valori[1]);
        text_Z.setText("Valore Z: "+valori[2]);

    }
}

So I've accelerometer's X, Y and Z values on the screen. Now what is the next step?

Thank you.


回答1:


IMHO, the next step is for you to decide what profile of accelerometer values over a time period represent a "fall", in a way that minimizes false positives and false negatives. This will need to take into account the sort of device that is being used (tablet? phone? watch? glasses?) and how it is being used (phone in hand? phone in pocket? phone in purse?).




回答2:


In order to do this, you will need to model what you want to define as a "fall". As CommonsWare pointed out, this is a hard problem to solve as you'll want to reduce false positives and false negatives.

See this: https://github.com/BharadwajS/Fall-detection-in-Android

And a similar question: Android - How to approach fall detection algorithm

One way I would recommend starting is to test a few "falling" situations yourself, and monitor the x-, y-, and z- coordinates as you do this. You should then come up with some reasonable limits to start when when testing the acceleration/deceleration of the phone to represent a fall. Note that you don't want your model to simply look for an acceleration as this would create a lot of false positives (when you're in a car, for example), but you'll want to have a slow acceleration at around 1g, and then an abrupt deceleration to zero at the end. This could all happen over the course of a second or two, so you should come up with some heuristics based on tests and define your model.

You may also want to allow the user to calibrate this in the application itself.



来源:https://stackoverflow.com/questions/21095930/detect-persons-fall-with-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!