DrivingSense : Dangerous Driving Behavior Identification Based on Smartphone

Since pervasive smartphones own advanced computing capability and are equipped with various sensors, they have been used for dangerous driving behaviors detection, such as drunk driving. However, sensory data gathered by smartphones are noisy, which results in inaccurate driving behaviors estimations. Some existing works try to filter noise from sensor readings, but usually only the outlier data are filtered.The noises caused by hardware of the smartphone cannot be removed from the sensor reading. In this paper, we propose DrivingSense, a reliable dangerous driving behavior identification scheme based on smartphone autocalibration. We first theoretically analyze the impact of the sensor error on the vehicle driving behavior estimation.Then, we propose a smartphone autocalibration algorithm based on sensor noise distribution determination when a vehicle is being driven. DrivingSense leverages the corrected sensor parameters to identify three kinds of dangerous behaviors: speeding, irregular driving direction change, and abnormal speed control. We evaluate the effectiveness of our scheme under realistic environments. The results show that DrivingSense, on average, is able to detect the driving direction change event and abnormal speed control event with 93.95% precision and 90.54% recall, respectively. In addition, the speed estimation error is less than 2.1m/s, which is an acceptable range.


Introduction
Owing to the rise in the popularity of automobiles over the last century, road accidents have become one of the leading causes of death in many countries around the world [1].For instance, in 2010, there were almost 280000 injured and 70000 killed in traffic accident in China alone [2].A study shows that over 90% of traffic accidents are associated with human errors [3].The human behaviors, such as speeding, drunk driving, and using a mobile phone while driving, are the major factors which lead to inattention of drivers.Since large scale fields studies have proved that when a driver is monitored, his/her behavior is relatively safer, thus, to reduce the road accident, various technologies have been developed to detect driver's state while driving.For example, in [4], the authors proposed to monitor the loss of attention of drivers by determining the percentage of eye closure.In addition, in [5], the authors proposed to leverage the existing car stereo infrastructure to monitor whether a phone is used by the driver.However, since the unsafe state of a driver is presented as dangerous driving behaviors of a vehicle, it is more meaningful to monitor driving behaviors of the vehicle rather than detecting a specific unsafe driving behavior of the driver.
Currently, several companies have provided products for drivers to monitor driving behaviors of vehicles with the aim of avoiding the traffic accident.In [6][7][8], the products collect real-time vehicular sensor data, such as GPS trajectory, and transmit them to a data center through the Internet or cellular wireless networks.Thus, we can troubleshoot and monitor the vehicle from our smartphone or computer.However, as with the sensing technology, the data collection raises severe privacy concerns among users who may perceive the continuous monitoring by the operator as intrusive [9].To overcome this drawback, products for personal use have been designed [10,11].The product is installed on the vehicle, to monitor parameters that determine the driving behavior of the vehicle and provide feedback on a regular basis for drivers.Then, the driver can ensure where they need to improve so that it can run on standard smartphones.Our extensive experiments validate the accuracy and feasibility of our scheme in real driving environment.
We highlight our main contributions as follows: (i) We propose a sensor noise distribution determination algorithm for the smartphone on a vehicle.Specifically, we exploit different change trends of smartphone sensor data between uniform moving and motion change to infer which data segments are from the vehicle in uniform moving.Then we can use this data segment to estimate the sensor noise distribution.
(ii) To correct the smartphone sensor data error, we propose an improved Kalman filter based autocalibration algorithm.The experimental results show that this method can effectively correct the data error.
(iii) We deduce an accurate driving speed of a vehicle estimation method that only uses the corrected acceleration data and GPS.
(iv) To detect the turn signal audio beep, an algorithm based on Fast Fourier Transform and crosscorrelation is proposed.The Fast Fourier Transform is used to analyze the audio beep frequency, filtering out the background noises.The cross-correlation algorithm is used to detect the turn signal.
(v) We conduct extensive experiments in urban city, Chengdu, China.The results show that, in the real world, DrivingSense can identify the vehicular driving behavior with high accuracy.
The remainder of this paper is structured as follows.Section 2 presents a brief overview of related works.Section 3 gives a data error analysis, which illustrates the impact of the data error on the vehicle state estimation.In Section 4, we present an overview of DrivingSense and the design details of our scheme step by step, including sensor noise distribution determination, data error correction, coordinate reorientation, and dangerous driving behavior identification.We evaluate the performance of our scheme and present the results in Section 5. Finally, we give the conclusion in Section 6.

