Detection of Indoor High-Density Crowds via Wi-Fi Tracking Data

Accurate detection of locations of indoor high-density crowds is crucial for early warning and emergency rescue during indoor safety accidents. The spatial structure of indoor environments is more complicated than outdoor environments. The locations of indoor high-density crowds are more likely to be the sites of security accidents. Existing detection methods for high-density crowd locations mostly focus on outdoor environments, and relatively few detection methods exist for indoor environments. This study proposes a novel detection framework for high-density indoor crowd locations termed IndoorSRC (Simplification–Reconstruction–Cluster). In this paper, a novel indoor spatiotemporal clustering algorithm called Indoor-STAGNES is proposed to detect the indoor trajectory stay points to simplify indoor movement trajectory. Then, we propose use of a Kalman filter algorithm to reconstruct the indoor trajectory and properly align and resample the data. Finally, an indoor spatiotemporal density clustering algorithm called Indoor-STOPTICS is proposed to detect the locations of high-density crowds in the indoor environment from the reconstructed trajectory. Extensive experiments were conducted using indoor Wi-Fi positioning datasets collected from a shopping mall. The results show that the IndoorSRC framework evidently outperforms the existing baseline method in terms of detection performance.


Introduction
Indoor environments are the main space for human activities, with research showing that human activities occur indoors approximately 87% of the time [1]. As a result, many indoor spaces host large numbers of people at any point in time. High-density crowds are the primary cause of indoor emergency safety accidents, such as overcrowding and trampling [2,3]. Compared with the outdoor environment, indoor three-dimensional spatial structures are more complicated, and safety accidents are more likely to occur there. Therefore, accurately detecting the locations of these high-density indoor crowds is important for early warning and emergency rescues during instances of indoor safety accidents.
With the rapid development of the Internet, indoor positioning has gradually become a rigid demand [4][5][6]. In recent years, indoor positioning technology has gradually matured and has been applied in our daily life, such as for indoor navigation and indoor location tracking. Concurrently, the available indoor positioning data of indoor users have grown severalfold, becoming a substantial data source for indoor-related research, such as indoor location prediction [7][8][9], indoor association rule mining [10], and indoor positioning methods [11][12][13]. Existing indoor-related research is mainly focused on indoor location services, and there are few studies related to detecting high-density indoor crowd locations. At present, studies related to high-density crowd detection are mainly focused on the outdoor environment. Compared with outdoor trajectories, indoor trajectories are of poor quality and have typical three-dimensional characteristics, which makes it difficult for traditional outdoor high-density crowd detection algorithms to be applied to indoor spaces.
Therefore, a novel high-density location-detection framework for indoor crowds called IndoorSRC (Simplification-Reconstruction-Cluster) is proposed herein. This study uses clustering algorithms to find high-density locations of indoor crowds, thereby providing a scientific basis for indoor emergencies. Based on the characteristics of indoor trajectories, we have made certain improvements to the existing clustering algorithms. The significant contributions of the study are summarized as follows.
(1) A novel indoor spatiotemporal aggregation hierarchical clustering algorithm called Indoor-STAGNES is proposed for detecting the stay points of indoor trajectory and for simplifying indoor movement trajectory. (2) The Kalman filter algorithm is proposed to reconstruct the indoor trajectory, thereby achieving the required alignment and resampling. (3) A new indoor spatiotemporal density clustering algorithm called Indoor-STOPTICS is proposed for detecting the location of high-density crowds in the indoor environment from the reconstructed trajectory. (4) Subsequently, we describe our evaluation of the performance of the IndoorSRC framework using real indoor trajectories. The results demonstrate the advantages of our approach compared to the baseline.
The rest of this paper is organized as follows. In Section 2, a review of the literature focusing on indoor trajectories and detection of high-density locations in outdoor environments is presented. The basic and problem definitions along with a new methodological framework for detecting high-density locations of indoor crowds are described in Section 3. The performances of the frameworks proposed in previous research and this study are compared based on real indoor Wi-Fi positioning data and are presented in Section 4 along with the results. Section 5 provides the conclusion of the study and suggestions for possible further studies are presented.

