Recognizing when the user drives, walks, rides a bicycle

I am trying to find the most reliable way to determine if the user is driving, walking, cycling or stationary. I am going to use this in an android app. I would rather avoid GPS as much as possible.

Please let me know which algorithms have worked for you, their advantages and disadvantages. Thank!

+3


source to share


2 answers


Google has an API to do this in Google Play Services. Check out https://developer.android.com/reference/com/google/android/gms/location/ActivityRecognitionApi.html



I wouldn't suggest coding it on your own, but it wasn't easy (I had a version about a year before Google did it, it was buggy and the battery was dead).

+1


source


You will probably never get an absolutely accurate result, but a reasonable estimate can be determined using

- GPS to identify speed
- Is the charger plugged in
- is the phone off, or on screensaver
- is the movement detector going off a lot - likely walking but may be driving on dirt road

      



I have been playing around with a simplified version of this as shown below (sorry code in Python)

def inspect_phone(self):
    self.phone_gps_lat = 137.0000  # get from phone
    self.phone_gps_lng = 100.0000  # get from phone
    self.phone_moving = False      #  get from phone
    self.phone_move_dist_2_mn = 4
    self.phone_on_charge = True
    self.screen_saver = False
    #-------------------------------
    phone_status = ''
    if self.phone_on_charge == True:
        phone_status += 'Phone is charging'
        if self.phone_moving == True:
            phone_status += ', driving in Car'
        else:
            phone_status += ', sitting still'
    else:
        if self.screen_saver == False:
            phone_status += 'Phone is being used'
        else:
            phone_status += 'Phone is off'
        if self.phone_moving == True:
            if self.phone_move_dist_2_mn < 5:
                phone_status += ', going for Walk'
            elif  self.phone_move_dist_2_mn > 500:
                phone_status += ', flying on Plane'
            else:    
                phone_status += ', riding on ' + transport['Public']
    return phone_status

      

0


source







All Articles