Related Work
Due to the popularity of smartphones and multiple sensors they are equipped with, there is a growing interest in driving safe research based on smartphones.In [17], the authors used a smartphone as a sensor platform to detect aggressive driving.Specifically, it used sensor-fusion output of accelerometer, gyroscope, and magnetometer sensors of a smartphone to detect and classify vehicle movement.The drawback of this approach is that it cannot tell the driver where he/she drives improperly in detail.In [15], authors proposed CarSafe, which is an app than runs on the smartphone.In CarSafe, it uses the time series GPS to estimate the vehicle's speed and uses the phone's front camera to recognize the head position of the driver to ensure whether the driver is in a safe lane change mode.A similar scheme has been proposed in [19,20] where GPS or subsampled GPS is used to drive the vehicle speed.Since the vehicle is highly dynamic, the low update rate of GPS is hard to keep up with the frequent change of the vehicle speed.Additionally, continuously using GPS drains the phone battery quickly.Thus, it is hard to obtain the accurate speed estimation from GPS trajectory.Besides vehicle speed estimation based on GPS, an alternative method based on OBD-II was developed [21].It leverages the Bluetooth communication between a smartphone and OBD-II adapter to monitor the vehicle driving speed and provide feedback for the driver.Although the speed obtained from OBD-II is quite accurate, this approach relies on an additional OBD-II adapter.In [22], the authors proposed SenSpeed, which estimated the vehicle speed by integration of the accelerometer's readings over time.The problem is that the initial velocity only can be calculated at the turn reference point through the angular speed.Besides, there are accumulative errors of the speed estimation caused by the biased acceleration.In [23], the authors proposed to use sensory data of accelerometer and orientation sensor of smartphone to detect the drunk driving.However, all these methods are suffering from the problem of sensor noise.
To tackle this problem, up to now, serval methods have been proposed to process noisy signal for robust detection.In [17], a signal filter was used over the raw data.But it can only filter out the noise from the vibrations of the vehicle interior.In [24], authors leveraged a mechanism that when a vehicle reached its maximum speed, the vehicle changed from acceleration to deceleration during normal driving.Thus, when the reference speed from OBD-II reaches its local maximum, the acceleration should be equal to zero.Acceleration adjustment is calculated by reducing the bias.Although this mechanism can obtain more accurate speed estimation, it not only requires additional hardware, but also cannot correct other sensor errors, such as gyroscope sensor.In [25], the authors proposed to use the Kalman filter algorithm to correct sensor noise.It assumed that the noise was drawn from a zero mean multivariate normal distribution and the variance was measured when a smartphone was still.However, there are some problems.(1) As we have tested, the sensor data error does derive not only from the white noise but also with a bias.Thus, the Kalman filter algorithm cannot be used directly.(2) We find that the data error is different every time even in still state.This means that we have to remeasure the data error when we use it.In [22], authors proposed to sense the natural driving conditions to identify the reference points to measure the acceleration error and further eliminate accumulative error from the biased acceleration.However, this method cannot be used in highway scenario in which there are less reference points.In this paper, we propose DrivingSense, which can efficiently eliminate the accumulate error when vehicles are driving, providing more accurate detection of the dangerous driving behaviors.

