SaferCross: Enhancing Pedestrian Safety Using Embedded Sensors of Smartphone

The number of pedestrian accidents continues to keep climbing. Distraction from smartphone is one of the biggest causes for pedestrian fatalities. In this paper, we develop <inline-formula> <tex-math notation="LaTeX">$\mathsf {SaferCross}$ </tex-math></inline-formula>, a mobile system based on the embedded sensors of smartphone to improve pedestrian safety by preventing distraction from smartphone. <inline-formula> <tex-math notation="LaTeX">$\mathsf {SaferCross}$ </tex-math></inline-formula> adopts a holistic approach by identifying and developing essential system components that are missing in existing systems and integrating the system components into a “fully-functioning” mobile system for pedestrian safety. Specifically, we create algorithms for improving the accuracy and energy efficiency of pedestrian positioning, effectiveness of phone activity detection, and real-time risk assessment. We demonstrate that <inline-formula> <tex-math notation="LaTeX">$\mathsf {SaferCross}$ </tex-math></inline-formula>, through systematic integration of the developed algorithms, performs situation awareness effectively and provides a timely warning to the pedestrian based on the information obtained from smartphone sensors and Direct Wi-Fi-based peer-to-peer communication with approaching cars. Extensive experiments are conducted in a department parking lot for both component-level and integrated testing. The results demonstrate that the energy efficiency and positioning accuracy of <inline-formula> <tex-math notation="LaTeX">$\mathsf {SaferCross}$ </tex-math></inline-formula> are improved by 52% and 72% on average compared with existing solutions with missing support for positioning accuracy and energy efficiency, and the phone-viewing event detection accuracy is over 90%. The integrated test results show that <inline-formula> <tex-math notation="LaTeX">$\mathsf {SaferCross}$ </tex-math></inline-formula> alerts the pedestrian timely with an average error of 1.6sec in comparison with the ground truth data, which can be easily compensated by configuring the system to fire an alert message a couple of seconds early.


I. INTRODUCTION
The number of pedestrian accidents continues to keep climbing. In 2018, 6,283 pedestrians were killed which accounted for an increase of 3% compared with pedestrian fatalities in 2017, the highest number of pedestrian fatalities since 1990 [1].
Many sources point out that smartphone distraction is one of the major causes for pedestrian fatalities [2] [3] [4]. Many pedestrians use their mobile phones while walking on sidewalks and crossing the street [5] [6]. A recent study shows that more than a third of pedestrians use their mobile phones while crossing streets [7], and 16% of pedestrian accidents were caused by distraction due to phone use [8]. Another study shows that 85% have seen distracted pedestrians, and 26% of the respondents were actually involved with distracted-walking accidents [9]. According to the report from US Consumer Product Safety Commission, the percentage of pedestrian injuries involving smartphones are increasing steadily [10]. Interestingly, the significant rise in the pedestrian injuries started in 2009, and this is exactly when smartphones started to take hold [11]. These distracted pedestrians are even called "smartphone zombies" in recent scientific publications to stress the seriousness of the problem [12]. VOLUME X, 2020 1 arXiv:1805.00442v2 [cs.CY] 26 Apr 2020 In this paper, we aim to develop a mobile system that enhances pedestrian safety by preventing distracted phone use. Numerous approaches have been designed and deployed to protect distracted pedestrians, e.g., using a signage [13], and LED spotlights [14] as shown in Fig. 1. However, painting road signs and installing LED lights at every crosswalk not only involves huge cost, but it can even be distraction to drivers especially at night. With a myriad of embedded sensors such as accelerometers, cameras, microphones, and GPS, smartphones have opened the new opportunities for various applications [15]; especially, those sensors can be used to improve pedestrian safety by directly alerting pedestrians. The camera of smartphone is used to detect approaching vehicles posing danger to pedestrians [16]. Some mobile systems utilize communication between cars and pedestrians. For example, Wu et al. adopt the Dedicated Short Range Communication (DSRC) to enable the vehicle to pedestrian communication [17], and Lin et al. utilize the cellular network [18] to perform risk analysis and alert the pedestrian accordingly.
Although existing solutions contribute to improving pedestrian safety, most solutions are focused on a certain aspect of a mobile system for pedestrian safety such as detection of approaching cars, communication between cars and pedestrians. However, a number of essential system components are still missing to build a complete mobile system for pedestrian safety. In this paper, we aim to develop a "fully-functioning" mobile system for pedestrian safety by developing these critical system components for precise pedestrian positioning, energy efficiency, accurate phone activity detection, and effective risk assessment. To this end, we present SaferCross , a mobile system for pedestrian safety based on the embedded sensors and WiFi Direct of smartphone [19]. SaferCross effectively senses approaching cars, performs real-time risk assessment, and alerts drivers and pedestrians in a timely and energy-efficient manner without requiring any modifications to the host mobile system. The key contributions of SaferCross are development of the essential system components that can be adopted for developing mobile systems for pedestrian safety, ultimately to spark the mobile computing research focused on protecting pedestrians from accidents. We note that it is ideal to force pedestrians not to use their phones while walking. At the same time, however, we admit that there are still a lot of pedestrians who are tempted to use their phones. In fact, a huge number of pedestrian involved accidents happen every year. As such, we argue that SaferCross is developed as an assistive technology for those distracted pedestrians and is not intended to encourage blind reliance on the technology.
SaferCross is built upon fundamental technologies focused on enhancing the effectiveness of pedestrian localization, energy efficiency of smartphone, phone activity detection, and situation awareness. More specifically, the pedestrian localization module of SaferCross is specifically designed to accurately localize slow-moving pedestrians. This module is particularly useful for localizing pedestrians in urban areas with skyscrapers where accurate positioning based on GPS is very challenging. Based on the observation that pedestrians walk along a sidewalk, a map matching algorithm is adopted and customized for accurately localizing slow-moving pedestrians. To mitigate the impact of significant power consumption of the GPS module and improve the energy efficiency, a dynamic approach is proposed to activate the GPS module adaptively depending on the estimated time that the user is expected to be geographically close to a nearby crosswalk. Additionally, a novel algorithm is designed to detect the user activities effectively so that the system is activated at the exactly right time. Extensive experiments were conducted in which both the module-level test and the integrated test were performed to evaluate the effectiveness of the proposed system modules individually and the system performance as a whole. The results demonstrate that the localization accuracy was significantly improved by up to 72%; the user phone viewing event was accurately detected with the accuracy of over 90%; and the energy consumption was reduced by 50.2%. An integrated test was performed to evaluate the effectiveness of the interplay of the individual system components. The results show that all modules effectively cooperate to provide an alert message to the user in a timely manner with an error of 1.6sec on average in comparison with the ground truth data. Such a small error can be easily compensated by configuring the system to fire an alert message a couple of seconds early. The contributions of this paper are summarized as follows.
• A Hidden Markov Model-based map matching algorithm is designed for accurately localizing pedestrians. • An adaptive algorithm is developed to improve the energy efficiency of a mobile system for pedestrian safety. • An effective algorithm is created to detect the pedestrian phone viewing event accurately. • A novel approach is developed to perform risk assessment effectively based on Wi-Fi Direct-based communication between cars and pedestrians. • Experiments are performed in a parking lot to demon-strate the effectiveness of individual system components and the proposed mobile system as a whole. This paper is organized as follows. Section II presents a literature review on related approaches designed for improving pedestrian safety. In Section III, we describe an overview of the proposed app followed by the details of each system component. The performance of the proposed app is evaluated in Section IV. We then conclude in Section V.