Related Work
In this section, we first review the research related to indoor trajectories and, then, review the detection methods for high-density crowd locations in outdoor environments.
Existing research related to indoor trajectories is mainly focused on indoor positioning technology and indoor location services. Indoor positioning technology is used to improve the accuracy of indoor positioning to obtain more accurate indoor movement trajectories. For example, Ye et al. [14] used a hidden Markov model to improve the accuracy of indoor positioning based on traditional fingerprint positioning. Tomazic et al. [15] proposed a confidence interval fuzzy-logic model to improve the accuracy of indoor pedestrian positioning. Indoor location services primarily improve the indoor user experience from multiple perspectives. For instance, Wang et al. [16,17] proposed the Indoor-WhereNext and Markov-LSTM models from the perspectives of group users and individual users based on indoor trajectories of a mall to predict the next location of indoor users and achieved high prediction performance. Li et al. [18] used uncertain historical indoor mobility data to determine the top-k popular indoor semantic locations with the highest flow values. Mou et al. [10] proposed an R-FP-Growth algorithm based on the traditional FP-Growth algorithm to mine association rules among shops in shopping malls, thereby providing indoor location services. Liu el at. [19] designed a graph structure (IT-Graph) that captures indoor temporal variations to return the valid shortest path. Baba et at. [20] proposed the Indoor RFID Multi-variate Hidden Markov Model (IR-MHMM) to capture the uncertainties in indoor RFID data as well as the correlation between moving object locations and object RFID readings. In addition, several scholars have tried to determine high-density crowd locations from indoor trajectories. For example, Li et al. [21] proposed a data-driven approach that finds the top-k indoor density regions using indoor positioning data; however, there are only a few high-density indoor crowd detection methods, making this an ongoing problem in the field.
Detection methods for high-density crowds in outdoor environments are mainly used to find urban hotspots and alleviate traffic congestion. Identifying urban hotspots can reveal the travel characteristics of urban residents. For example, Zheng et al. [22] proposed a grid-based clustering algorithm based on taxi-trajectory data to find popular travel areas and, thus, analyzed the travel patterns of Chongqing residents. Lu et al. [23] presented a visual analysis system to explore the Origin-Destination patterns of hotspots to reveal the potential functions of urban regions. Zhao et al. [24] proposed a trajectory clustering method based on decision graphing and data fields to determine the dynamic pattern of urban hotspots. Easing traffic congestion mainly provides support for urban traffic planning and management. For instance, Li et al. [25] proposed a density-based clustering algorithm called FlowScan to identify high-density traffic locations at road-level to alleviate traffic congestion. Anbaroglu et al. [26] proposed a Non-Recurrent Congestion (NRC) events detection methodology to support the accurate detection of NRC events on large urban road networks. Cheng et al. [27,28] used a data-driven approach to predict changes in traffic flow to alleviate traffic congestion. However, the abovementioned methods mainly focus on high-density crowd detection in outdoor environments. Due to the low quality and three-dimensional characteristics of indoor trajectories, it is difficult to apply these methods directly to indoor environments.
In this study, we propose a novel high-density indoor crowd location detection framework, termed IndoorSRC. Compared with existing methods, the proposed framework is suitable for indoor spaces. It is a lightweight framework that is not only easy to implement but also combines the advantages of multiple clustering algorithms to improve detection performance.

Materials and Methods
First, it is necessary to define the terms utilized herein and identify the problems to be addressed.

Definition 1 (Indoor Trajectory
). An indoor trajectory, tra j = pt i n i = 1 , is an ordered sequence of points for pt i = (id, t i , x i , y i , f i ), where n is the length of the trajectory, id is the length of the trajectory, t i is a unique user identifier, is the time that pt i was collected, and (x i , y i , f i ) corresponds to the longitude, latitude, and floor, respectively, of the user at time t i .

Definition 2 (Simplified Trajectory).
A simplified trajectory, sim_tra j = sim_pt i k i = 1 , simplifies the trajectory points caused by the stay event in the indoor trajectory. As shown in Figure 1b, sim_pt i = (id, sim_t i , sim_x i , sim_y i , f i ) is obtained by simplifying the points that are continuous in time and close to each other, where sim_t i is the average time of the simplified points, (sim_x i , sim_y i ) is the center coordinate of the simplified points, and f i is the floor on which the user is located.
Sensors 2020, 20, x FOR PEER REVIEW 3 of 15 valid shortest path. Baba el at. [20] proposed the Indoor RFID Multi-variate Hidden Markov Model (IR-MHMM) to capture the uncertainties in indoor RFID data as well as the correlation between moving object locations and object RFID readings. In addition, several scholars have tried to determine high-density crowd locations from indoor trajectories. For example, Li et al. [21] proposed a data-driven approach that finds the top-k indoor density regions using indoor positioning data; however, there are only a few high-density indoor crowd detection methods, making this an ongoing problem in the field. Detection methods for high-density crowds in outdoor environments are mainly used to find urban hotspots and alleviate traffic congestion. Identifying urban hotspots can reveal the travel characteristics of urban residents. For example, Zheng et al. [22] proposed a grid-based clustering algorithm based on taxi-trajectory data to find popular travel areas and, thus, analyzed the travel patterns of Chongqing residents. Lu et al. [23] presented a visual analysis system to explore the Origin-Destination patterns of hotspots to reveal the potential functions of urban regions. Zhao et al. [24] proposed a trajectory clustering method based on decision graphing and data fields to determine the dynamic pattern of urban hotspots. Easing traffic congestion mainly provides support for urban traffic planning and management. For instance, Li et al. [25] proposed a density-based clustering algorithm called FlowScan to identify high-density traffic locations at road-level to alleviate traffic congestion. Anbaroglu et al. [26] proposed a Non-Recurrent Congestion (NRC) events detection methodology to support the accurate detection of NRC events on large urban road networks. Cheng et al. [27,28] used a data-driven approach to predict changes in traffic flow to alleviate traffic congestion. However, the abovementioned methods mainly focus on high-density crowd detection in outdoor environments. Due to the low quality and three-dimensional characteristics of indoor trajectories, it is difficult to apply these methods directly to indoor environments.
In this study, we propose a novel high-density indoor crowd location detection framework, termed IndoorSRC. Compared with existing methods, the proposed framework is suitable for indoor spaces. It is a lightweight framework that is not only easy to implement but also combines the advantages of multiple clustering algorithms to improve detection performance.