Data Error Analysis
As mentioned above, in this paper we utilize the smartphone as a sensing platform to collect the driving information of vehicles and identify their dangerous driving behaviors.
However, we find that the data collected by smartphone sensors are noisy.In this section, we will verify the impact of the data error of sensors on the vehicle driving behavior estimation.
We first conduct experiment to learn about how the sensor data error is.To achieve this objective, we lay a smartphone in a horizontal plane and keep it stable to collect the sensor data.The sample frequency is set to 1 Hz.Under the ideal condition, the value of each sensor data reading is equal to zero.We take the -acceleration and -gyroscope readings as an example and plot the measurement data, as shown in Figure 1.The measurement data are volatile and deviate from the ground truth.The primary error sources of smartphone sensors are uncorrected bias errors and white noise [26], which are consistent with our practice test.From the figure, we can see that the data error of the accelerometer sensor is larger than gyroscope sensor's.Thus, we mainly focus on analyzing the impact of acceleration error on the vehicle driving speed estimation.
Let  = ( 1 ,  2 , . . .,   ) be a series of collected data,   = (  ,   ),   is the acceleration, and   is the vehicle location.Suppose the interval of sampling is Δ.Therefore, the travelling distance  during the time span Δ ⋅  can be expressed as With the initial velocity  0 at the beginning of data collection, the travelling distance  can be computed as (2) Then, we have the velocity estimation function of  0 as Thus, the vehicle speed at the time point Δ ⋅  can be estimated as  From (4), we can see that the velocity of a vehicle is comprised of the acceleration and the travelling distance which is obtained by GPS.As we know, the GPS data is unreliable as well.Even the GPS readings corrected by WAAS have an error of 3 m (standard deviation), not to mention the ones in the area without WAAS.Fortunately, analyzing the GPS trajectories of different vehicles, we observe that the GPS error is highly correlated for a long driving distance, which is reflected by the fact that the vehicle trajectory is nearly paralleled with the real roads, as shown in Figure 2.That is to say, for a series of GPS trajectories, they have the similar data bias.It is worth to note that we are not the first ones to make such observations; similar characteristics have already been discovered and utilized by many works [27,28].Based on this result, we can conclude that the travelling distance computed through the relative motion distance superposition is reliable.Using (4), we can figure out the estimation speed error of the vehicle as where  *  is the ground truth value of the acceleration.From (5), we find that the estimation error is accumulated when integrating the accelerometer's readings and the latter accelerometer's readings have greater impact on the vehicular speed estimation.Suppose the accelerometer's -axis is along the moving direction of the vehicle.The error mean of acceleration readings in Figure 1(a) is −0.07 m/s 2 .For 200 samples, the speed estimation error is up to 7.48 m/s, which enough affects the vehicular driving behavior identification.Therefore, it is very necessary to correct the sensor data error before using them.

The Detailed Design of DrivingSense
Since DrivingSense is designed to run on the smartphone, it should be lightweight and fast so that the dangerous driving behavior can be detected in real time and a warning message can be sent to the driver as accurately as possible.In this section, we present the design of our DrivingSense and describe this scheme in detail.

The DrivingSense Overview.
The vehicle driving behavior can be estimated by integrating of sensor data reading over time.However, there are two problems.Firstly, the sensor data are noisy.The accumulative error can cause a large deviation between the ground truth value and the estimation result.Secondly, since the smartphone can be in any orientation in the vehicle, its coordinate system is different from the vehicle's.Thus, before using the sensor data, DrivingSense must perform data processing to correct the obtained data and align the smartphone's coordinate system with the vehicle's.
The workflow of DrivingSense is shown in Figure 3.It is mainly divided into three components: (1) data collection; (2) data processing; (3) dangerous driving behavior identification.For data collection, DrivingSense uses two kinds of sensors, accelerometer and gyroscope, GPS device, and microphone in smartphones.The accelerometer is used to monitor the vehicle acceleration and the gyroscope is used to monitor the vehicle angular speed, the GPS device is used to obtain the vehicle location which will be used to calculate the relative motion distance over a period of time, and the microphone is used to monitor the audio beep in the vehicle.For data processing, DrivingSense first determines the sensor error distribution.It can be estimated by the data segment that derives from when the vehicle moves in uniform motion.Then, it uses an improved Kalman filter algorithm to correct the collected data.After that, DrivingSense utilizes the corrected data to align the smartphone's coordinate system with the vehicle's to obtain meaningful data.For dangerous driving behavior identification, DrivingSense uses the corrected readings to identify the dangerous driving behavior of speeding, irregular driving direction change, and abnormal speed control.Speeding, which is one of the main causes of traffic accident, means the vehicle driving over the speed limit of the road.It is identified by comparing the estimated speed with the predefined speed obtained from a navigation system.Irregular driving direction change is when the vehicle makes a lane change or turn without turning on the turn signals.Abnormal speed control is abrupt accelerating, deceleration, or erratic braking.This is very common when drivers are under the drunk or fatigue driving conditions.In our scheme, we utilize a threshold scheme to identify this dangerous driving behavior.