II. RELATED WORK
Wang et al. develop an app that uses the rear camera of a phone to monitor approaching vehicles to alert the pedestrian [16]. A machine-learning-based image processing algorithm is designed to capture approaching cars for pedestrian safety assessment. This approach, however, raises the privacy issue as it takes photos of cars without acquiring permission of drivers. Additionally, the energy efficiency is another problem as this system is based on continuously executing image processing algorithms which consume much energy.
A cellular network is used to enable car-to-pedestrian communication [18]. However, this approach based on a cellular network not only incurs high cost but also results in non-negligible message delay compared with the direct peer to peer communication. Especially, even a small message delay is critical in mobile systems for pedestrian safety. Dedicated Short Range Communication (DSRC) is a wireless communication standard specifically designed for vehicle-tovehicle communication (V2V). Researchers utilize DSRC as a means to enable vehicle-to-person (V2P) communication for pedestrian safety [17]. However, implementing DSRC on a phone requires significant modifications to the host system firmware, and extra device support is needed to operate DSRC on vehicles.
Specialized hardware is designed to enhance pedestrian safety. For example, sensors are adhered to the pedestrians' shoes to detect whether the pedestrian is crossing at a crosswalk [20]. Those sensors are used to calculate the slope between the sidewalk and the roadway as an indicator to find whether the pedestrian is about to cross the street. Another example is to exploit an electronic transponder that is attached to the pedestrian's body to determine whether the pedestrian is visible or not [21]. However, typically asking the users to attach these types of specialized hardware is not easy, preventing widespread adoption of such technology.
WiFi has been actively considered as an appropriate alternative technology to enable vehicle to pedestrian communication for pedestrian safety [22] [23] [24]. In particular, Wi-Honk is quite similar to the Communication module of our work [23]. However, WiHonk is based on the modification of the beacon frame of IEEE 802.11 which requires the root privilege that makes it difficult for common use. Additionally, no details are provided regarding when to exchange messages with cars, potentially resulting in unnecessary network bottleneck. WiSafe is another WiFi-based pedestrian safety system which resembles our Communication module [24]. Our work is different in that the system design involves both the driver and pedestrian while WiSafe utilizes only one-way communication from a pedestrian to cars.