Materials and Methods
First, it is necessary to define the terms utilized herein and identify the problems to be addressed.

Definition 3 (Reconstructed Trajectory).
A reconstructed trajectory, rec_tra j = rec_pt i l i = 1 = id, t i ,x i ,ŷ i , f i l i , reconstructs the missing data in the simplified trajectory. As shown in Figure 1c, t i is the recording time of the reconstructed point rec_pt i , (x,ŷ) is the coordinate information of the user at time t i , and f i is the floor on which the user is located. The research object of this study is the trajectories tra j i N i = 1 of the group users in the indoor environment. From the trajectories of the group users, the high-density locations of the crowds in the indoor environment are found, thereby assisting in early warning and emergency rescue during indoor safety accidents. The problem defined in this study is expressed by Equation (1): where tra j i N i = 1 represents the group user trajectory for modeling, N represents the total number of users, M represents the IndoorSRC framework proposed in this study, which is used to detect high-density crowds in the trajectories of group users, and {l i } m i = 1 represents the high-density locations detected by framework M.
The IndoorSRC structure is presented in Figure 2. Based on the bottom-up design principle, our method is divided into three phases: simplification of the indoor movement trajectory; reconstruction of the indoor movement trajectory; and detection of high-density indoor crowd locations. First, a new indoor spatiotemporal agglomeration nesting called Indoor-STAGNES is proposed, which is used to identify the stay point in the indoor trajectory and simplify the indoor movement trajectory. Second, we propose using a Kalman filter algorithm [29,30] to reconstruct the simplified trajectory to align and resample the indoor movement trajectory. Finally, an indoor spatiotemporal density clustering algorithm called Indoor-STOPTICS is proposed to detect the locations of high-density crowds in the indoor environment from the reconstructed trajectory point set. The research object of this study is the trajectories { } = 1 of the group users in the indoor environment. From the trajectories of the group users, the high-density locations of the crowds in the indoor environment are found, thereby assisting in early warning and emergency rescue during indoor safety accidents. The problem defined in this study is expressed by Equation (1): where { } = 1 represents the group user trajectory for modeling, represents the total number of users, ℳ represents the IndoorSRC framework proposed in this study, which is used to detect high-density crowds in the trajectories of group users, and { } = 1 represents the high-density locations detected by framework ℳ.
The IndoorSRC structure is presented in Figure 2. Based on the bottom-up design principle, our method is divided into three phases: simplification of the indoor movement trajectory; reconstruction of the indoor movement trajectory; and detection of high-density indoor crowd locations. First, a new indoor spatiotemporal agglomeration nesting called Indoor-STAGNES is proposed, which is used to identify the stay point in the indoor trajectory and simplify the indoor movement trajectory. Second, we propose using a Kalman filter algorithm [29,30] to reconstruct the simplified trajectory to align and resample the indoor movement trajectory. Finally, an indoor spatiotemporal density clustering algorithm called Indoor-STOPTICS is proposed to detect the locations of high-density crowds in the indoor environment from the reconstructed trajectory point set.

Simplification of the Indoor Movement Trajectory
The sampling interval of indoor positioning data is heterogeneous; when a user stays in a specific area for a certain period, the mobile terminal will record more trajectory points in the limited area, thereby forming a cluster of trajectory points. If the original trajectory tra j is used to directly identify the high-density crowd locations, the high-density point locations are often obtained rather than the crowd locations. Therefore, we propose a novel Indoor-STAGNES algorithm to simplify the user trajectory and remove the stay point information from the trajectory.
The Indoor-STAGNES algorithm is an improvement over the traditional agglomerative nesting (AGNES) algorithm. Two major improvements have been made-the addition of time and floor constraints and, consequently, the adjacent spatiotemporal trajectory points (clusters) on the same floor are merged by iteration. Finally, the original tra j = pt i The sim_pt i is obtained by simplifying the points in cluster C i , and k simplified trajectory points are obtained from k clusters, i.e., sim_tra j = sim_pt i k i = 1 . As shown in Figure 3, the cluster C i (pt 1 , pt 2 , pt 3 , pt 4 ) is iterated into a new cluster and, then, simplified into a trajectory point sim_pt i . The calculation methods of the time distance and spatial distance between clusters are shown in Equations (2) and (3): where spatial_dist is used to calculate the spatial distance between C i and C j , time_dist is used to calculate the time distance between C i and C j , pt i represents the mean coordinate of cluster C i , the number of points in C i is represented by |C i |, and C i .time ave represents the average recording time of the trajectory points in cluster C i .