Sensor Noise Distribution Determination.
The smartphone is used to measure the vehicle movement parameters; the collected sensor data are derived from that when the vehicle is being driven.How to calculate the data error distribution under this state becomes the key issue of the data error correction.In the following parts, we will first present a method to determine the sensor noise distribution of an onboard vehicle smartphone.
The spatial movement of a rigid body can be described as a combination of translation and rotation in space.Suppose the -acceleration represents the vehicle's longitudinal acceleration, and the vehicle motion of the lane change or turn is determined by the -gyroscope.When vehicle motion changes (speeding up and making a turn), the two parameter readings have an obvious change.As shown in Figure 4, Δ1 is the data reading deviation when the vehicle is in uniform motion.Δ2 is the data reading deviation when the vehicle motion changes.Compared with Δ1, Δ2 has a much larger change.Based on this observation, we can infer which data segment derives from when the vehicle moves in uniform motion.After that, we utilize the mean and variance of the data segment to estimate the sensor noise distribution.
The key issue during this process is how to determine the change point and the algorithm should be lightweight so that it can run on the smartphone efficiently.Let  = ( 0 ,  1 ,  2 , . . .,   ) be the raw data reading.We make a firstorder difference on the obtained data and then extract all the nonzero values.After that, we make a first-order differential again on the absolute value of the extracted data.The absolute values of the results are calculated.We name this process as pseudo-second-order differential.Based on the result, data reading change trends can be determined.As Figure 5 shows, they are the results of the pseudo-second-order differential of -acceleration and -gyroscope in Figure 4.It can be seen that the results grow rapidly when the vehicle motion changes.Let  = ( 0 ,  1 ,  2 , . . .,   ) be the pseudo-secondorder differential set of the raw data.If   =  −1 , we can see that there is a regular change in the raw data.Thus, we only need to consider the case   ̸ =  −1 ; the change point of  satisfies where TH is a threshold that is chosen empirically as two.
After   determination, we can find the change point of raw data   using data index.The 100 consecutive samples between two change points can be used to determine the sensor error.The detailed sensor noise distribution determination method is depicted in Algorithm 1.

Data Error Correction.
Once the sensor noise distribution is determined, DrivingSense next uses this information to correct the sensor data.As described above, the sensor data error is mainly caused by a constant bias and a white noise.
If we subtract the constant bias from the collected data, the remaining data error is mainly a white noise.Then, we can use Kalman filter algorithm to correct the remaining data.In our scheme, the constant bias is the mean value  of sensor noise distribution.
Let O(k) be the th measurement vector.Thus, Y(k) = O(k) − u is the new measurement vector with a white noise.Let Z(k) be the th state vector which denotes the rough estimate before the measurement update correction.To obtain the corrected data, we introduce a discrete control process of the system; it can be given as where  is the state transfer matrix of the system and  is the measurement matrix.Since in our system () and () are just numeric values,  and  are identity matrixes.() and () are the process noise and the measurement noise, respectively.Usually, () can be assumed as white Gaussian noise [29], and () is white Gaussian noise with the variance  2 derived from Algorithm 1. Their covariances are  and .
According to (7), we utilize the previous corrected sample to predict the current state that is given as where ( − 1 |  − 1) is the corrected result of the  − 1th sample.
After that, we should calculate the current measurement data () by the raw data value minus the mean value of the sensor noise.Based on the combination of the current prediction result and the measurement, the optimal correction result ( | ) can be given as where Kg is the Kalman gain; it can be computed as where ( |  − 1) is the covariance of (); it is computed as where In order to implement Kalman filter algorithm until the end of the system, we should update the covariance ( | ) of ( | ) as Initially, in our scheme we choose (0 | 0) = 0, (0 | 0) = 5.Through this process iteration, we can obtain more accurate data.