III. SYSTEM DESIGN A. SYSTEM OVERVIEW
SaferCross has two modes of operation: the driver mode and pedestrian mode. In the driver mode, SaferCross keeps monitoring the speed and location of the vehicle, and sends the speed and location information to the pedestrians within the communication range of WiFi Direct. In the pedestrian mode, SaferCross keeps track of the pedestrian location and activity to detect if the user is attempting to cross a crossing while viewing their phone. It communicates with approaching cars, i.e., driver phones of those cars, to obtain the speed and location information of the cars and estimates the probability of collision. Depending on the calculated probability of collision, the pedestrian is alerted. To minimize driver distraction, the driver is only alerted when the pedestrian ignores the alert message several times.
SaferCross also supports the stand-alone mode where it works without requiring to communicate with driver phones. In other words, it can be configured to alert the pedestrian based only on the distance to the crossing and the pedestrian's walking direction with varying safety levels (Fig. 2). More specifically, the user will be alerted if he is close to the crossing and his phone screen is on (Level 3); if the phone screen is on and he is viewing the phone (Level 2); and if the phone screen is on and he is viewing the phone and he is walking toward the crossing (Level 1).
SaferCross consists of five main system modules, namely Location, Energy, Context, Alert, and Communication ( Fig. 3(a)). Specifically, the Location module is developed to improve the positioning accuracy of the pedestrian. The resulting pedestrian location information is distributed to other system modules. The Energy module is designed to save energy by adaptively controlling the operation of the GPS module. Taking the user location as input from the Location module, the Context module identifies the user activity, e.g., whether the user is walking, running, and viewing their phone. In particular, the module addresses the challenge of effectively detecting the 'phone viewing' activity. The Alert module is where the collision probability is calculated. As can be seen in Fig. 3(a), it interacts with the Location and Communication modules to obtain necessary information in calculating the collision probability. The Alert module then makes a decision to send an alert message to the user based on the resulting collision probability. The Communication VOLUME X, 2020 Geographically closest location from zt on a sidewalk segment r i |z i − z j |geo Geodetic distance between z i and z j σz Standard deviation of GPS measurements  module enables P2P communication between pedestrians and approaching cars using WiFi Direct.
To explain the operation of SaferCross in more detail, a flowchart ( Fig. 3(b)) is used. When the system is started, it identifies whether the user is a driver or not. For this, we adopt an existing driver phone detection algorithm [25]. If the user is a driver, using WiFi Direct, SaferCross starts to scan on the predetermined channel to be connected with pedestrians. Once it is connected, SaferCross sends the vehicle information to the pedestrian so that the pedestrian can calculate the collision probability. More specifically, the autonomous mode of WiFi Direct is adopted to minimize the connection establishment time and to alert the user timely [19].
If the user is a pedestrian, the Location module is activated to obtain the calibrated user location. This location information is distributed to the Energy, Context, and Alert modules. The Energy module in turn finds if the user is located within an alert zone, a region around a crossingdetailed description about the alert zone will be presented when we explain the Energy module in Section III-C. If the user is in an alert zone, the Context module kicks in and detects whether the user is actually walking/running while viewing their phone. If the phone-viewing-event is detected, the Context module triggers the Communication module. And then the Communication module is used to create a P2P group for Wi-Fi Direct to initiate communication with cars and obtain necessary information for the Alert module to perform risk assessment. Notations used to explain the modules of SaferCross throughout this paper are summarized in Table 1.

