How to use activity recognition to detect walking / running against on_foot

Google Play Services Activity Recognition has

DetectedActivity.RUNNING,
DetectedActivity.WALKING,
DetectedActivity.ON_FOOT

when I get an activity update for walking or running, I get ON_FOOT

how can i differentiate?

I know this suggests that RUNNING and WALKING: "This is a sub-activity ON_FOOT"

Thank you for your help.

+4
source share
3 answers

. , ActivityRecognitionResult, DetectedActivity, , . WALKING DetectedActivity - DetectedActivity ON_FOOT DetectedActivity WALKING .

, ON_FOOT + WALKING || RUNNING , ON_FOOT .

+2

walkOrRunning(), emil10001, , ( ), if for 0.

, , List of size 2 "probableActivities" walkOrRunning() i.e: walkOrRunning ( ).

- ,

List probableActivities = [activity1, activity2],

:

activity1 = "" 75%

activity2 = "running" 5% - .

, walkOrRunning ( ) :

1) 1- for myActivity = ""

2) 2- for myActivity = "running"

"running" , , "".

, (/), walkOrRunning()

[fyi: , , //].

 private DetectedActivity walkingOrRunning(List<DetectedActivity> probableActivities) {
    DetectedActivity myActivity = null;
    int confidence = 0;
    for (DetectedActivity activity : probableActivities) {
        if (activity.getType() != DetectedActivity.RUNNING && activity.getType() != DetectedActivity.WALKING)
            continue;

        if (activity.getConfidence() >= confidence) {
            confidence = activity.getConfidence();
            myActivity = activity;
        }
    }

    return myActivity;
}
+3

, WALKING RUNNING (ActivityRecognitionResult.getProbableActivities()) .

// Get the update
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);

// Get the most probable activity from the list of activities in the update
DetectedActivity mostProbableActivity = result.getMostProbableActivity();

// Get the type of activity
int activityType = mostProbableActivity.getType();

if (activityType == DetectedActivity.ON_FOOT) {
    DetectedActivity betterActivity = walkingOrRunning(result.getProbableActivities());
    if (null != betterActivity)
        mostProbableActivity = betterActivity;
}

private DetectedActivity walkingOrRunning(List<DetectedActivity> probableActivities) {
    DetectedActivity myActivity = null;
    int confidence = 0;
    for (DetectedActivity activity : probableActivities) {
        if (activity.getType() != DetectedActivity.RUNNING && activity.getType() != DetectedActivity.WALKING)
            continue;

        if (activity.getConfidence() > confidence)
            myActivity = activity;
    }

    return myActivity;
}

, , , , , . RUNNING WALKING, , , .

+2

All Articles