Simplification of the Indoor Movement Trajectory
The sampling interval of indoor positioning data is heterogeneous; when a user stays in a specific area for a certain period, the mobile terminal will record more trajectory points in the limited area, thereby forming a cluster of trajectory points. If the original trajectory is used to directly identify the high-density crowd locations, the high-density point locations are often obtained rather than the crowd locations. Therefore, we propose a novel Indoor-STAGNES algorithm to simplify the user trajectory and remove the stay point information from the trajectory.
The Indoor-STAGNES algorithm is an improvement over the traditional agglomerative nesting (AGNES) algorithm. Two major improvements have been made-the addition of time and floor constraints and, consequently, the adjacent spatiotemporal trajectory points (clusters) on the same floor are merged by iteration. Finally, the original is obtained by simplifying the points in cluster , and simplified trajectory points are obtained from clusters, i.e., _ = { _ } = 1 . As shown in Figure 3, the cluster ( 1 , 2 , 3 , 4 ) is iterated into a new cluster and, then, simplified into a trajectory point _ . The calculation methods of the time distance and spatial distance between clusters are shown in Equations (2) and (3): where _ is used to calculate the spatial distance between and , _ is used to calculate the time distance between and , ̅̅̅̅ represents the mean coordinate of cluster , the number of points in is represented by | |, and . represents the average recording time of the trajectory points in cluster . The overall process of Indoor-STAGNES is shown in Algorithm 1.
(1) The indoor trajectory = { } = 1 of the continuous time is input and each trajectory point is initialized as a cluster.
(2) The spatial distance matrix and the time distance matrix between the clusters are initialized, where represents the spatial distance between and , and represents the time distance between and . If and are not on the same floor, and are infinity.
(3) The minimum value in the distance matrix under the time threshold ℎ ℎ is examined. If is smaller than the distance threshold ℎ ℎ , the two nearest clusters are merged, and the spatial distance matrix and the time distance matrix are updated. Otherwise, step 4 is followed. The overall process of Indoor-STAGNES is shown in Algorithm 1.
(1) The indoor trajectory tra j = pt i n i = 1 of the continuous time is input and each trajectory point is initialized as a cluster.
(2) The spatial distance matrix SD and the time distance matrix TD between the clusters are initialized, where SD ij represents the spatial distance between C i and C j , and TD ij represents the time distance between C i and C j . If C i and C j are not on the same floor, SD ij and TD ij are infinity. (3) The minimum value d min in the distance matrix SD under the time threshold t threh is examined.
If d min is smaller than the distance threshold d threh , the two nearest clusters are merged, and the spatial distance matrix SD and the time distance matrix TD are updated. Otherwise, step 4 is followed.

Reconstruction of the Indoor Movement Trajectory
The simplified trajectory sim_tra j generally reflects the user mobile skeleton; however, it is not suitable for detecting high-density indoor crowd locations. The simplified trajectory sim_tra j contains more missing trajectory points. If the simplified trajectory sim_tra j is directly used to detect the desired location, the detection performance will be affected to some extent. Therefore, indoor trajectory reconstruction is one of the key steps involved in this process. To complete the missing trajectory points in the simplified trajectory, we proposing using a Kalman filter algorithm to reconstruct the simplified trajectory.
Kalman filtering is a linear optimal estimation algorithm that comprehensively considers measurement data and physical motion models and iteratively estimates the optimal location of a user at each moment, that is, the reconstructed trajectory point rec_pt. The Kalman filtering algorithm reconstructs the indoor movement trajectory in two main stages: (1) Identification of the missing trajectory points: The number of missing trajectory points in the simplified trajectory are determined according to the sampling interval of the simplified trajectory. As shown in Figure 4, the trajectory interval with a sampling interval that exceeds twice the average sampling interval in the simplified trajectory is regarded as the missing trajectory interval. When the sampling interval of the missing trajectory interval is less than the 95th percentile of the sampling interval, the missing trajectory points need to be reconstructed. The calculation method of the number and time information of the missing trajectory points are shown in Equations (4) and (5): where missing_interval represents the sampling interval of the missing trajectory interval, ave_interval represents the average sampling interval of the simplified trajectory points, f loor(x) represents the downward rounding function, count represents the number of missing trajectory points, and rec_pt i + j .t represents the time information of the j-th missing trajectory point in the missing trajectory interval (for example, rec_pt i + 1 .t represents the time information of the first missing trajectory point in the missing trajectory interval).
(2) Reconstruction of the missing trajectory points: The Kalman filtering algorithm iteratively solves the location of the reconstructed trajectory point at each moment, which is mainly divided into two stages: the location prediction and location update stages. In the location prediction stage, the physical motion model is used to predict the location of the next moment according to the optimal location of the previous moment. In the location update stage, the optimal location of the current moment is obtained by correcting the predicted location of the current moment using measurement data and error of the current moment. The iterative process is shown in Equations (6) and (7): where kalManFilter represents the Kalman filter algorithm, (rec_pt i .x, rec_pt i .ŷ) represents the coordinates of the reconstructed trajectory point at the current moment, (rec_pt i−1 .x, rec_pt i − 1 .ŷ) represents the coordinates of the reconstructed trajectory point at the previous moment, and (sim_pt i .x, sim_pt i .y) represents the coordinates of the simplified trajectory point at the current moment.  (2) Reconstruction of the missing trajectory points: The Kalman filtering algorithm iteratively solves the location of the reconstructed trajectory point at each moment, which is mainly divided into two stages: the location prediction and location update stages. In the location prediction stage, the physical motion model is used to predict the location of the next moment according to the optimal location of the previous moment. In the location update stage, the optimal location of the current moment is obtained by correcting the predicted location of the current moment using measurement data and error of the current moment. The iterative process is shown in Equations (6) and (7): where represents the Kalman filter algorithm, ( _ .̂, _ .̂) represents the coordinates of the reconstructed trajectory point at the current moment, ( _ −1 .̂, _ − 1 .̂) represents the coordinates of the reconstructed trajectory point at the previous moment, and ( _ . , _ . ) represents the coordinates of the simplified trajectory point at the current moment.