B. IMPROVING POSITIONING ACCURACY
Attaining high positioning accuracy of the pedestrian is crucial for SaferCross to estimate the collision probability accurately and alert the pedestrian timely. However, achieving precise localization using the GPS module of smartphone is a challenging problem, especially in urban canyons with significant multipath and non-line-of-sight effects. To understand the localization accuracy of the smartphone that we used in our experiments, we collected GPS locations in a metropolitan area. Fig. 4 shows the collected GPS locations. The red-colored dots represent the measured GPS locations. The green arrow indicates the ground-truth trajectory. The mean location error was very large as 12.9m. The Location module of SaferCross is designed to improve the positioning accuracy. It finds highly erroneous GPS locations and replaces them with newly estimated locations. The Location module is developed based on the observation that pedestrians walk along a sidewalk, and therefore a GPS location that is geographically far from a sidewalk can be considered as an outlier. Specifically, a Hidden Markov Model-based map matching algorithm is designed to infer the current sidewalk segment using preceding user locations and to remove/replace erroneous GPS locations. In contrast to existing map matching algorithms, an unique approach is developed specifically for 'slow-moving' pedestrians. Fig. 5 depicts an overview of the Location module. The current GPS location is provided as input to the map matching algorithm. The algorithm then estimates the current sidewalk segment based on the preceding user locations. Once the current sidewalk segment is identified, the algorithm calculates the location error and rejects or replaces the GPS location with a newly estimated location.
The Location module identifies the current sidewalk segment using a Hidden Markov Model (HMM). Let us define a set of states S = {r 1 , r 2 , ..., r N } where each state represents a sidewalk segment with N being the total number of states. Note that only the sidewalk segments in the surrounding area of the current user location are considered in finding the current sidewalk segment in order to reduce the computational overhead. Now we exploit HMM to find the most probable sidewalk segment r i ∈ S, 1 ≤ i ≤ N given the observation of a set of the preceding GPS locations in a sliding window examined at time t, which is denoted by Z t . A unique aspect of the proposed map-matching algorithm based localization method compared to other map matching algorithms is that a set of preceding locations are taken into account rather than a single location to account for the low speed of a pedestrian.
More formally, a HMM is modeled as λ = (S, Z t , A, B, π), where S is the state set. Z t is an observation that is represented as a sliding window of size ω consisting of the preceding GPS locations, i.e., Z t = {z 1 , ...z ω }, where z j is a GPS location measured at time j. A is the observation probabilities denoted by P (Z t |r i ), 1 ≤ i ≤ N . It defines the likelihood that the user is actually on sidewalk segment r i . B is the transition probabilities denoted by P (r j |r i ), i = j(i, j = 1...N ). It represents the likelihood of the user moving from one segment r i to another r j . π is the initial state probabilities which are defined as The probability models A, B, and π are designed to decide the most probable current sidewalk segment. First, the observation probabilities A are computed based on the fact that a GPS location geographically far from the current sidewalk segment is less likely to occur [26]. An observation probability P (z t |r i ) for a GPS location z t thus can be modeled as the probability distribution of the geodetic distance between z t and z t,i . Here z t,i is the geographically closest location from on a sidewalk segment r i from z t . Let us denote this geodetic distance by |z t − z t,i | geo . Since the geodetic distance represents the GPS positioning error which is known to follow the zero-mean Gaussian [27], the observation probability can be written as: where σ z is the standard deviation of GPS measurements, which can be obtained empirically. Note that our system VOLUME X, 2020 regularly updates σ z based on previously measured GPS locations since σ z may change depending on the environment. Now considering a set of GPS locations Z t = {z 1 , ...z ω } stored in a sliding window, the observation probabilities A = P (Z t |r i ) can be defined as follows.
which represents the likelihood that the user is on sidewalk segment r i given the set of preceding GPS positions Z t . Next we model the transition probabilities B which define the likelihood that the user transitions to another sidewalk segment. For this, let us define the moving distance between two GPS locations z t and z t+1 , denoted by |z t+1 − z t | mov . The moving distance refers to the geographic distance between the two GPS locations along the shortest sidewalk trajectory. Fig. 4 illustrates the geodetic and moving distance between two GPS locations z t and z t+1 . Newson and Krumm noted that the transition probability depends on the difference between the moving distance and the geodetic distance [26]. More specifically, the transition probability becomes higher when the difference is larger, and vice versa. It was also shown by [26] that the difference follows the exponential distribution. A trick that we make to account for the slow moving speed of the pedestrian is to use the GPS location measured time ago (i.e., z t− ) rather than using the preceding GPS location (i.e., z t−1 ) in calculating the moving and geodetic difference. Now by denoting the distance difference as β . Finally, since the transition probabilities B depend on the distance difference, we obtain: B = P (r j |r i ) ≈ p(δ). We also note that using Eqs. 1 and 2, the initial state probabilities π = P (Z 1 |r i ) can be easily calculated. Given these probability models A, B, and π, the proposed map matching algorithm identifies the current sidewalk segment. Once the current sidewalk segment is identified, the "valid" region is calculated. Any GPS location that is outside this region is either rejected, or projected onto the region. More precisely, the width of the region is defined as 'α· (max walking speed) · (GPS measurement interval)' and the height of it is defined as 'α· (the sidewalk width)'. Here, the parameter α is adopted to allow the user to adjust the tolerance to location errors. In our experiments, we used 15m as the threshold to reject a GPS location. If the distance between a measured GPS location and the valid region is greater than 15m, we rejected the GPS location, and if not, the GPS location is projected onto the closest point on the valid region.

C. IMPROVING ENERGY EFFICIENCY
The GPS module of smartphone is one of the most power hungry sensors [28]. We develop the Energy module to improve the energy efficiency of SaferCross that heavily utilizes the GPS module. To characterize the energy consumption of the Location module of SaferCross, an experiment was performed using the Monsoon Power Monitor [29]. Fig. 6 Samsung Galaxy Nexus shows the experimental setup. We connected the power monitor's probes to the phone's battery terminals so that the monitor provides current to the phone. And then, a laptop was connected to the power monitor via USB and measured the samples of current drawn and the voltage at a rate of 5KHz. Fig. 7 shows that a large amount of power was consumed for a short period of time when the app was started to load and display the app on the screen. After that, the app used about 1.5 watt for updating and calibrating the position. An interesting observation was that the GPS module consumed very a small amount of energy, as low as the baseline energy consumption, when the GPS module was put into the sleep mode, indicating that significant energy savings can be achieved by putting the GPS module into the sleep mode. It is worth to note that the sleep mode depends on mobile operating systems. For example, by the sleep mode in Android, we mean that we stop receiving position update, while the GPS module maintains the lock on the acquired satellites, so that when we resume position update, the GPS module does not need to re-acquire and lock on satellites.  The Energy module determines dynamically when to turn on the GPS module and when to put it into the sleep mode. To explain the mechanism, we need to define the alert zone. The alert zone is a 2D region, the boundary of which is equidistant from a nearest crosswalk (Fig. 8). This alert zone is important for SaferCross as system components are activated only when the user is within an alert zone. An interesting aspect of this alert zone is that it can also be set up for non-crosswalk areas to prevent accidents for jaywalkers. The basic mechanism for saving energy is to estimate the time when the user will be at an alert zone and put the GPS module into the sleep mode until that time. More specifically, the estimated time is calculated as d vmax where d is the shortest geodetic distance between the current user location and the closest alert zone, and v max is the maximum brisk human walking speed [30]. An interesting aspect of the Energy module is that GPS is adaptively controlled in coordination with the provided map and the associated alert zones, considering the user walking direction. The walking direction can be monitored even if the GPS is off based on a known technology [31] so that the GPS will be turned back on when the user direction is reversed to re-estimate the time.

