{'fraction_non_alphanumeric': 0.02819116077946875, 'fraction_numerical': 0.005166507553209412, 'mean_word_length': 4.813907933398629, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Capturing the Dynamics of Pedestrian Traffic Using a Machine Vision System

We developed a machine vision system to automatically capture the dynamics of pedestrians under four different traffic scenarios. By considering the overhead view of each pedestrian as a digital object, the system processes the image sequences to track the pedestrians. Considering the perspective effect of the camera lens and the projected area of the hallway at the top-view scene, the distance of each tracked object from its original position to its current position is approximated every video frame. Using the approximated distance and the video frame rate (30 frames per second), the respective velocity and acceleration of each tracked object are later derived. The quantified motion characteristics of the pedestrians are displayed by the system through 2-dimensional graphs of the kinematics of motion. The system also outputs video images of the pedestrians with superimposed markers for tracking. These visual markers were used to visually describe and quantify the behavior of the pedestrians under different traffic scenarios.


INTRODUCTION
Pedestrian traffic is the behavioral flow of people in an area or moving crowd. In any publicly-accessible area, variations of pedestrian traffic can always be observed. There are several places in these public areas where the sudden change in the behavior of huge groups of people can cause traffic jams, specifically along hallways and on crossroads. The measurement of the dynamics of pedestrian traffic is important in various applications and field of studies such as crowd control, stampede and accident control, public security, pedestrian flow organization, pedestrian safety, architectural design and safety, advertising, and marketing. For example, architects and transportation designers frequently use crowd dynamics in designing environments and buildings for the efficiency of pedestrian flow. During extreme conditions, such as stampedes, riots, and fire escapes, improved procedures on building designs could save many lives [11].
In obtaining data about the dynamics of pedestrian traffic, the usual procedure is to manually observe the various metrics associated with particle motion of a pedestrian by assigning several researchers on top of walkways over a period of time. This manual procedure is tedious, prone to error, and sometimes unreliable because of the human factors affecting the observers. During the start of the observation, the data gathered might be accurate because the human observers are still attentive. However, towards the later part of the observation, the data may become inaccurate due to the observers' boredom, eye stress, and tiredness. Thus, to replace the human observers, we created a computer vision system to mimic the observing capabilities of humans at a higher accuracy and consistency during the longest possible time. This study aims to effectively present the pedestrian behavior and characterize the motion of the crowd using the developed vision-based system. Several researchers have attempted to simulate the pedestrian traffic dynamics wherein models for crowd dynamics were developed [11]. Some of these models are the agentbased model of Reynolds [12], the social force model of Helbing and Molnar [9], the cellular automata model of Blue [3], and the gas-kinetic model of Helbing [6], but all of them used data gathered by human observers. To develop better models, data must be gathered by a system that is less prone to error due to human subjectivity and tiredness, and thus, a vision-based system needs to be developed. To develop our vision-based system, we utilized models, concepts, and techniques in image processing and computer vision. Our aim for the system is to detect and track pedestrians and at the same time measure and analyze the pedestrian's collective behavior under four different traffic scenarios. The system accepts as input the overhead view of the pedestrian traffic. To aid the system operator in real-time, color is used to track multiple pedestrians. The system, then, outputs several metrics and captures the dynamics of these metrics in 2-dimensional graphs of the kinematics of motion: distance vs. time, velocity vs. time, and acceleration vs. time.

RELATED LITERATURE 2.1 Recent Studies in Traffic Dynamics
Because of the importance of crowd dynamics on several real-world applications, several researchers attempted to quantify the collective dynamics of the pedestrians through developed simulations of motion. Helbing and Molnar [9], borrowing some ideas in gas-kinematic models, introduced the social force model to simulate pedestrian flows. In their model, a self-driven particle (i.e., a pedestrian) that interacts through social rules and regulations tries to move in its desired speed and direction while at the same time attempts not to collide with obstacles, other particles, and surrounding barriers. In order to reach its destination faster, pedestrians take detours even if the route is crowded [10]. The choice, however, is dependent on the recent memory of what the traffic was like the last time they took the route, which was found by other researcher to be polygonal in nature [4]. In agreement with the social force model, Weidmann [16] observed that, as long as it is not necessary to go faster, such as going down a ramp, a pedestrian prefers to walk with his or her desired speed, which corresponds to the most comfortable walking speed. However, Weidmann further observed that pedestrians keep a certain distance from other pedestrians and borders. The distance between the pedestrians decreases as the density of the crowd increases. The pedestrians themselves cause delays and obstructions. Arns [2] observed that the motion of the crowd is similar to the motion of gases and fluid, while Helbing, et al. [10] suggested that it is similar to granular flow as well.
Helbing [7], in his extension of the social force model, showed that many aspects of traffic flow can be reflected by selfdriven many-particle systems. In this system, he identified the various factors that govern the dynamics of the particles such as the specification of the desired velocities and directions of motion, the geometry of the boundary profiles, the heterogeneity among the particles, and the degree of fluctuations. One such observable pattern is the formation of lanes of uniform walking direction, formed because of the self-organization of the pedestrians [1]. Aside from the self-organizing behavior of the crowd, obstacles were also observed to both positively and negatively contribute to the flow of the traffic.
During escape panic of large crowds, several behavioral phenomena were observed [8]: build up of pressure, clogging effects at bottlenecks, jamming at room widening areas, faster-is-slower effect, inefficient use of alternative exits, initiation of panics by counter flows, and impatience. It was observed that the main contributing behaviors in these situations is a mixture of individual and grouping behavior.

Tracking and Detecting Objects
Detection and tracking of objects using machine vision is a much efficient solution, with much higher consistency of results, than the canonical manual observation performed by multiple human observers. Several methods have been implemented and tested in the area of machine-based tracking, the most traditional of which are the background subtraction method and the frame differencing method. However, the most efficient approach [13] by far is by utilizing a bipartite graph G β . In this method, G β contains classes that represent certain entities about a frame or image parsed from a video. One class corresponds to the expected positions of the tracked objects E p i ∈ B, ∀i, while the other corresponds to the blobs B from within the current image. Features such as size, position, color, shape, and velocity may be extracted from the object blobs. An adjacency matrix MG of the graph will be created, wherein the matrix entries mi,j are the similarity measurements between the jth blob and ith tracked object.

Motion Analysis
Researches abound in the study of motion in image sequences. Motion analysis is the science of comparing sequential still images captured from photographing a body in motion in order to study the kinematics (the motion themselves) and the kinetics (external and internal forces) of the body [5]. Often called dynamic image analysis [14], motion analysis is only based on a few number of consecutive frames, which has similar methods as to the analysis of static images. Correspondence between the pairs of points of interest are being observed in the sequence of images. It uses the concept of motion field which projects the threedimensional motion into two-dimensional one, such that a velocity vector (e.g., direction, velocity, and distance) from an observer is assigned to each point in the two-dimensional image. A good approximation of the motion field is the concept of the optical flow. Optical flow gives a description of motion and can be a valuable contribution to the interpretation of the image. Since the data is qualitative, optical flow can be done even if no quantitative data are obtained from motion analysis. Furthermore, optical flow can be used to study a large variety of motions, as it can determine the motion direction and velocity at image points. The method, however, suffers in accuracy due to illumination changes but can still be useful by taking in some motion-localized assumptions, such as constraining the motion to maximum velocity, small acceleration, common motion, and mutual correspondence.

METHOD 3.1 Video Capturing
We captured several videos in overhead view of pedestrians along hallways and cross ways under different traffic scenarios as follows: 1. Scenario 1: Pedestrians were flowing smoothly in one direction (left-to-right, LR). In the corridor of the study area (Figure 2 (a)), after considering for the perspective effect of the camera lens, the dimensions of the captured area (Figure 2 (c)) is 2.0 × 1.5 (3 m 2 ) when the camera was mounted 3.5 m from the hallway floor (Figure 2 (b)). However, the captured area (Figure 2 (d)) is 4.5 m 2 (2.5 × 1.8) when the camera is mounted 3.9 m from the ground. We used a video rate of 30 frames per second (fps).

Preprocessing Image Sequences
We split into several frames F = {f1, f2, . . . fn} the respective n-frame videos of the different pedestrian scenarios using a video processing software called VirtualDub (Version 1.6.16) [15]. Because of the variability of the scenarios, each has a different value for n. We then archived the image frames in file directories.

Detecting Pedestrians
We used the hair color of the pedestrians to detect them by utilizing various intensities of the black pixels. We did this by scanning each fi, ∀i = 1, 2, . . . , n through a bounding box b, and then by processing the two-dimensional pixels bounded by b. Within each b, we counted the valid redgreen-blue (RGB) color values of black pixels. We indicated that b has already bounded a candidate pedestrian head once a threshold sum of pixels p is met (See Figure 3 for an example overhead image with detected head). We then searched the vicinity margin of b for more related pixels. Once done, we incremented the position of b and repeated the same process for the next set of pixels bounded by b.

Tracking Pedestrians
Once we have identified that b bounds a pedestrian's head, we computed the two-dimensional coordinates of the center of mass Mx,y(O) of the bounded object O. We used Mx,y to track the coordinates of the center of mass of the pedestrian's head. We considered b to be still bounding the pedestrian's head if the difference of the current (xt+1, yt+1) and previous (xt, yt) of M (O) is less than a set value (See Table 1 for the set of values we used in this study). Otherwise, we considered the f as erroneous and used Mx,y(O) at time t instead. Because the pedestrians head might overlap in realworld due to the perspective effect of the camera lens, we allowed b to overlap with other bs in a certain margin (See column F of Table 1 for the margin values we used in this study). We repeated the process for the succeeding f until the object being tracked is out of the scene. We considered an object as out of the scene when there is no more valid number of black pixels within b that can represent the object.
We utilized several threshold values to account for the varied lighting conditions when the input image sequences were recorded for each different scenario. We did this to avoid false detection and misdetection of pedestrians in the image sequences. The values of variables we used for the different scenarios are shown in Table 1.  To track multiple objects, we colored the outline of b as white once b detects an object. This way, the system will not keep detecting and tracking the same object within the same f .

Tracing Trajectories and Computing Distances
We traced the trajectories or the path traveled of each pedestrian in the image using each object's Mx,y(O) for every f . Given the coordinates of the (x, y) in each f , we used the cononical two-dimensional distance formula, the L2 metric, to compute for the distance dp(O) traveled by each pedestrian per f .

Presentation of Measured Values
We presented the trajectories of the pedestrians by superimposing colored lines following the center of mass Mx,y on the video scene ( Figure 4). We displayed the other motion characteristics of pedestrians as line graphs over time: distance vs. time, velocity vs. time, and acceleration vs. time.

RESULTS AND DISCUSSION
In comparing the motion characteristics of the pedestrians at different scenarios, we used the trajectories (superimposed on video sequences) and the graphs generated by the system.

Scenario 1
This scenario shows a freely flowing pedestrians. As captured in the output graphs ( Figure 6), uniform speed is shown for all the pedestrians. The small variation shown in the graph can be attributed to the integer arithmetic when dealing with pixel positions and not with the small motion by the pedestrians. However, even if such motion was created by the pedestrians, such variations are small enough to create traffic jams.

Scenario 2
In this scenario, the traffic flow of simultaneous crossing of pedestrians from opposite directions is smooth, as captured by the velocity vs. time graph in Figure 7. Although there were two directions of pedestrian flow, the individuals were moving in uniform lanes. We observed in their respective trajectories (Figure 7 (b)) that there were two dominant divisions of walking lanes. This observation surely verifies the claim of Helbing [1] that the pedestrians self-organize. Figure 7 (c) shows the separate groups of pedestrians. The line graphs starting in distance zero correspond to the pedestrians coming from the left part of the scenario while the other line graphs correspond to the ones coming from the right. Even if the graphs crossed each other, there were no major changes in the magnitude of the pedestrians' motion characteristics. The pedestrians still created uniform lanes of walking direction to avoid moving delays.

Scenario 3
In this scenario, a pedestrian P stopped in an area in the scene and went back to the direction he came from (i.e., made a U-turn). It was observed in the graphs (Figure 8) that some pedestrians slowed down when they where intersected by P . Others stopped for a certain range of time. As P moves away from the other pedestrians, the latter slowly recovered and increased their velocity. It shows here that a pedestrian itself can cause delays in pedestrian traffic.

Scenario 4
In this scenario, a counter flow exhibited slow down of motion of the pedestrians before and during the intersection. We observed no self-organization among pedestrians here. Instead, the individuals moved to different directions just to reach their destination and to avoid colliding with other pedestrians. We observed from some of the pedestrians' trajectories that they make turning motion to avoid the obstacles along their way (see Figure 5). Even with this obstacle avoidance behavior, because everybody is avoiding the counter flow, a short-term traffic jam that lasted for a short time was observed. When a pedestrian moved out of the intersection, the pedestrian was able to get back to a uniform speed, as evident in Figure 9.

CONCLUSION
In this study, we created a machine vision system that automatically captures the dynamics of pedestrian traffic. The system was able to detect and track multiple pedestrians and effectively display some of their motion characteristics. We used the system to analyze and quantify the behavior of the pedestrian in four different traffic scenarios, namely: 1. Scenario 1: Pedestrians were flowing smoothly in one direction (left-to-right, LR). Using the measured metrics by the system, the results of our analysis suggest that pedestrians themselves alter the traffic condition. The motion characteristics of a pedestrian depend on its desired magnitude and on the delays in its environment. In counter flows (as in Scenario 4), if pedestrians self-organize, the traffic flow can be smooth, otherwise a traffic jam may build up.
By learning the behavior of pedestrians in different traffic scenarios, we could efficiently devise safety and security measures in crowded areas, avoid accident, injuries, and even loss of lives. This system will be helpful in the field of architecture for the structural designs of pedestrian hallways and pathways in buildings. We recommend this system for use in the study of pedestrian evacuation during fire escaping and for avoidance accidents such as stampedes.