Detection of High-density Indoor Crowd Locations
The reconstructed trajectory point _ can accurately reflect the movement of a user's location. By combining all the reconstructed trajectory points of all users, we can analyze the changes in the indoor group user's location, thereby detecting the locations of high-density indoor crowds. We regard the high-density clusters in the reconstructed trajectory point set (Definition 4) as these locations. Therefore, we proposed a novel indoor spatiotemporal ordering point to identify the cluster structure (Indoor-STOPTICS).

Definition 5 (Indoor Spatiotemporal Neighborhood). For
_ ∈ , the indoor spatiotemporal neighborhood of its indoor space is defined as a cylinder, with 1 as its radius and 2 as its time window;

Detection of High-Density Indoor Crowd Locations
The reconstructed trajectory point rec_pt can accurately reflect the movement of a user's location. By combining all the reconstructed trajectory points of all users, we can analyze the changes in the indoor group user's location, thereby detecting the locations of high-density indoor crowds. We regard the high-density clusters in the reconstructed trajectory point set DB (Definition 4) as these locations. Therefore, we proposed a novel indoor spatiotemporal ordering point to identify the cluster structure (Indoor-STOPTICS).

Definition 5 (Indoor Spatiotemporal Neighborhood).
For rec_pt i ∈ DB, the indoor spatiotemporal neighborhood of its indoor space is defined as a cylinder, with 1 as 2 its radius and as its time window; rec_pt i is the center of the cylinder, N 1 , 2 (pt i ) represents a subset of points contained inside the cylinder, and the points in N 1 , 2 (pt i ) are on the same floor as pt i , as defined in Equation (8): where sd is used to calculate the spatial distance between rec_pt i and rec_pt j , td is used to calculate the time distance between rec_pt i and rec_pt j , and the number of points in N 1 , 2 (rec_pt i ) is represented by N 1 , 2 (rec_pt i ) .