D. DETECTING PEDESTRIAN PHONE USE
The Context module is developed to effectively detect the user-phone-viewing event. However, detecting the phoneviewing event is hard because it is associated with limited user interactions such as tapping on the phone. There is an approach that utilizes the camera of the phone to detect the phone viewing event by recognizing the user's face/eyes [32]. A limitation of this approach is the privacy concerns. Furthermore, the phone orientation information is insufficient to determine whether the user is viewing the phone or not.
In order to develop a novel approach for detecting the phone-viewing event, we hinge on the observation that when the user views their phone while walking, they tend to try to minimize phone shaking to better read email/text messages, and watch videos. Based on this motivational observation, we quantify phone shaking using the variance of the acceleration magnitude of phone. We then use the quantified data to detect the phone-viewing event. More precisely, given an accelerometer reading (a x , a y , a z ) of phone in x, y, and z directions respectively, we remove random noise using the standard low-pass filtering. As a result, we obtain filtered accelerometer data denoted byâ x ,â y ,â z . The magnitude of the acceleration vector m is then calculated as m = â x 2 +â y 2 +â z 2 .
A sliding window W = {m 1 , m 2 , ...m φ } is used to store a sequence of acceleration magnitude values collected over a period of time. The variation of the magnitude values in a window is represented as the mean absolute deviation (MAD) which is used to quantify the shaking of phone. Fig. 9 displays an example of MAD values for both phone-viewing and non-viewing events with a 10-sec sliding window. Leveraging the clear difference between the MAD values of the two events, we design a simple threshold-based method to detect the phone-viewing event. More specifically, a threshold Γ is defined as the average of the mid points of MAD values for VOLUME X, 2020 . A more advanced AI-based and dynamic mechanism to determine the threshold is left as a future work.
An experiment was performed to evaluate the feasibility of the proposed approach. Five volunteers participated in this experiment. They were asked to walk with viewing their phones. They were also asked to walk without viewing their phones. Figs. 9 and 10 show the results for different sizes of the sliding windows, i.e., 10sec and 20sec, respectively. As it can be seen, MAD values for the phone-viewing scenario were significantly smaller than that for the non-phoneviewing scenario, allowing us to clearly differentiate the two scenarios. The proposed method turns out to be quite accurate with detection accuracy over 90%.
It is also worth to note that since the Context module is only activated when the user is within an alert zone, and the accelerometer consumes significantly less amount of power than the GPS module, the energy efficiency issue for the Context module is less critical than the Location module.

