简体   繁体   English

活动识别API不可靠?

[英]Activity Recognition API unreliable?

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. 知道API如何结束这将是非常好的。

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. 这是每30秒拍摄一次MostProbableActivity的日志,以显示我的意思。 Sitting at my desk, after 4 minutes I turn the phone a couple of times, and this results in a "mostProbable IN-VEHICLE" result. 坐在我的办公桌前,4分钟后我转了几次手机,这导致了“最具可驾驶性的车辆”结果。

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 活动识别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. 我认为这是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 托马斯

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. 可能的用例是估计设备的运营商参与物理活动的时间,或者当运营商正在执行检测到的活动之一时激活和停用应该运行的应用程序的组件。

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. 就结果的回复而言,为了确保您的用户正在执行某项活动,Google Play服务的置信度必须> 75,否则可以安全地假设您的用户未执行此操作。 In your case, the Google Play services confidence is 49, which means it is not sure whether your user is driving. 在您的情况下,Google Play服务信心为49,这意味着它无法确定您的用户是否在驾车。 You could also try using a simple 'IF STATEMENT' 您也可以尝试使用简单的“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 在不耗尽电池的情况下获得有关用户活动和位置的更准确见解的其他方法是尝试使用某些API,如tranql,Context Hub或Neura

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM