我試圖在項目中使用活動識別來檢測用戶何時是「車內」(駕駛)問題在於它幾乎不可能使用它,因爲大多數ProbableActivity經常報告「車內」(In-VEHICLE)儘管我已經坐在辦公桌上很長時間,或者只是在我家裏走動。知道API如何得出這個結論將是非常好的。活動識別API不可靠?
我認爲這個功能有很大的潛力,但是現在有些東西顯然不起作用。
這是每30秒拍攝一次MostProbableActivity的日誌,以顯示我的意思。坐在我的辦公桌前,4分鐘後,我打開手機幾次,這導致「最可能的車內」結果。
我試過不同的手機,結果是一樣的。所以我不認爲它與硬件有關。
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]
這是代碼,沒有什麼特別的有:
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));
}
}
從這個鏈接:
我可以看到其他人有類似的經歷,但有些說法,它行得通。
我認爲這是API的置信算法中的一個錯誤。應該很容易得出這樣的結論:手機沒有朝任何方向移動,也沒有在道路上顯然不是「最可能的」。
任何人都可以證實這個問題,或者我用它錯誤的方式嗎?
問候
托馬斯
您正在以正確的方式使用它。問題在於,如果沒有對GPS進行採樣並排空電池,將很難檢測到駕駛活動。 Google可能會在某些時段追蹤傳感器數據(加速度計,陀螺儀,磁力計等),並尋找駕駛模式(這與靜止但非常相似,但具有獨特的振動)。有時候算法不夠精確。 – MikeL