E. DETERMINING WHEN TO ALERT THE USER
The Alert module of SaferCross is developed to determine when to alert the user by estimating the collision probability. This module is activated when the user is within an alert zone. It sends a REQ message to approaching vehicles via WiFi Direct. In response to the REQ message, vehicles send a REP message to the user. The REP message contains information required to estimate the collision probability including the vehicle speed v c , vehicle mass m, cross-sectional area of the vehicle A, and time for the vehicle to reach the crossing denoted by t c (Fig. 11). The vehicle and the pedestrian keep exchanging these messages to update the collision probability in real time to account for the changing motion of the vehicle and the user.
In estimating the collision probability, the time for the pedestrian to reach at the crossing is calculated, i.e., t p = dp vp where d p is the shortest geodetic distance between the pedestrian and the crossing, and v p is the user walking speed. The Android context API is used to determine v p . Specifically, we use a brisk walking speed [30] when the API detects that the user is walking; if the user is running, v p is set to a predetermined running speed. In particular, if the user is not walking or running, the collision probability is not calculated.
It is important to note that to provide the near real-time computation of the collision probability, when the user in an alert zone, the calculation of the current sidewalk segment of the Location module is suppressed, which is based on the observation that the user stays in the same sidewalk segment when she is in the same alert zone.
Given v c , m, t c , A, and t p , the Alert module is ready to estimate the collision probability. Let v c (i), m(i), t c (i), and A(i) be the vehicle speed, vehicle mass, amount of time to reach at a crossing, and cross-sectional area for vehicle i, respectively. If t p max(t c (i)), ∀i, i.e., if the user is expected to reach at the crossing long after all approaching vehicles have passed, the user is not alerted. On the other hand, if t p < max(t c (i)), ∃i, i.e., there is at least one approaching vehicle around the crossing by the time the user reaches at the crossing, the module estimates the collision probability. Consequently, if the following two conditions are satisfied, an alert message is generated for the user: (a) The pedestrian is walking/running while viewing the phone; (b) The probability of collision is greater than a threshold. Note that the estimation of the collision probability is continually updated as the REQ and REP messages are kept being exchanged between vehicles and the user. Thus, if there is any new vehicle within the range of WiFi Direct, the collision probability for that new vehicle will be calculated and updated.
More details are presented on how the collision probability is calculated. First, we define a term 'user warning time' denoted by t warning = min(t c (i)) − t p that represents the amount of time allowed for the driver to avoid an accident after he sees the pedestrian who is about to cross the street. And then, the collision probability is estimated as P (t delay + t react + t skid > t warning ), where t delay is the round-trip message delay for a single-hop 802.11 link. t react is the driver reaction delay, and t skid is the amount of time from the point when the driver applies brakes until the car completely stops. If the sum of these time delays is greater than t warning , the likelihood of collision is deemed high. In particular, we disregard the WiFi Direct connection establishment time since the connection has been already established before the first alert message is sent from the user to the approaching cars.
More specifically, t delay is empirically obtained as the pedestrian continuously exchanges messages with approaching vehicles, i.e., t delay is the average of measured roundtrip message delays. In calculating t react , we leverage the observation that the log-normal probability model fits the driver reaction time well [33]. Thus, t react is defined based on the log-normal distribution [34] as follows: where we select the mean and standard deviation of the driver reaction time as µ = 1.14 and σ = 0.32, respectively according to the experimental data collected by Gaziz et al. [35]. To calculate t skid , we first compute d skid that is the distance that a car moved until it is completely stopped after brakes are applied as follows: , where m is the vehicle mass, and v p is the vehicle speed, which we obtain from the REP message. f is the resistance force, which is calculated based on the model proposed by Ho et al. [24].
where ρ is the density of air, A is the cross-sectional area of the vehicle, C d is the drag coefficient, v r is the speed of the vehicle relative to the air, and f 0 is the other resistance force. In our experiments performed on a sunny day on a good conditioned road with Volkswagen Passat 2013, we used the parameter: m = 1400kg, µ k = 0.8, A = 2.7m 2 , C d = 0.25, ρ = 1.23kg/m 3 according to [36] [37] [38]. v r was approximated as the current vehicle speed v due to the slow wind speed. Thus, t skid = d skid v . Once t delay , t skid , and t warning are known, the collision probability can be written as: P (t react > t warning − t delay − t skid ) which can be calculated leveraging the fact that t react follows the log-normal distribution specified in Eq. 3. Note that we are very careful in sending an alert message to approaching cars. The reason is that alert messages may disturb safe driving. In designing the Alert module, thus, we give an emphasis on alerting the user first in an hope that the user will stop and look up when they receive the alert message. However, if the user ignores the alert message (e.g., by clicking the cancel button), an alert message is eventually sent to the driver.

F. ENABLING COMMUNICATION BETWEEN PEDESTRIAN AND CARS
To enable direct communication between the user and approaching cars, WiFi Direct is used. WiFi Direct is a standard designed by the WiFi alliance to facilitate device-to-device (D2D) communication between nearby devices without involving an access point [19]. In WiFi Direct, devices communicate by establishing a group. One of them is the group owner (GO), and the others are the group members (GM). These roles are negotiated by the devices in the device discovery phase. The GO implements the AP-like functionality, and the GMs act like clients. Specifically, the GO advertises to its GMs and allows new GMs to join the group. The GO runs a Dynamic Host Configuration Protocol (DHCP) server to provide IP addresses to joining GMs after going through the WiFi Protected Setup (WPS) phase.
In SaferCross, the pedestrian is the GO, and approaching cars are the GMs. An approaching car scans a predefined channel to search for the GO. Once the GO is discovered, the car joins the group immediately. There are two main challenges. The first one is that these scanning and negotiation processes take too much time. The literature shows that it can take about 8 to 9 seconds [19]. Fortunately, WiFi Direct provides the autonomous mode in which the negotiation process is not required as the GO is predetermined. The autonomous mode fits perfectly with SaferCross because there are clear roles, i.e., the user and the cars. Our experiments show that the average time to form a group in the autonomous mode is 2.8 seconds, which coincide with the results of the previous research [19].
Another challenge is that WiFi Direct is essentially designed to support 1-to-1 or 1-to-many communication. For example, consider Fig. 11 in which the user P ed A forms a group (1-to-many) with two cars Car A and Car B . However, there may be other users around, say P ed B in this figure who wants to communicate with the cars. Basically, the challenge is how to allow the GMs (cars) to join more than one groups. According to the WiFi Direct Specification, operating GMs for more than one groups is not precluded, but the implementation is not described [39].
We address this challenge by allowing the user to overhear on the operating channel for a very brief moment, if the user is not the GO. For example, P ed B overhears the message exchanges between P ed A and the cars. P ed B then finds that the cars have already formed a group with P ed A . Since there is already a group, P ed B joins as a GM and communicates with P ed A instead of the cars. Now the trick is that the REP messages received from the GO (i.e., P ed A ) are forwarded to P ed B . As a result, although P ed B is not the GO, it still can receive the vehicle information that it needs to compute the collision probability. Essentially, the proposed solution effectively establishes the virtual n-to-n communication based on a single group.