Coordinate Reorientation.
In DrivingSense, we utilize acceleration and -gyroscope of the smartphone to obtain the longitudinal acceleration and angular speed of vehicles.However, the smartphone can be fixed in the vehicle body Require: The raw data reading  = { 0 ,  1 ,  2 , . . .,   }; The none-zero first-order difference set  of the raw data; The pseudo second order differential set  of the raw data; Ensure: The sensor noise mean  and variance  2 ; (1) Collecting raw sensor data (2) for  = 1;  ≤ size(); i++ do D.add(  ) (6) end if (7) end for (8) for  = 1;  ≤ size(); i++ do (9) (22) end for (23) Find   that is correspond with   in the raw data (24) If the sample number between two change point greater than 100 (25 in any orientation.That is to say, there are two coordinates in the system, one for the vehicle ( V ,  V ,  V ) and the other for the smartphone (  ,   ,   ), as illustrated in Figure 6.Thus, to derive the meaningful vehicle dynamics from sensor readings on the smartphone, DrivingSense must align the phone's coordinate system with the vehicle's.
Figure 7 depicts the relationship between the vehicle's coordinate and the phone's.Thus, our coordinate alignment aims to find the rotation angle, , , and , of -axis, -axis, and -axis of the smartphone.Based on the rotation angle, we can determine a rotation matrix  to rotate the phone's coordinate to match the vehicle's.Let  denote the acceleration of gravity.The angles of the coordinate on the phone to the vertical direction are   ,   , and   .When the vehicle moves with a constant speed, the acceleration readings are caused by the projection of gravity acceleration.The corrected values of the acceleration on the three directions of the smartphone are denoted as   ,   , and   .Therefore, we have the following results: As Figure 7 shows, we can calculate the rotation angle as  = |  −   |,  =   .Using (14), we can determine the value of .Thus, the rotation matrix  = ()()(). where According to the rotation matrix, the smartphone will go through a self-learning process to complete reorientation.After that, DrivingSense can obtain meaningful data readings that represent the vehicle's movement.

Dangerous Driving Behavior Identification.
In our scheme, DrivingSense collects sensor data from smartphones in real time to identify three dangerous driving behaviors: (1) speeding; (2) irregular driving direction change; (3) abnormal speed control.To achieve these functions, we should carefully design the detection method so that it can reduce the potential false negative dangerous driving behavior detection.

Speeding.
After the smartphone's coordinate reorientation and data error correction, DrivingSense obtains the meaningful data.Based on -acceleration and GPS readings, we can apply (4) to estimate the vehicle speed.In order to avoid the estimation error caused by the GPS bias, Driv-ingSense will reestimate vehicle speed every 150 m (usually, the GPS error correlation continues to more than 200 m [27]).When the vehicle speed exceeds the road speed limit obtained from a navigation system, DrivingSense identifies that the vehicle is in the speeding mode.Different from the existing speed estimation algorithm [22,30], we propose a novel speed estimation method.Not only does it not depend on the additional infrastructure, such as base station, but also there is no accumulative error during the speed estimation process.From (4), we can see that DrivingSense just utilizes the corrected the sensor data, providing drivers with an accurate speed estimation.

Irregular Driving Direction Change.
DrivingSense utilizes the -gyroscope to detect the driving direction change of vehicles.In our system, driving direction changes under three conditions, which are lane change, sharp turn, and gentle turn.We define the irregular driving direction change as the driver does not provide any caution signal to the drivers around him when the event of driving direction change happens.This is to say, the host vehicle's turn signal is off during this period.Therefore, the irregular driving direction change detection is divided into two stages: (1) the driving direction change detection; (2) the turn signal detection.
The Driving Direction Change Detection.The spatial movement of a vehicle can be divided into two kinds of movements: translation movement and spin movement.The spin movement is the key factor to distinguish turning style.The gyroscope of a smartphone is a sensitive device that can be used to detect angular speed in three dimensions according to the coordinate system of the phone.After aligning the phone's coordinate with the vehicle's, -gyroscope is used to reflect the spin movement of vehicles.The primary work of DrivingSense is to distinguish the driving direction change event from all the spin movement based on the corrected gyroscope readings.
In order to achieve this objective, in our initial experiment we collect three sets of -gyroscope of each driving direction change event.Based on the datasets, Figure 8 plots the -gyroscope cumulative distribution function (CDF) of lane change, sharp turn, and gentle turn.According to the figure, we find that when the -gyroscope reading exceeds 0.56 rad/s, one type of driving direction change happens.To filter out outliers due to any sudden change of vehicle, a window  is used.We set  = 3 in our implementation.
The Turn Signal Detection.As we know, when the turn signal is on, the vehicle will send an audio beep to respond to the driver.In our system, we let the smartphone detect the audio beep which is a distinct beep in the vehicle interior.In order to detect the audio beep of the turn signal, we collect an audio clip in a vehicle at the audio sampling rate of 44.1 kHz with a smartphone.Figure 9(a) plots the raw audio signal that contains background signal and turn signal beep in the time domain.The background signal is that there is no sound except for the engine sound of a car.The turn signal starts beeping approximately from the 520000th sample and lasts to the 1010000th sample.We crop the segment of the audio signal and the background signal.Then, we convert the time domain signal to the frequency domain through Fast Fourier Transform, as shown in Figures 9(b) and 9(c).We observe that the frequency domain of the background signal is almost equal to zero.The frequency band of the turn signal beep is between 4 kHz and 6 kHz, which can rule out the background signal.
With the knowledge of the frequency range of the audio beep send out by the turn signal, in our system we first utilize a band-pass filter [31] to filter out some of noise caused by the talking or music, improving the detection accuracy.After that, a sound cross-correlation algorithm [32] is used to detect the audio beep.Particularly, sound features of the turn signal are captured in advance.When filtering out a sound signal, DrivingSense implements the cross-correlation between the filtered sound signal and the previous captured signal.When there is a spike in the result, it means that there is turn signal sound.Figure 10 shows a sound wave cross-correlation result.It can be seen that there are spikes in the figure, which indicates that the audio signal contains the turn signal sound.

Abnormal Speed Control.
Since the abnormal speed control is related to abrupt acceleration or deceleration and erratic braking, it will all be reflected on the changes of longitudinal acceleration.Usually, the abnormal speed control indicates that the driver is in drunk driving or fatigue driving state, which is one of the main causes of traffic accident [33].The abrupt acceleration of vehicle will lead to a great increase in longitudinal acceleration.On the contrary, the abrupt deceleration or erratic braking will cause a great decrease of longitudinal acceleration.Therefore, the vehicle acts abnormally in either acceleration or deceleration, resulting in a large absolute value of   .
To detect the abnormal speed control, DrivingSense keeps checking the maximum and minimum value of longitudinal acceleration  max and  min in the raw data.If the amplitude of the value exceeds a threshold TH lon , a speed control problem is considered detected.Since the features of the acceleration and deceleration during driving are different even for the same driver, we set different thresholds for the acceleration and deceleration, denoted as TH + lon and TH − lon , respectively.In this paper, we set the threshold as two times the values of  max and  min .

Evaluation
In this section, we evaluate the performance of the Driv-ingSense with different types of smartphones.We first present the experimental setup.Then, we test and evaluate each component of DrivingSense, including smartphone sensor data correction, turn signal audio beep detection, speed estimation accuracy, driving direction change, and abnormal speed control detection.The following details the experimental methodology and findings.

Experimental Equipment.
To test the practicability of DrivingSense, we conducted our experiments on two Android smartphones.One is Nubia Z5S and the other is MX3.Both of them are equipped with accelerometers, gyroscope, and support 44.1 kHz audio signal sampling from microphones.The Nubia Z5S has a 2 GB RAM and Quad-Core 2.2 GHz Adreno Snapdragon 800 processor, while the MX3 has a 2 GB RAM and Quad-Core 1.6 GHz Exynos 5410 processor.

Experimental Scenarios.
To evaluate the generality and robustness of DrivingSense, we need to test our designs in a realistic driving environment.Since it is irresponsible to run an experiment that promotes dangerous behaviors without taking the sort of measures which car manufacturers take, it is challenging to build suitable experimental environment.To finish the experiment, we let DrivingSense sense the natural driving of a vehicle.We conduct experiments under a realworld condition, which is derived from Chengdu, a city in China.Figure 11 shows the area that the trace covered and there are two routes used for data collection.For route 1, the total length of the trace is up to 4.8 km.At the end of the trace it is an empty space.For route 2, the total length of the trace is up to 0.65 km and it is a straight road.5.1.3.Dataset.We implement our system using the Android platform.DrivingSense records sensed data from GPS, accelerometers, gyroscopes, and microphone during the natural driving of a vehicle.In order to verify the effectiveness of driving direction change detection, we deliberately let the vehicle make the driving direction change behaviors on route 1.Similarly, to verify the effectiveness of abnormal speed control detection, we let the vehicle make the abnormal speed control behavior at the end of route 1 which is an empty space.Table 1 summarizes the details of the two events.Since it is difficult to obtain the various accurate acceleration readings from on-board devices, to evaluate sensor data correction, we also collect data from route 2 in which the vehicle did little motion change.It also means that the true value of the accelerometer and gyroscope of a smartphone should be equal to zero.

Sensor Data Correction Performance.
Our accurate vehicle driving behavior detection is built upon the inerrant data source that derives from the natural driving conditions.Thus, we first evaluate the performance of smartphone sensor data correction algorithm.As we depict above, -acceleration has a comparatively large deviation from the true value.In this section, we use -acceleration readings as the test set.Since it is difficult to obtain the various accurate acceleration readings from the on-board device, we choose the dataset that is between two change points from route 2 as the test data.At this time, the true value of this dataset is zero.It also can be verified by a constant speed.Figure 12 presents the corrected result.From Figure 12(a), we can observe that the data errors of Z5S and MX3 are obvious differently.For the smartphone of Z5S, the data error is positive deviation.But for the MX3,  the data error is negative deviation.In addition, we can also observe that the corrected data gradually converge to the true value with time.From Figure 12(b) which is the a posteriori error estimation of the corrected set, we find that the convergence rate and correction accuracy of Z5S are better than MX3's.The reason is that the raw data of Z5S has more convergence than MX3's.Furthermore, the error variances of the smartphone are less than 0.05 after the 30th sample.It is an encouraging result.Furthermore, we also compare our correction algorithm with Kalman filter based correction algorithm [25] and SenSpeed [22] using the data from Z5S.We leverage the parameter of error variance which denotes variance between correction results and ground true values to evaluate the performance of the correction algorithms.Figure 13 presents the error variance of the three algorithms.We can observe that the error variance of DrivingSense is much lower than the other two algorithms.For Kalman filter based method, the error variance increases initially and tends to be stable with the number of samples.But it has a larger error variance as well.The reason is that it can only correct sensor data discreteness but cannot correct a bias.For SenSpeed, it has the highest error variance.The reason is that SenSpeed can only use the acceleration error at the beginning of route 2 to correct the following data readings.As we mentioned above, the sensor data error is not fixed.So it has larger cumulative errors than DrivingSense and SenSpeed.

Turn Signal Audio Beep Detection.
To evaluate the robustness of our turn signal audio beep detection algorithm, we collect audio signals in the other two scenarios: turn signal together with talking and music.Firstly, we analyze the spectrum characteristics of talking and music.As shown in Figures 14(c) and 14(d), the frequency band of talking is between 0.2 kHz and 1 kHz and the frequency band of music is between 0.5 kHz and 1.5 kHz.Thus, they can be well ruled out from the turn signal.As shown in Figures 15(a) and 15(c), they are the raw audio signal segments that derive from turn signal together with talking and music environment, respectively.It can be seen that human voices and music submerge  From the two figures, we can find that there are obvious spikes for each situation, which indicates the existence of the turn signal.Thus, we can conclude that, based on the noise filtering, our audio beep detection algorithm has a higher accuracy of turn signal identification in various environments.

Speed Estimation Accuracy.
We evaluate the speed estimation accuracy of our system using two test smartphones under two routes.To verify the effectiveness of our speed estimation method, we compare the estimated speed by our system with the SenSpeed [22] and the GPS.DrivingSense and SenSpeed both use the acceleration integration scheme to estimate speed.We compare the estimated speed with that of the ground truth, which is obtained from a calibrated OBD-II adapter.
Figure 16 presents the average estimation error in the two routes.For route 1, since the vehicle changed frequently, GPS cannot well keep up with the dynamic; it has the highest estimation error.Although DrivingSense and SenSpeed both use the acceleration integration scheme to estimate speed, SenSpeed cannot eliminate the accumulated error caused by sensor noise until at the reference point (the turning point).Thus, DrivingSense leveraging the sensor noise correction scheme has the lowest error compared with SenSpeed and GPS.For route 2, since the motion of the vehicle changed a little and there is no reference point, SenSpeed is worse than GPS and DrivingSense.Furthermore, we can observe that the average estimation error of GPS is lower than the DrivingSense's.The reason is that, under this scenario, the acceleration integration scheme would incur more estimation error caused by sensor noise correction error.But we can find that the bias is very small.Thus, we can conclude that DrivingSense has more greater universality.
To further evaluate the accuracy and robustness of DrivingSense, we analyze the speed estimation error.Figure 17 shows the CDF of the speed estimation error of the smartphone MX3 and Z5S.It can be seen that we get a relatively accurate speed estimation for our scheme.For the smartphone Z5S, the estimation error is less than 1.9 m/s; by comparison, the max estimation error for the smartphone MX3 is 2.06 m/s.We analyze the datasets that are used for the speed estimation, finding that the speed estimation error is mainly caused by two reasons: (1) the existing outlier point; (2) the changing of the error deviation of the collected data.To tackle these problems, an outlier point filter algorithm and an error deviation recalculation method can be used.Anyway, the speed estimation error of our system is within an acceptable range, which indicates DrivingSense can detect the speeding driving behavior with high accuracy.

Driving Direction Change and Abnormal Speed Control
Detection.The main function of our scheme is to detect the dangerous driving behavior under real-world conditions.During the route, we deliberately let the vehicle make the   driving direction change behavior and at the end of the route, which is an empty space, we let the vehicle make the abnormal speed control behaviors.There are 56 driving direction change events and 20 abnormal speed control events for the two smartphones.The confusion matrix in Table 2 shows the precision and recall results of the two events.The average precision and recall for driving direction change and abnormal speed control detection are 93.95% and 90.54%, respectively.After checking the test data, we find that the false negative of the driving direction change event is mainly caused by gentle shifting of the vehicle when it makes a lane change or gentle turn.During this process, the -gyroscope does not exceed the threshold that identifies the driving direction change occurrence.The false negative of the abnormal speed control detection event is mainly caused by the slow driving.When we make the experiment for the abnormal speed control, the speed of the vehicle is relatively low.At that time, when the vehicle is in abrupt deceleration, -acceleration is not greater than the predefined threshold.

Conclusion
In this paper, we propose DrivingSense that makes the best of smartphones for dangerous driving behaviors detection, so that it can provide drivers with a warning to avoid traffic accidents.DrivingSense can detect three dangerous driving events: speeding, irregular driving direction change, and abnormal speed control.To achieve the high accuracy detection objective, we first propose a smartphone sensor data correction algorithm based on an improved Kalman filter algorithm.After that, we utilize the corrected data to estimate the vehicle's behaviors in real time.To calculate the vehicle

Figure 1 :
Figure 1: The raw data of smartphone sensors.(a) The -acceleration readings of smartphone; (b) the -gyroscope readings of smartphone.The data error of the accelerometer sensor is larger than gyroscope sensor's.

Figure 2 :
Figure 2: GPS trajectory sample.The vehicle trajectory is nearly paralleled with the real roads.

Figure 4 :
Figure 4: An illustration of sensor data reading change when the vehicle driving behavior changes.(a) The -acceleration readings of smartphone.(b) The -gyroscope readings of smartphone.Δ1 is the deviation of data readings when the vehicle is in uniform motion.Δ2 is the deviation of data readings when the vehicle motion changes.Δ2 is much greater than Δ1.

Figure 5 :
Figure 5: The change trend of -acceleration and -gyroscope when the vehicle motion changes.

Figure 6 :
Figure 6: The vehicle's coordinate system and the smartphone's coordinate system.

Figure 7 :
Figure 7: An illustration of the relationship between the vehicle's coordinate and the smartphone's.

Figure 8 :
Figure 8: CDF of the -gyroscope over lane change, hard turn, and gentle turn of vehicle.
The raw audio signal in the time domain, which contains background signal and turn signal beep The frequency domain of the turn signal beep

Figure 9 :
Figure 9: analysis of turn signal beep.

Figure 10 :
Figure 10: A sound wave cross-correlation result.

Figure 11 :
Figure 11: Real road driving trace for DrivingSense evaluation.
Figure 12: The -acceleration data error correction.

Figure 13 :
Figure 13: Error variance of sensor data correction.
The raw audio beep of talking in the time domain The raw audio beep of playing music in the time domain The frequency domain of playing music

Figure 14 :
Figure 14: The spectrum characteristics of talking and playing music.
The detection result of playing music

Figure 15 :
Figure 15: The detection of turn signal in different environments.

Table 1 :
Dataset of driving direction change and abnormal speed control.

Table 2 :
The overall accuracy for detecting the driving direction change and abnormal speed control.