Definition 6 (Indoor Core Trajectory Point).
For rec_pt i ∈ DB, if its indoor spatiotemporal neighborhood N 1 , 2 (rec_pt i ) contains at least Minpt indoor trajectory points, that is, N 1 , 2 (rec_pt i )| > Minpt , then, rec_pt i is called the indoor core trajectory point. Indoor-STOPTICS is an improved algorithm of spatiotemporal ordering points to identify the clustering structure [31,32]. Indoor-STOPTICS first considers the three-dimensional characteristics of indoor trajectories and adds the floor constraint based on ST-OPTICS (Definition 5). Then, it uses core points (Definition 6) as drivers to determine the set of trajectory points connected with the maximum density of the same floor under spatiotemporal constraints. Unlike traditional density-based spatiotemporal clustering algorithms, the Indoor-STOPTICS algorithm does not explicitly generate clusters, but generates a reachable distance for each data point and an ordered list for analysis to assist in detecting high-density crowd locations in the DB. The calculation method for the reachable distance of each point and the ordered list is the same as in ST-OPTICS [31,32]. As shown in Figure 5, the reconstructed trajectory point set DB = rec_pt i M i = 1 generates an ordered point list orderList = rec_pt j M j = 1 using the Indoor-STOPTICS algorithm. Taking orderList index j as the horizontal axis and rec_pt j reachable distance as the vertical axis, a decision graph of DB can be obtained. The auxiliary information of the decision graph can be summarized as follows.
(1) When the spatial radius of the Indoor-STOPTICS algorithm is 1 = r 1 , two clusters, ClusterA and ClusterB, can be detected from the set DB.
(2) When the spatial radius of the Indoor-STOPTICS algorithm is 1 = r 2 , ClusterA is split into three small clusters, namely ClusterA1, ClusterA2, and ClusterA3. Thus, a total of four clusters can be identified from the set DB. (3) When the spatial radius of the Indoor-STOPTICS algorithm is 1 = r 2 , the trajectory points included in each cluster can be obtained by the corresponding horizontal axis index sequence. For example, the horizontal axis index sequence corresponding to ClusterA1 is idxArr and the trajectory points included in ClusterA1 can be expressed as orderList[i] i∈idxArr . (4) When the spatial radius of the Indoor-STOPTICS algorithm is 1 = r 2 , the cluster density can be approximated by the width of the cluster. For example, the density of ClusterB can be represented by w. When w is wider, the density of the cluster is greater.
Sensors 2020, 20, x FOR PEER REVIEW 8 of 15 Indoor-STOPTICS is an improved algorithm of spatiotemporal ordering points to identify the clustering structure [31,32]. Indoor-STOPTICS first considers the three-dimensional characteristics of indoor trajectories and adds the floor constraint based on ST-OPTICS (Definition 5). Then, it uses core points (Definition 6) as drivers to determine the set of trajectory points connected with the maximum density of the same floor under spatiotemporal constraints. Unlike traditional density-based spatiotemporal clustering algorithms, the Indoor-STOPTICS algorithm does not explicitly generate clusters, but generates a reachable distance for each data point and an ordered list for analysis to assist in detecting high-density crowd locations in the . The calculation method for the reachable distance of each point and the ordered list is the same as in ST-OPTICS [31,32]. As shown in Figure  5  (1) When the spatial radius of the Indoor-STOPTICS algorithm is ϵ 1 = 1 , two clusters, and , can be detected from the set .
(2) When the spatial radius of the Indoor-STOPTICS algorithm is ϵ 1 = 2 , is split into three small clusters, namely 1, 2, and 3. Thus, a total of four clusters can be identified from the set . (3) When the spatial radius of the Indoor-STOPTICS algorithm is ϵ 1 = 2 , the trajectory points included in each cluster can be obtained by the corresponding horizontal axis index sequence. For example, the horizontal axis index sequence corresponding to 1 is and the trajectory points included in 1 can be expressed as { [ ]} ∈ . (4) When the spatial radius of the Indoor-STOPTICS algorithm is ϵ 1 = 2 , the cluster density can be approximated by the width of the cluster. For example, the density of can be represented by . When is wider, the density of the cluster is greater.  indoor trajectory points were collected every day. The positioning accuracy was approximately 3 m, and trajectory points with a sampling interval of 1-5 s accounted for more than 70% of the collected data points. Table 1 lists the unique identifier of the user, record upload time, the user's (X, Y) coordinates, and the unique floor identifier.

Data Preprocessing
The original Wi-Fi data were collected via fingerprint positioning technology. First, multiple Wi-Fi access points (APs) were deployed in the study area and, then, the coordinate information of each AP was calculated iteratively. After the determination of coordinate information of each AP, the research area was divided into multiple grids that do not overlap; then, fingerprint information from each grid was obtained to construct a fingerprint database. When a mobile terminal enters the coverage area of APs, the mobile terminal matches the signal strength of received AP with the fingerprint database to determine the specific location of the terminal. Because of the unstable signal of the mobile terminal and the artificial shutdown of the Wi-Fi signal, it was easy to generate abnormal, erroneous, and invalid data. There were three types of noise in our dataset: (1) The coordinate abnormal point. If the trajectory point fell outside the study area, it was regarded as a coordinate abnormal trajectory point.

Evaluation Metrics
In this study, we regarded the clusters in the reconstructed trajectory point set DB as the high-density indoor crowd locations and used crowd density (CD), point density (PD), and running time as the quantitative evaluation indexes of the IndoorSRC framework. The CD and PD can be defined by Equations (9) and (10), respectively: where m represents the number of clusters detected by the IndoorSRC framework, V i represents the volume of a certain cluster (i.e., the convex hull volume of the three-dimensional point set), CrowdNum i represents the number of users in a cluster, PointNum i represents the number of trajectory points in a cluster, and ∆t represents the time step.