IV. EXPERIMENTAL RESULTS
We implemented SaferCross on a Samsung Galaxy S6 which is equipped with 1.5GHz octa-core processor and 3GB RAM running on Android 5.0. We performed experiments in a department parking lot (Fig. 12). To characterize the exper-VOLUME X, 2020  imental environment, the packet delivery rates (PDR) were measured for both Pedestrian → Driver, and Driver → Pedestrian. The average PDR was over 90% when the distance between the car and the pedestrian was smaller than 60m (Fig. 13). Based on the results, the length of the emulated road segment was set to 75m including the 20m acceleration zone.
A driver ran SaferCross in the driver mode. A Volkswagon Passat'13 was used which moved along the 75m road segment. The driver was asked to accelerate the car to reach the desired vehicle speed in the 20m acceleration zone (Fig. 12). After reaching the desired speed, the vehicle's cruise control was used to maintain the same speed. Another participant was asked to act as a pedestrian with SaferCross in the pedestrian mode and walk toward the crossing. To ensure safety, we made sure that the pedestrian always stops at the crossing.
We performed the module-level test first to evaluate the performance of individual system components. We then con-ducted the integrated test to evaluate the overall performance of SaferCross. The main parameter used for this experiment was the vehicle speed, and we used the 'user warning time' t warning as the main metric because it effectively measures the performance of SaferCross as a whole. Specifically, we can get the accurate user warning time only if all other system components work correctly and the interplay of these components functions effectively. The measured user warning time was compared with the ground truth data.
The experimental environment serves effectively the purpose of evaluating the performance of SaferCross in comparison with conducting the experiment in real roads. The individual module test can be done readily without accounting for real traffic conditions. Also, the integrated test would effectively approximate the performance of SaferCross in real roads, because eventually the pedestrian maintains communication only with the foremost vehicle for estimating the collision probability regardless of the traffic of approaching vehicles, and the vehicle used in the experiment effectively represents the foremost vehicle. It should be noted, however, that in order to understand better the effect of other realworld factors such as obstacles, weather conditions, lighting conditions, and human factors, performing experiments in real roads would be valuable. Due to the space limitation and restricted access to public roads, we had to leave the extension of the experiment as future work.

A. POSITIONING ACCURACY
Positioning accuracy was measured in both rural and city areas without using the Location module first. Five different trajectories were used in each area. In each experiment, a participant was asked to walk along the trajectories to measure the GPS locations and calculate the location errors. Specifically, the location error was defined as the shortest geodetic distance from the measured GPS location to the ground-truth trajectory. Fig. 14 shows the cumulative distribution graph of the location errors for both the rural and city environments. The mean location error for the rural area was 0.9m. The location error for the city area was significantly greater than the rural area as 12.9m due to many obstacles that disturbed reception of signals from satellites.
To improve the localization accuracy, the Location module was activated, and the experiment was performed under the same conditions. In particular, other system modules were turned off in order to focus on evaluating the effectiveness of the Location module. The results show that the Location module significantly reduced the location errors (Fig. 14). The average location errors for the rural and city areas after applying the Location module were 0.8m and 3.5m, respectively. Although the improvement was not significant for the rural area because the location accuracy was already high without the Location module, the module successfully decreased the location error by 72% in the urban area. Of course, an average error of 3.5m in the urban area is not negligible; yet, it can be compensated by increasing the size of the alert zone, i.e., by providing an alert message to the  user a bit early.

B. ENERGY EFFICIENCY
We evaluate the performance of the Energy module focusing on two key questions: (1) Is GPS reactivated timely, and (2) how much energy savings are achieved. To answer the first question, we measured the shortest geodetic distance between the pedestrian and the alert zone when GPS was reactivated by the Energy module. If the distance is small, it means that GPS is reactivated timely. This experiment was performed with both the actual walking speed and the brisk walking speed. The actual walking speed was measured by asking the participant to walk for 5mins. Fig. 15 shows the histogram of the actual walking speed. We then calculated the average walking speed and integrated it into the Energy module.
The pedestrian was asked to walk from 30 meters away from the alert zone toward the alert zone. We then measured the geodetic distance when GPS was reactivated. The results are shown in Fig. 15. The shortest geodetic distance between the pedestrian and the alert zone was about 1m when the average of the actual walking speed was used by the module. In contrast, when the module used the brisk walking speed, the shortest geodetic distance was about 4m. The results may seem that using the actual walking speed for estimating the time to reactive GPS is better. However, we note that reactivating GPS several seconds early actually would not affect much the energy efficiency, and in fact, it could improve the safety of the pedestrian since other system components are activated several seconds early to allow for more time for the pedestrian to respond to the alert message. Assuming the brisk walking speed, we evaluated energy savings resulting from the Energy module.
We then performed experiments to understand how much energy savings can be achieved. In this experiment, we used the brisk walking speed. Specifically, we created 8 alert zones along a 850m sidewalk and asked the pedestrian to walk along the sidewalk repeating 5 times (Fig. 16). In this experiment, only the Location module was turned on to provide the calibrated location information. We then measured energy consumption with and without the Energy module. The results are depicted in Fig. 17 demonstrating that Location module decreased energy consumption by 50.2%.

