Tomáš Repčík - 21. 10. 2022

Car accident Detection with a Smartphone

Overcoming limitations of smartphone sensors

Every year, 1.3 million people die because of car accidents. 20–50 million people suffer injuries. [WHO] Car accident can put the body under acceleration force with a power of more than 100g. [NHTSA]

Photo by Viktor Bystrov on Unsplash

Nowadays, phones like Pixels from Google or the latest iPhones support car accident detection. Pixels uses a combination of GPS, accelerometer and sound. The iPhone 14 contains a new high-g sensor with a range of a whooping 256g, which enables the phone to process the signal. However, other phones have a range of 4g, 8g or 16g. How could we detect car accidents with this limited range? Let’s look at one of the ideas.

Disclaimer: This is just my imagination and exploration of the idea, when I tried to figure out how it could work. But no real car crashes were tried, because of lack of data.

What is at our disposal

We must change our perspective on the problem and abandon the whole idea of signal processing. On the other hand, the phone has some other APIs to use.

How to piece it together?

When to detect?

Firstly, we make sure that the phone is in the car. We can use Activity Recognition API or GPS. Recognition activity provides the direct answer, but we could say that, if the person goes above 30 km/h, the detector turns on.

When to look for the accident?

Even though the car accident causes acceleration in dozens of gs, the limited range is usable to distinguish that something is happening. The person does not drop the phone often in the car because it is in the pocket or phone holder. The drop of the phone is negated by the fact that the vehicle moves with tracking GPS. If the phone detects higher acceleration, we should look for other clues.

Is the car moving?

If acceleration is detected, the algorithm should wait for the GPS. If the speed was 50km/h and still is 5s later, then the car collision did not occur. The Android location callback is activated only if the phone moves at some point or after some time interval. We can wait for the 30s. If there is no movement, something is happening.

Moreover, GPS gives us information about speed and rapid change in speed. This can be also taken as evidence that something happened. The speed dropping from 50km/h to 0km/h can mean something went wrong too.

Is there something wrong with GPS?

The GPS signal is not available everywhere. If you are surrounded by tall buildings or behind the cliff of the mountain, the signal is not available or has poor quality. The algorithm should still be able to recognize the collision situation even though the GPS is not available.

The low-range accelerometer comes here because the moving car will have a different signal than the standing car. The variance was calculated for samples below 1.4g from car driving data and 10s window. The threshold is low. Most of the samples are below 0.3 in the histogram below, which describes the relative static vehicle. This approximate threshold we can use as another clue. If the acceleration variance in the 10s window is below 0.3, the car is static and not moving.

Is the phone still in the car?

The phone is in the car still if someone does not take it out. This could be done in multiple ways in Android.

Algorithm

As input for the algorithm we have acceleration, GPS and activity recognition API. Taking all the input into consideration, the algorithm awaits high acceleration to occur. From my experience, achieving 4g in the car is hard. The only way is to drop the phone on the car floor.

If the acceleration is above 4g, the algorithm awaits a new GPS sample with a new location and similar speed. If no new location comes, the algorithm looks at the accelerometer. If the acceleration has a profile of a moving car, the indication is ignored. Otherwise, the algorithm waits for a couple of more seconds for GPS and if that is with a speed of 0km/h or the change in speed is above 20km/h, the alarm is triggered.

Testing

The created dataset contains 2500 km of travelling in 5 different middle Europe countries for more than 28h in different environments. The accelerometer, GPS and activity recognition readings were recorded in the CSV files.

The data are not public. The volunteers did not give permission to make them public as they could potentially disrupt their privacy.

The validity of the algorithm was checked by coding a dummy algorithm to go through the data. As a result of investigating all available data, there were 61 indications of a car accident, but not one of them was an algorithm confirmed. The most common aspect that cancels the given indication is the availability of additional GPS samples that indicate vehicle movement. Otherwise, in this regard, the activity recognition API contributes, which can filter out situations where the user just gets out of the vehicle and starts walking.

Previous article

Subscribe for more
LinkedIn GitHub Mail Medium