Variable Estimation
The hyperparameters of the IndoorSRC framework primarily included parameters in the Indoor-STAGNES and Indoor-STOPTICS algorithms. The Indoor-STAGNES algorithm has two auxiliary functions. First, it simplifies the user trajectory and reduces the number of trajectory points, thereby reducing the running time of the Indoor-STOPTICS algorithm. Second, it ensures that a single user contains only one trajectory point in a particular spatiotemporal neighborhood. Thus, the detection performance of the IndoorSRC framework predominantly depends on the Indoor-STOPTICS algorithm. Hence, we set the distance threshold d threh and the time threshold t threh to fixed values in the Indoor-STAGNES algorithm, wherein the distance threshold d threh was fixed to 5 m with reference to the average distance between indoor shops and the time threshold t threh was fixed to 4 min.
The hyperparameters of Indoor-STOPTICS mainly include the radius 1 , time window 2 , and minimum number of points MinPts. In the Indoor-STDBSCAN algorithm, the main test time window 2 influences the detection performance. To determine the parameters in Indoor-STOPTICS, the control variable method was used to obtain the combination of parameter values and the best detection performance. In the parameter estimation phase, the radius 1 was set to infinity for generating the decision graph, time window 2 was the best parameter found in [1 min, 2 min, 3 min, . . . , 10 min], and minimum number of MinPts was set to 5 × ln(M) [33], where M represents the number of points in the set DB. Figure 6 shows the effect of the time window 2 on detection performance. The crowd density first increased and then decreased, whereas the point density first increased and then stabilized. This is due to the fact that when the time window 2 is greater than the time threshold t threh in the Indoor-STAGNES algorithm, the probability of including multiple points of a user in the neighborhood (Definition 5) is higher in the Indoor-STOPTICS algorithm. This, therefore, leads to a decrease in the crowd density; the two auxiliary functions of the Indoor-AGNES algorithm is also confirmed, to a certain extent. In this study, we eventually fix the time window 2 to 5 min.
volume of a certain cluster (i.e., the convex hull volume of the three-dimensional point set), CrowdNum represents the number of users in a cluster, PointNum represents the number of trajectory points in a cluster, and represents the time step.

Variable Estimation
The hyperparameters of the IndoorSRC framework primarily included parameters in the Indoor-STAGNES and Indoor-STOPTICS algorithms. The Indoor-STAGNES algorithm has two auxiliary functions. First, it simplifies the user trajectory and reduces the number of trajectory points, thereby reducing the running time of the Indoor-STOPTICS algorithm. Second, it ensures that a single user contains only one trajectory point in a particular spatiotemporal neighborhood. Thus, the detection performance of the IndoorSRC framework predominantly depends on the Indoor-STOPTICS algorithm. Hence, we set the distance threshold ℎ ℎ and the time threshold ℎ ℎ to fixed values in the Indoor-STAGNES algorithm, wherein the distance threshold ℎ ℎ was fixed to 5 m with reference to the average distance between indoor shops and the time threshold ℎ ℎ was fixed to 4 min.
The hyperparameters of Indoor-STOPTICS mainly include the radius 1 , time window 2 , and minimum number of points . In the Indoor-STDBSCAN algorithm, the main test time window 2 influences the detection performance. To determine the parameters in Indoor-STOPTICS, the control variable method was used to obtain the combination of parameter values and the best detection performance. In the parameter estimation phase, the radius 1 was set to infinity for generating the decision graph, time window 2 was the best parameter found in [1 , 2 , 3 , … ,10 ], and minimum number of was set to 5 × ln ( ) [33], where represents the number of points in the set . Figure 6 shows the effect of the time window 2 on detection performance. The crowd density first increased and then decreased, whereas the point density first increased and then stabilized. This is due to the fact that when the time window 2 is greater than the time threshold ℎ ℎ in the Indoor-STAGNES algorithm, the probability of including multiple points of a user in the neighborhood (Definition 5) is higher in the Indoor-STOPTICS algorithm. This, therefore, leads to a decrease in the crowd density; the two auxiliary functions of the Indoor-AGNES algorithm is also confirmed, to a certain extent. In this study, we eventually fix the time window 2 to 5 min.

IndoorSRC Framework Performance
The IndoorSRC detection results on specific floors obtained after determining the optimal combination of parameters, using 11:00-16:00 as the research time, are presented graphically in Figure 7. The reconstructed trajectory point set DB shows an obvious aggregation pattern in different regions and at different times. After drawing the decision graph of the set DB, the spatial coordinates and time of the high-density crowd location can be detected. For example, when the distance threshold mall and three short-period-high-density crowd locations were formed there at noon. "Fisherman's lamp" and "Chinese Restaurant" are restaurants inside the shopping mall; long-period-high-density crowd locations were formed here. Figure 7. The reconstructed trajectory point set shows an obvious aggregation pattern in different regions and at different times. After drawing the decision graph of the set , the spatial coordinates and time of the high-density crowd location can be detected. For example, when the distance threshold 1 = 6 m, there will be eight clusters in the set ; upon further determining the width of each cluster, five high-density crowd locations will be obtained. Table 2 shows the spatial and temporal information of each high-density crowd location. These locations are mostly crowded at noon and are primarily located in the dining area. For example, "Food Shangjia" is part of the food court inside the shopping mall and three short-period-high-density crowd locations were formed there at noon. "Fisherman's lamp" and "Chinese Restaurant" are restaurants inside the shopping mall; long-period-high-density crowd locations were formed here.