C. CONTEXT DETECTION ACCURACY
We measured the accuracy of detecting the phone viewing event. The accuracy is defined as the sum of true positives and true negatives divided by the total number of event detection. In this experiment, 7 volunteers participated. They were asked to walk with and without viewing their phones for 10mins each to collect the training data.
The size of the sliding window is determined before measuring the accuracy. We should choose the sliding window size that makes clear distinction between the phone viewing and non-phone viewing events. To quantify how well the two events are differentiated, a new metric ∆ = ∆ values are preferred because it will lead to higher event detection accuracy due to the fact that the two events are more clearly differentiated. However, note that higher accuracy does not necessarily mean higher ∆ values because the phone-viewing event will be detected even if the difference between the MAD values of the two events is small, which is the reason why this new metric is defined to determine the window size.
To decide an appropriate window size, we measured ∆ by varying the window size. Fig. 18 shows the results which indicate that using a larger window distinguishes the two events better because of more samples contained in the window. A downside of using a large window size is, however, the increased delay to fill up the window with samples. An interesting observation is that even if we use a small window, ∆ does not decrease too much. For example, ∆ for the window size of 3sec is only 12% smaller than that for the window size of 60sec. In this experiment, we decided to use the window size of 3sec.
With the window size, we measured the event detection accuracy. This time the volunteers were asked to walk with and without viewing their phones for another 5 mins. Fig. 18 shows the results. The accuracy was varied depending on the individual as each participant had a different walking style. However, it can be noted that the accuracy for all participants was greater than 90%, validating that the Context module effectively detects the phone viewing event.

D. INTEGRATED TEST
We perform an integrated test to evaluate the performance of SaferCross as a whole by putting together all the individual modules. We use the user warning time t warning as a main metric for performance evaluation based on the observation that accurate t warning can only be obtained if all system modules perform effectively. Specifically, in this experiment, t c and t p were recorded to calculate the user warning time, i.e., |t c −t p |. However, measured t warning may be different from the ground-truth time to collision denoted by t GT warning due to various factors such as the positioning error (for both the car and the pedestrian), processing delay, and transmission delay for delivering the warning message to the driver. We focus on capturing the difference, i.e., |t warning − t GT warning in evaluating the overall system performance.
In this experiment, a participant was asked to walk toward the crossing while viewing his smartphone. At the same time, a driver was asked to drive a car toward the crossing. t warning was measured for different vehicle speeds. For each vehicle speed, we repeated measurement of t warning five times and obtained the average value of t warning . At the same time, the locations where an alert message was actually sent (pedestrian) and received (driver) were recorded based on an LED indicator and a camera to calculate t GT warning . Fig. 19 shows the ground-truth distance to the crossing when the vehicle received an alert message, which varies due to the nondeterministic nature of the user walking speed, GPS locations, and message delay. The results indicate that when the vehicle speed was high, the vehicle was closer to the crossing when the alert message was generated, leading to the small user warning time and greater collision probability. We compared the measured user warning time calculated based on t c and t p with the ground truth user warning time. The difference was between 0sec and 3sec, and the average difference was 1.6sec. Although the max difference of 3sec is a non-negligible amount of time considering the fast moving vehicle, it can be compensated by configuring the system to fire an alert message several seconds early.

V. CONCLUSION
We have presented SaferCross, a first fully functioning prototype mobile system for preventing distracted phone use. We develop critical system components for mobile systems for pedestrian safety focusing on the positioning accuracy, energy efficiency, activity detection, and effective risk assessment, laying the foundation for future research and development of mobile systems for pedestrian safety. We demonstrated that SaferCross effectively performs risk assessment of pedestrian safety via systematic integration of various software components for pedestrian positioning, phone use activity detection, energy efficiency, and car-to-pedestrian communication. We expect that the technical contributions made in this paper will be useful assets for various other transportation research involving pedestrians. A potential extension of this work is to enhance the pedestrian positioning accuracy as well as the proposed energy efficiency algorithm utilizing the recently arising 5G network [40]. Another interesting future direction is to understand how pedestrians and drivers respond to a warning sent by the proposed system, which is an important research problem as noted by a recent research [41] that pedestrians tend to reduce their attention when receiving a warning, and they sometimes do not respond to a warning once they initiated a crossing.