Activity Recognition API unreliable?

旧巷老猫 提交于 2021-01-27 04:12:06

问题


I'm trying to use the activity recognition in a project to detect when the user is "IN-VEHICLE".(Driving) The problem is that it is almost impossibly to use it, as mostProbableActivity often report "IN-VEHICLE" even though I've been sitting at my desk for a long time or just walking around in my house. It would be very nice to know how the API conclude this.

I think this feature has great potential, but as now something is clearly not working.

This is a log of MostProbableActivity taken every 30 seconds to show what I mean. Sitting at my desk, after 4 minutes I turn the phone a couple of times, and this results in a "mostProbable IN-VEHICLE" result.

I've tried different phones and the result is the same. So I don't think it's hardware related.

DetectedActivity [type=STILL, confidence=43]
DetectedActivity [type=STILL, confidence=54]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=69]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=92]
DetectedActivity [type=TILTING, confidence=100]
DetectedActivity [type=IN_VEHICLE, confidence=49]
DetectedActivity [type=TILTING, confidence=100]
DetectedActivity [type=STILL, confidence=51]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=85]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=66]
DetectedActivity [type=STILL, confidence=100]

This is the code, nothing special there:

public class ActivitiesIntentService extends IntentService {


    private static final String TAG = "ActivitiesIntentService";


    public ActivitiesIntentService() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
        Intent i = new Intent(Constants.STRING_ACTION);


        DetectedActivity mostProbableActivity = result.getMostProbableActivity();


        i.putExtra("MOST_PROBABLE_ACTIVITY",mostProbableActivity);



        LocalBroadcastManager.getInstance(this).sendBroadcast(i);


        Log.e(TAG, String.valueOf(mostProbableActivity));
        }

}

From this link:

Activity Recognition API

I can see that others have similar experience, but some claims that it works OK.

I think this is a bug in the confidence algorithm of the API. It should be easy to conclude that the phone isn't moving in any direction, nor on a road so obviously NOT "mostProbable" in a VEHICLE.

Can anyone confirm this problem or do I use it the wrong way?

Best regards

Thomas


回答1:


Bear in mind that this is a very low-energy consumption service, so it can't be looking at the device sensors constantly. That would drain the battery too quickly to be useful. Be sure to read the docs to understand the constraints.

If you want more accurate readings, increase your detection interval. That will give it more data to work with.

Also bear in mind these measurements are to be taken broadly. A possible use case is to estimate how much time the carrier of the device has been engaged in physical activity, or to activate and deactivate components of an app that should be running when the carrier is doing one of the detected activities.




回答2:


If you need more accurate readings you should increase the detection level of your device, but this, in turn, would end up draining your battery. As far as the responses of your results are concerned, to be assured that your user is performing a certain activity, the Google Play services’ confidence must be >75 or it would be safe to assume that your user isn’t performing it. In your case, the Google Play services confidence is 49, which means it is not sure whether your user is driving. You could also try using a simple ‘IF STATEMENT’

if(DetectedActivity == “In_Vehicle” && result.getConfidence()> 75)
 {
 // output = User is Driving;
 // Perform task 
 }

Other ways to get more accurate insights about your user’s activities and locations without having your battery drained, is to try some of the API's like tranql, Context Hub or Neura



来源:https://stackoverflow.com/questions/36632163/activity-recognition-api-unreliable

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