Comparison with Baselines
To verify the performance of the proposed IndoorSRC framework, it was compared with the existing ST-OPTICS, and the experimental results were analyzed from the perspectives of CD, PD, and running time. Figure 8 shows the comparison results of the point and crowd densities with the baseline. From these perspectives, the crowd density detected by the IndoorSRC algorithm is much higher than that calculated by ST-OPTICS. This is because there is more stay-point information in the indoor movement trajectory. If ST-OPTICS is used to identify high-density crowd locations directly, the clusters obtained are mostly "high-density point locations" rather than "high-density crowd locations". The density of points detected by the IndoorSRC algorithm is slightly lower than that by ST-OPTICS as the IndoorSRC framework simplifies and reconstructs the indoor movement trajectory so that the adjacent trajectory points in the reconstructed trajectory are farther apart. This makes the trajectory points more sparse, resulting in a slight decrease in the point density. Therefore, the IndoorSRC framework is more suitable for detecting high-density indoor crowd locations. calculated by ST-OPTICS. This is because there is more stay-point information in the indoor movement trajectory. If ST-OPTICS is used to identify high-density crowd locations directly, the clusters obtained are mostly "high-density point locations" rather than "high-density crowd locations." The density of points detected by the IndoorSRC algorithm is slightly lower than that by ST-OPTICS as the IndoorSRC framework simplifies and reconstructs the indoor movement trajectory so that the adjacent trajectory points in the reconstructed trajectory are farther apart. This makes the trajectory points more sparse, resulting in a slight decrease in the point density. Therefore, the IndoorSRC framework is more suitable for detecting high-density indoor crowd locations.  Figure 9 shows the comparative results of the running time with the baseline approach. In this study, we compared the running time of the entire framework with baseline and not the running time of a simple single component, such as Indoor-STOPTICS or Indoor-STAGNES. From the perspective of the framework running time, when the number of users is small, the running time of the IndoorSRC framework is slightly higher than that of the ST-OPTICS algorithm, as the former simplifies and reconstructs the indoor movement trajectory, which increases the running time of the framework. As the number of users increases, the running time of the ST-OPTICS algorithm exceeds that of the IndoorSRC framework. This is because, when the number of trajectory points is very large, although the IndoorSRC framework simplifies and reconstructs the indoor movement trajectory, it greatly reduces the number of trajectory points, and the time consumed by simplification and reconstruction is far less than that consumed by direct detection.  Figure 9 shows the comparative results of the running time with the baseline approach. In this study, we compared the running time of the entire framework with baseline and not the running time of a simple single component, such as Indoor-STOPTICS or Indoor-STAGNES. From the perspective of the framework running time, when the number of users is small, the running time of the IndoorSRC framework is slightly higher than that of the ST-OPTICS algorithm, as the former simplifies and reconstructs the indoor movement trajectory, which increases the running time of the framework. As the number of users increases, the running time of the ST-OPTICS algorithm exceeds that of the IndoorSRC framework. This is because, when the number of trajectory points is very large, although the IndoorSRC framework simplifies and reconstructs the indoor movement trajectory, it greatly reduces the number of trajectory points, and the time consumed by simplification and reconstruction is far less than that consumed by direct detection.

Conclusions and Future Work
Accurate and robust detection of high-density indoor crowd locations is of great significance for early warning and emergency rescue during indoor safety accidents. Compared with the outdoor environment, the spatial structure of the indoor environment is more complicated, and tightly packed indoor crowds are more likely to cause security accidents. In this paper, the IndoorSRC framework is proposed to detect high-density indoor crowd locations. First, Indoor-STAGNES is proposed to detect the stay points of the indoor trajectory and simplify it. Then, the use of a Kalman filter algorithm to reconstruct the indoor trajectory is proposed. Finally, Indoor-STOPTICS is proposed to detect the location of high-density crowds in the indoor environment.
Experimentally, a two-week real indoor trajectory was used to verify the detection performance

Conclusions and Future Work
Accurate and robust detection of high-density indoor crowd locations is of great significance for early warning and emergency rescue during indoor safety accidents. Compared with the outdoor environment, the spatial structure of the indoor environment is more complicated, and tightly packed indoor crowds are more likely to cause security accidents. In this paper, the IndoorSRC framework is proposed to detect high-density indoor crowd locations. First, Indoor-STAGNES is proposed to detect the stay points of the indoor trajectory and simplify it. Then, the use of a Kalman filter algorithm to reconstruct the indoor trajectory is proposed. Finally, Indoor-STOPTICS is proposed to detect the location of high-density crowds in the indoor environment.
Experimentally, a two-week real indoor trajectory was used to verify the detection performance of the proposed framework. First, we used the control variable method to obtain the optimal parameter combination of the IndoorSRC framework. Afterward, we analyzed the predictive performance of the IndoorSRC framework using the dataset. Then, we conducted a comparison with the existing ST-OPTICS algorithm. Compared with the existing approach, the IndoorSRC framework considerably improved the detection performance in running time and crowd density, which demonstrates the efficiency of the IndoorSRC framework.
The following problems need to be investigated in the future. This study considered the high density of indoor crowds as the only necessary condition for indoor congestion, trampling, and other safety accidents; however, additionally, the direction of user movement can affect the occurrence of indoor safety accidents to a great extent. For example, when the crowd density is high and the users' walking directions are the same, accidents often do not occur. When the crowd density is high and the users' walking directions are disordered, there is more probability of an accident occurring. Therefore, future studies should introduce additional constraints, such as direction, to further improve the practicality of the IndoorSRC framework.