{'fraction_non_alphanumeric': 0.03297776170674381, 'fraction_numerical': 0.009365395046103779, 'mean_word_length': 4.543850856971034, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 2, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Benchmark data and method for real-time people counting in cluttered scenes using depth sensors

Vision-based automatic counting of people has widespread applications in intelligent transportation systems, security, and logistics. However, there is currently no large-scale public dataset for benchmarking approaches on this problem. This work fills this gap by introducing the first real-world RGB-D People Counting DataSet (PCDS) containing over 4,500 videos recorded at the entrance doors of buses in normal and cluttered conditions. It also proposes an efficient method for counting people in real-world cluttered scenes related to public transportations using depth videos. The proposed method computes a point cloud from the depth video frame and re-projects it onto the ground plane to normalize the depth information. The resulting depth image is analyzed for identifying potential human heads. The human head proposals are meticulously refined using a 3D human model. The proposals in each frame of the continuous video stream are tracked to trace their trajectories. The trajectories are again refined to ascertain reliable counting. People are eventually counted by accumulating the head trajectories leaving the scene. To enable effective head and trajectory identification, we also propose two different compound features. A thorough evaluation on PCDS demonstrates that our technique is able to count people in cluttered scenes with high accuracy at 45 fps on a 1.7 GHz processor, and hence it can be deployed for effective real-time people counting for intelligent transportation systems.


I. INTRODUCTION
Automatic people counting in real-time has multiple applications in intelligent public transportation systems [1], [2], [3]. On effective method to reliably accomplish this task is to directly analyze continuous video streams of vehicle entrance and exit doors, and perform automatic counting of people in those videos. For intelligent public transportation systems, such as buses with on-line monitoring, knowing the number of people entering and leaving the transport can be used in e.g. dynamic planning to avoid congestion. It also promises significant economic benefits by improving transportation scheduling in accordance with human traffic on stations at different hours of operation. Computer Vision techniques are well-suited to the problem of automatic people counting for public transportations. However, using conventional RGB videos for this purpose is challenged by multiple issues resulting from real-world conditions such as clutter, occlusions, illumination variations, handling shadows etc. In comparison to the conventional video systems, RGB-D cameras (e.g. Kinect V1 [4], Prime Sense Camera [5]) can mitigate these issues by providing 'depth' information of the scene in addition to its color video. Nevertheless, effective people counting in real-world conditions using depth information still remains a largely unsolved problem due to noise and occlusion [6].
Vision-based people counting is a comprehensive task that involves object detection, recognition, and tracking. Existing approaches in this area can be broadly categorized into three classes: (a) regression-based methods, e.g. [7], [8] (b) clustering-based methods, e.g. [9], [10], and (c) detectionbased methods, e.g. [11], [12]. Regression-based methods aim at learning a regression function using features of detection regions and exploit that for counting. Clustering-based methods track a set of features of target objects, and cluster their trajectories for counting them. Detection-based methods have a common pipeline, comprising foreground extraction, target localization, tracking, and trajectory classification. We can further divide these methods based on the data types they use e.g. color/depth/hybrid video methods (see Section II for the details). Although useful, the above mentioned approaches face some common problems while counting people under practical conditions in real-time, which include; restriction of camera angles [13], [14], [15]; computational inefficiency [16], and failing to handle cluttered scenes [17]. Moreover, to the best of our knowledge, there is currently no large-scale public dataset available to benchmark methods for real-world people counting.
In this paper, we first introduce a large-scale dataset for the problem of counting people in real-world scenes of bus entrance/exit doors. The dataset, called People Counting DataSet (PCDS) contains 4, 689 videos acquired with the Kinect V1 camera [4] that contains RGB and depth sensors. The dataset can be publicly downloaded using the following URL (https://github.com/shijieS/people-counting-dataset.git). Each video in the dataset is labeled with the number of people entering or exiting the bus door. The data has been collected on three different bus routes at different times of the day on 4 -6 different days, and presents large variations in terms of illumination, occlusion, clutter and noise. As a second major contribution, we propose a real-time method for counting people passing through cluttered scenes. The   uses the depth video stream for people counting. Figure 1 illustrates the pipeline of the proposed method. Our approach assumes the setting where the camera is mounted on top of the area to be monitored (see 'Camera Calibration' in the figure). This is the most common setting in scenarios like bus doors, corridors, entrances/exits to market places etc. After retrieving the depth video stream from the input, we subtract the scene background using a proposed procedure for the real-time performance of our approach. A 3D-point cloud of the foreground is computed from the depth information and then re-projected orthogonally onto the ground plane for effective segmentation. For each video frame, we analyze its projected height image for the presence of potential human heads while employing a 3D-human model to refine those proposals. The refined proposals are tracked to compute the head trajectories that are further refined and continuously monitored in our approach to count people entering or leaving the buses. To achieve our objective, we also introduce two discriminative feature vectors for head detection in height images and trajectory tracking in frame sequences. Our approach is evaluated using PCDS, and achieves up to 92% accuracy for the real-world bus videos while enabling processing at 45 fps on a relatively less powerful 1.7GHz Intel processor with 2GB RAM. These results are significant since people counting is a challenging problem and our method can achieve real-time performance in practical conditions with minimal computational resources. This paper is organized as follows. The related work is reviewed in Section II followed by Section III which describe the published dataset named PCDS. In Section IV, we introduce the proposed approach for people counting in cluttered environment. The experiments and results are provided in Section V. In Section VI, we draw the conclusion.

II. RELATED WORK
The problem of people counting is often seen from two different perspectives: (a) Region of Interest (ROI) counting [18], [19], [20], [21], and (b) Line of Interest (LOI) counting [22]. The former deals with counting people in specific regions (e.g. in playgrounds), whereas the latter aims at counting the number of people 'passing through' a certain region (e.g. through doorways). This work deals with the LOI counting. Many methods for LOI counting have been proposed, which can be divided into three major categories: 1) regression-based methods, 2) clustering-based methods, and 3) detection-based methods. Below, we review literature under these categories with emphasis on detection-based methods because of their close relevance to the proposed approach.

A. Regression-based Methods
The main objective of the regression-based methods is to learn a regression function as the representation of changes in a scene which indicates passing of a pedestrian. Under the paradigm of regression-based approach, Barandiaran et al. [7] used a single RGB camera to count people by the state change of virtual counting lines. Pizzo et al. [12] proposed a method which divides the detection region into stripes and counts people by monitoring the change of state for these stripes without people head detection and object tracking steps. Fradi et al. [8] used Gaussian Mixture Model (GMM) to extract the foreground and used Gaussian Process regression to learn the correspondence between frame-wise features and the number of persons. Benabbas et al. [23] proposed a method which accumulates image slices and estimates the optical flow. They applied a linear regression model to blob features which are extracted by an on-line blob detector to get the position, velocity, and orientation of the pedestrian. Cong et al. [24] estimated the number of pedestrians passing through a line by quadratic regression with the number of weighted pixels and edges which are extracted from the flow velocity field. Whereas useful, one common drawback of the above methods is that they place hard restrictions on camera installation angles and the scene itself, which compromises their practical value.

B. Clustering-based Methods
Clustering based methods simultaneously track multiple features of objects e.g. key points or people component, and subsequently count people by clustering feature trajectories. For instance, Antonini et al. [9] clustered trajectories of visual features and then used the number of clusters for counting people. Topkaya et al. [10] used features based on spatial, color and temporal information and clustered the detected feature trajectories by Dirichlet Process Mixture Models (DP-MMs) [25]. They used Gibbs sampling to estimate an arbitrary number of people or groups in their approach. Brostow et al. [26] proposed a method that first tracks simple image features and then probabilistically groups them into clusters based on space-time proximity and trajectory coherence through the image space. Rabaud et al. [27] used KLT tracker [28] to track feature points, and segmented the set of trajectories by a learned object descriptor.

C. Detection-based Methods
The approaches that fall under this category share a common sequential processing pipeline which goes as follows. First, foreground is extracted from the video stream, then the objects of interest are detected and tracked. The tracked trajectories are subsequently classified to count the objects of interest. The detection-based methods can be further divided into three different groups based on the underlying data modalities, namely 1) RGB video methods, 2) Depth video methods, and 3) Hybrid methods. We also include an additional category in our review that includes approaches employing the fast emerging deep learning framework.
1) RGB video methods: Using RGB videos is more popular in people counting literature because of easy availability of color video cameras. Zeng et al. [11] detected head-shoulder patterns in RGB videos by combining multilevel HOG features [29] with multilevel LBP features [30]. They used PCA [31] to reduce the dimensionality of the multilevel HOG-LBP feature set, and finally tracked the head-shoulder patterns to count people. Antic et al. [32] proposed a people segmentation, tracking, and counting system by using an overhead mounted camera. Garcia et al. [33] also developed an RGB system for counting people in supervised areas. Their method is based on finding heads of people by a circular pattern detector and tracking them using Kalman filter [34]. Their approach also performs the final counting using the tracked trajectories. Chen et al. [13] used a vertical RGB video-camera to count a crowd of moving people by segmenting the crowd based on the frame difference method [35]. Their approach extracts features to describe the individual patterns, and tracks the individuals for counting. Kurilkin et al. [36] compared different people detectors in their study.
The methods described above are likely to suffer from critical failures when the scenes become complicated due to shadows, light changes, compound objects, occlusion, and the presence of significant background texture. To alleviate these problems, researchers exploit stereo cameras which can provide the third dimension information. For instance, Terada et al. [37] proposed one of the first approaches for stereo camera based people counting in RGB video regime. They detected people using max points, tracked them with template matching and finally used the two measurements from the stereo vision for counting. In a related approach, Kristoffersen et al. [38] used two thermal cameras to reconstruct 3D points and proposed an algorithm for pedestrian counting based on clustering and tracking of the 3D point clouds. However, in their approach, the cost of depth computation remains high, which makes it difficult to use the approach in real-time with low computational power devices.
2) Depth video methods: With the popularity of RGB-D cameras; such as Kinect V1/V2 [39] and Prime-Sense [5], depth videos are also becoming popular in people counting applications. Zhang et al. [40] proposed to use a so-called 'water filling method' to detect people and counting them by the virtual line in a depth image. Barandiaran et al. [7], and later Pizzo et al. [12], [41] proposed approaches that are based on detection without tracking. These approaches detect changes in scene states across a virtual line, where the scene is divided by multiple stripes. The state of the scene changes when people pass by, thereby enabling people counting. Rauter et al. [42] introduced the Simplified Local Ternary Patterns (SLTP) that are used to describe a human head. They trained an SVM using SLTP and tracked human heads with the nearest neighbor association methods. Vera et al. [43] proposed a network of cameras to count people. They devised a head detection method based on morphology geodesic reconstruction [44] and performed tracking using the Hungarian algorithm [45]. Their approach combines tracks generated by multiple cameras and the final count is based on the length of the combined track. Li et al. [14] proposed an embedded framework for real-time top-view people counting. They used the Kinect camera and the Jetson TK1 board [46] to detect human heads using the water filling technique [40]. Their approach also uses the nearest neighbor association method for tracking. Enrico Bondi et al. [47] introduced a framework for real-time people counting which follows the sequence of background removal, head detection and tracking the projected heads. Whereas promising, their framework drastically performs in complicated scenarios where other head-like objects also appear in the scenes.
3) Hybrid methods: Combining the advantages of RGB and depth data streams are well documented in related problems, e.g. action recognition [27]. Therefore, few methods have also used the hybrid approach in people counting. For instance, Gao et al. [15] detected head candidates in depth videos by water filling method and refined these candidates by training an SVM classifier using HOG features of the frame in RGB videos. Their approach eventually generates a set of trajectories by the nearest distance between the head candidates and the previous tracks. Liu et al. [48] also used RGB-D camera for detecting people. Their approach projects people into a virtual plane and trains an SVM classifier using features that are used for detecting the upper body of humans. Zhang et al. [49] proposed head detection by blob detection in depth frames and projected the blobs into the 3D space. Their approach filters the candidate blobs for heads by physical constraints and employs the histogram of multi-order depth gradient (HMDG) features and joint histogram of color and height (JHCH) features to train an SVM classifier. The trained SVM is used to classify the candidate blobs as heads. However, their approach remains sensitive to occlusion.

4) Deep Learning-based Methods:
Recently, Deep Learning [50], [51], [52] has demonstrated great success in object detection and classification tasks [53], which has also motivated researchers to employ it for the problem of people counting. For instance, Liu et al. [16] proposed a people counting system based on Convolutional Neural Network (CNN) [54] and Spatio-Temporal Context (STC) model [55]. The CNN model is used to detect people whereas the STC model is used to track heads of moving people. Similarly, Wei et al. [56] proposed a framework based on supervised learning. They extracted spatio-temporal multi-features by joining super-pixel based multi-appearance features and multi-motion features, and then fused the multi-features with the features extracted from the VGG-16 model [57].

III. PEOPLE COUNTING DATASET (PCDS)
In this Section, we present the People Counting DataSet (PCDS) introduced for the problem of people counting in realworld conditions. The dataset is publicly available for download at https://github.com/shijieS/people-counting-dataset.git.

A. Settings and Data Taxonomy
The data consists of videos of bus-door scenes recorded using Kinect V1 camera [39]. The camera is mounted on the ceiling of (front/back) doors of different buses, and captures people entering or exiting through the doors. Figure 2 shows four representative scenes from the dataset. Due to the realworld scenarios, complexity of the data is apparent from the figure. In comparison to the existing related datasets [12], [40], videos in PCDS are recorded by the camera with a pitch angle that is not necessarily vertical to the ground plane.
We divide the videos in the dataset based on the bus route numbers. The dataset is recorded for three different bus routes, namely No. 25, No. 301 and No. 106 in the cities of Xi'An, XiNing and YinChuan, respectively in China. The data samples cover all the bus stops in the complete circuit route of the buses. For No. 25, the videos have been collected on 6 different days. For No. 301 and No. 106, the number of days are 5 and 4 respectively. For each day, we collected data for the front door as well as the back door. Thus, in total, there are 30 different scenes in our dataset. We can further sub-categorize the videos of these scenes based on their noise level and crowd in the scene. In the above mentioned URL for the dataset, we organize the dataset according to these measures. In Fig. 3, we provide the folder structure of the proposed dataset. We denote the noisy/clean scenes with N + /N − , and crowded/uncrowded scenes by C + /C − . As an example, a noisy-crowded scene is denoted by N + C + according to the adopted notation.
The rationale of dividing the dataset into noisy and clean videos is that Kinect V1 camera is sensitive to illumination conditions. For strong illumination, there is often noise in the videos, as can also be observed in Fig. 2. The videos in our dataset are mainly recorded in either direct sunlight or diffused sunlight, resulting in a natural division of corresponding levels of noise. Similarly, the division of videos according to congestion in the scenes is also natural. During rush hours, multiple people are generally passing through the bus doors. On the other hand, sequential entry with clear separation between people is observed during normal conditions.
In light of the division provided in Fig. 3, one can expect the following from the four possible sub-categories for each scene in the proposed dataset: • N + C + : Videos are captured in strong sunlight during rush hours, with multiple people attempting to enter/exit the bus at once. • N + C − : Videos recorded in sharp sunlight during normal hours where people are entering/exiting bus doors in a more sequential manner. Fig. 3. Structure of the People Counting DataSet (PCDS): The root directory contains 30 scenes, with two subdirectories each. Each subdirectory either contains noisy scenes (denoted by N + ) or clean/normal scenes (denoted by N − ). The 3rd-level of directories contains crowded (i.e. C + ) or un-crowded (i.e. C − ) scenes.  but in crowded situations. • N − C − : The recording is done in mild/diffused sunlight with sequential entry/exit of people through the doors. Table. I summarizes the number of people entering and exiting the bus doors for each sub-category.

B. Video Information
In Table II, we summarize the basic attributes of the videos in our dataset. We note that, these video attributes along the camera parameter details are also provided in each folder of the dataset. Moreover, the total number of people passing through the doors is also provided as the ground truth. We also provide RGB videos along the depth videos that can be used for verification purposes. However, we emphasize that the depth modality is more useful for the problem of people counting in the real-world conditions because of its robustness to e.g, illumination conditions and shadows.

IV. PROPOSED APPROACH
The schematics of the proposed approach for people counting is illustrated in Fig. 1. Our method performs counting by analyzing the depth video frames retrieved from the RGB-D camera. The major steps involved in our approach are; 1) removing the scene background, 2) re-projecting point cloud onto the ground plane, 3) generating candidate head proposals in the projected images, 4) refining those proposals, and 5) tracking the trajectories of human heads for counting. We provide details of each of these steps below.

A. Background Removal
There are multiple techniques for background subtraction from RGB videos [11], [58], [59]. However, depth videos are inherently different from RGB videos and such methods are not readily applicable to them. Few methods for background removal from depth videos also exist [60], [61]. However, those techniques are generally computationally expensive, which makes them unsuitable for our real-time application. Moreover, such methods were also found to be unsuitable for handling the noise in PCDS resulting from the real-world conditions. Therefore, we develop our own method for efficient background subtraction from depth videos for people counting scenarios, such that the results also remain robust to noise in the real-world data. In our settings, a depth frame I D ∈ R H×W is a matrix, with its each element representing the distance of a point in the real-world to the camera sensor. For a camera mounted on top of the area to be monitored (as in PCDS), one can expect that the farthest points in the scene would generally belong to the background. Based on this simple intuition, we develop a 'farthest background model' B I ∈ R H×W of dynamic scenes that enables automatic estimation of the background on-thefly. A major advantage of such an approach is that it can be readily used for any scene without the need of calibration for the background.
We compute B I as a map of the largest distances appearing in the sequences of depth frames, while accounting for the possible noise accumulation. To ensure that effective B I is available for each video frame, we take the help of two intermediate models B c and B 2c , where 'c' stands for cache. We initialize B I and B c with I D at the start of the video stream (B 2c is initialized later, see below). For an input frame sequence, we update B c at every frame as follows: where the superscript 't' denotes the current frame and t − 1 indicates the previous frame. The max{.} operation is performed element-wise. After every n c frames, we update B I by assigning it the values of B c . It is easy to see that under the above mentioned strategy, any large distance values in B c resulting from noise at any stage can eventually get stored in B I . To cater for this problem, we separately initialize B 2c with I D just after B I is updated (i.e. after n c frames), and keep updating it with every frame as follows: We update B c as well as B I with B 2c after each n 2c , whereas we impose that n 2c − n c = 0 to ensure that the update of B I under B c and B 2c is asynchronous. This strategy entails that a maximum value once entered in B I as a result of noise can be replaced by the correct smaller value in the later frames.
For computational purpose, we also constrain n 2c > 2n c . As a result of the asynchronous updates with intermediate models, effective B I remains available for each frame. We use this farthest background model to extract the foreground I F at each frame as follows: Fig. 4. Camera mounted position and camera calibration: The RGB-D camera is mounted on top of the scene and has a pitch angle. The camera coordinate frame is shown by is the i-th point in the world coordinates which corresponds to (x (i) , y (i) , z (i) ).
is the pixel value at (u, v) position of I t D , and δ dis denotes the threshold parameter for our approach.

B. Reprojection
Generally, cameras used for counting people are installed with non-zero pitch angle, e.g. see Fig. 4. The camera perspective often causes occlusion and overlap in the depth maps of people, which adds to the complexity of counting problem. The objective of "reprojection" stage is to remove the perspective distortions so that individuals become well separated in the reprojected depth frames. For that purpose, we first construct a 3D point cloud from a depth frame of the camera and then re-project it normally onto the ground plane to obtain a normalized depth image. We present details of the reprojection procedure below.
First, we convert the foreground image I F into 3D points in the camera coordinates. For every pixel in I F , we recover its 3D point as follows: where (f x , f y ) denote the camera focal length, (c x , c y ) is the camera principal point, I F (u, v) is the pixel value at the position (u, v) in I F , and X C , Y C , Z C are the recovered 3D point coordinates.
For projecting points onto the ground, we must first convert 3D points in the camera coordinates to the world coordinates. Let us denote the world coordinate frame by {X W , Y W , Z W , O W }. We fix this frame directly below the camera coordinate reference frame, as shown in Fig. 4. To perform the transformation between the coordinate frames, we compute the homogeneous transformation matrix (T ∈ R 4×4 ) based on the extrinsic parameters of the camera. To that end, we first identify N points in a depth frame acquired by the camera and physically measure the corresponding points in the world coordinates. The following optimization problem is then solved using the least squares approach [62]: where P W ∈ R 4×N contains N points arranged as its columns in the world coordinates, and P C ∈ R 4×N contains the corresponding points in the camera coordinates. The last row of these matrices consist of 1s. For a unique solution, we constrain N > 4 in our measurements. Note that, estimation of T is an off-line process in our approach and it is performed only once for calibration. Using the matrix T we eventually transform all points in I F to a 3D point cloud in the word coordinates. We then project this point cloud normally onto the ground plane. Intuitively, multiple points in the 3D point cloud can be mapped to the same point on 2D ground plane. In our approach, we only store the 2D mappings of the highest points in the 3D point cloud. Concretely, for the points (X , ∀i in the 3D point cloud, we compute a 2D ground plane projection I H (x, y) as follows: where (x, y) indexes points in the 2D plane. Henceforth, we refer to I H as the "height image" because each point/pixel in this image represents the highest point in the corresponding 3D point cloud.
The effects of reprojection can be understood as acquiring the depth image by 'Camera 2' instead of 'Camera 1' in Fig. 5b. Looking at the scene exactly from the top, Camera 2 is able to separate the individuals in the scene very well. This is clear from Fig. 5d when we compare it with the camera captured depth frame (with background) in Fig. 5c. The figure clearly demonstrates the benefits of the reprojection step in the proposed approach.

C. Candidate Head Proposals
Although the reprojected height images separate individuals well, the loss of information due to occlusions in the original depth frames can not be recovered from these images. Due to their height, human heads suffer the least from the occlusions caused by the camera perspective. Therefore, instead of tracking the complete human body to count people, we focus on reliable localization of human heads in the height images and eventually use head trajectories for people counting.
To locate human heads in the reprojected images, we exploit our prior knowledge about a human body. We make use of a 3D human model, shown in Fig. 6, by dividing the body into three major parts, namely; Head, Shoulders, and Lower body. We place a cuboid on each of these parts that represents the volume where the body part is most likely to be located in the 3D space. For instance, we expect the head to be located in the blue cuboid of dimensions W h , H h , L h in the figure. The exact dimensions of the cuboid would vary from person to person. Therefore, we empirically place minimum and maximum thresholds on these dimensions in our approach. The used thresholds are summarized in Table III. Our intuition is that we can locate the corresponding body parts of individuals in the height image using the human model. Therefore, the thresholds in the table cover reasonably large ranges to account for the variability in human sizes in height images.
With the help of underlying human model, we generate candidate proposals about the human heads possibly present in the height image by sequentially performing the following steps. 1) Down sampling the height image, 2) computing the local maxima in the down sampled image, 3) expanding the local maximum points, and 4) filtering the expanded areas. Below, we describe each of these steps in detail.

1) Down sampling:
Recall that our aim is to develop a realtime method that can deal with the real-world noise. To reduce computations and mitigate the adverse effects of noise in this step, we first down sample the height image I H by averaging its w b ×w b dimensional disjoint patches. As a result, we get an image I B with its pixel at (x, y) location computed as follows: where, (u, v) denotes a pixel location in I H . For the height image shown in Fig. 5d, the resulting down sampled image I B is illustrated in Fig. 7a.
2) Local Maximum Point Computation: Intuitively, the pixels corresponding to human heads are more likely to have the largest values in height images. This property is also well preserved in the down sampled image I B , as can be seen in Fig. 7a. Thus, to locate the areas that can potentially belong to human heads in I B , we adopt a simple strategy of identifying a set C b of the pixels in I B that contain the maximum values in their 8-connected pixels. These pixels are then used to identify the local maximum points in the original height image. Note that, the i th element of C b , i.e. C i b is computed as the mean of a set of pixels in the height image. We represent the set of the desired maximum pixels in I H as C H , and compute the j th element of that set, i.e. C j H as follows: As a result of this operation, we are able to efficiently identify the local maximum points in our height image. Fig. 7b illustrates the computed points from the corresponding down sampled image in Fig. 7a.

3) Expanding Local Maximum Points:
A local maximum point in I H may or may not belong to a human head. Therefore, we must analyze the local vicinity of the maximum point and compare it with our human model to ascertain that the point is indeed located on a human head. We adapt the for each pixel (u, v) ∈ C 0 do 5: N P is 8-connected pixels of (u, v) 6: for each pixel (x, y) ∈ C 0 do 7: if (x, y) / ∈ C s and |I H (x 0 , y 0 ) − I H (x, y)| ≤ δ h and r − l t ≤ W max and b − t t ≤ L max then 8: l t ← min(x, l); r t ← max(x, r); 9: t t ← min(y, t); b t ← max(y, b); 10: end for 16: [63] to expand the local maximum points into rectangles such that the object bounded by each rectangle can be compared with the human model. The procedure for expanding the local maximum point is given as Algorithm 1.
Along the height image I H and the set of local maximum points C H , the algorithm requires the maximum allowable height and width of a head (from Table III) as the input. It also uses an expanding threshold δ h as an input parameter, that restricts the expanded rectangles to contain object pixels with similar values. The algorithm eventually results in a set E H that contains the expanded rectangles as its elements. The main iteration of Algorithm 1 runs over each element of C H , that are called seeds in the context of seed fill method [63]. The first inner 'for loop' (lines 4-15 in the algorithm) performs the actual expansion process. It first identifies the 8-connected neighborhood of a considered pixel (line 5) and then iterates over each of the neighboring pixels (line 6-13) to evaluate the condition given on line 7 of the algorithm. If the condition is satisfied, the sets C s and C 0 are updated which are subsequently used in the outer loop. The algorithm gradually expands a seed in C H to a rectangle that is upper-bounded by the maximum dimensions W max and L max while ensuring that the pixel values in the expanded rectangles remain close to the seed value so that the rectangle only bounds a single object.

4) Filtering Local Maximum Areas:
Despite capitalizing on the physical attributes of human body parts, we can still expect that few rectangles in E H may not actually belong to human heads (see e.g. Fig. 7c). Therefore, we further filter the computed rectangles using the human model. In the filtration process, we also consider incomplete human heads resulting from occlusions. To filter, we discard all the rectangles in E H that do not satisfy the following condition: where, L and W represent the length and width of a rectangle and the subscripts min, max denote the minimum and maximum lengths allowed in Table III for 'Head'. Notice that we reduced the minimum allowed values in Eq. (9) by half. This is done to account for occlusions that can often cause the size of a head in our height image I H to reduce significantly.

D. Head Proposals Refinement
For the cameras installed on top of pathways, human heads in video frames rarely overlap in real scenes, as can be observed in Fig. 8a-b. However, the set E H may contain few overlapping rectangles (see Fig. 8c), therefore we can further refine this set by discarding the overlapping rectangles. To do that, we consider all the groups of overlapped rectangles in E H , and for each group, we store only the rectangle with the highest seed value and discard the remaining rectangles. We denote the refined set of rectangles by F H . Fig. 8d illustrates the result of this refinement.
The rectangles contained in the set F H are highly likely to correspond to human heads in I H , however it is still possible that some of those rectangles may actually belong to other objects in the scene. Differentiating between a head and a nonhead rectangle in F H is a non-trivial task because occlusions and other factors, e.g. presence of high round-shaped objects like bag-backs, can result in patterns in I H that are very similar to human heads. We hypothesize that despite their close similarity with the human heads, the non-head objects can be automatically identified by analyzing their relevant features.
Hence, we design a compound discriminative feature that accounts for different relevant attributes of objects to classify them as 'heads' and 'non-heads'. We momentarily defer the discussion on the proposed feature to the text to follow. We extract the proposed features for the elements of F H and train an SVM classifier over those features to further discard the rectangles that bound non-head objects.
For the SVM training, we manually label each extracted feature for a rectangle as 'head' or 'non-head'. This off-line training is carried out only once in our approach on the training data. For the test frames, we similarly extract the features of head proposals and classify them as 'heads' or 'non-heads' using the trained SVM. The 'non-heads' are discarded in further processing. Our proposed compound feature vector is a concatenation of two major types of features that we call Basic Geometric Features (BGF) and the Nearest Rectangle Difference Feature (NRDF). The BGF itself is a combination of four different features explained below: • Shape Feature (H r , W r , R, P ), where H r is the height of a rectangle, W r is the width of the rectangle, R is the ratio of W r to H r and, P = H r × W r . • Symmetry Feature (S H , S V ), where S H captures the horizontal symmetry and S V represents the vertical symmetry. We define S H and S V as follows: where, (l, t) denotes the top-left corner point of the rectangle. Inclusion of this feature in our compound feature is motivated by the natural symmetry of human heads. • Zero Pixel Feature (N 0 , R 0 ), where N 0 denotes the number of zero pixels appearing in the image area bounded by a rectangle, and R 0 = N0 HrWr is the rate of zero pixel appearance. • Expansion Ratio Feature Ψ ∈ R 5 contains the ratios of the area of a rectangle in F H to five different rectangles achieved by using different expansion thresholds δ h in Algorithm 1. By varying the values of the expansion threshold we can expect different rectangles resulting for different kinds of objects in the scene. Therefore, the expansion ratio feature provides important clues about an object being a head or not. In our original algorithm, we let δ h = 15 to arrive at the set E H . To compute the expansion ratio feature, we select the values of δ h from {20, 25, 30, 35, 40} to generate five different rectangles corresponding to each element of F H and calculate Ψ for each element. We concatenate the above mentioned four geometric features into a vector in R 13 . Notice that, although we do consider varied areas of I H in the above mentioned features, the compound feature only accounts for the information that is local to individual rectangles. In the real-world scenarios, the relative locations of the rectangles (that we suspect to contain Bag Head (a) (b) Fig. 9. Illustration of NRDF feature: a) The height image. b) The corresponding color video frame. There is a bag rectangle (yellow) in both images, whose nearest rectangle is the head (red). The yellow arrow is the NRDF feature of the bag rectangle and the red arrow is the NRDF feature of the head rectangle.
human heads) can provide useful information about a bounded object being a human head or not. Therefore, we further define NRDF to account for this additional information. For each rectangle in F H , we compute NRDF as a vector in the 3D-space that is directed towards the center of the rectangle from the center of its nearest rectangle in our current set of head proposals. This feature is further illustrated in Fig. 9.
The resulting NRDF ∈ R 3 is concatenated with the above mentioned feature vector to finally arrive at our compound feature vector in R 16 .

E. Tracking and Counting
Using the compound features introduced above, we refine the head proposals in F H . Notice that, this set is computed for a single depth frame in our approach. To eventually count the people passing through a scene, we must also track the trajectory of individual heads (i.e. people) in a continuous video stream. For that purpose, we exploit F H in maintaining a record of head trajectories in the incoming video stream. We count the number of people passing by the camera by counting the number of trajectories disappearing in our records. We use the direction of movement to determine if the person has entered or exited the bus. Concrete technical details of this procedure are provided below.
To track individuals in the scene, we maintain a set of trajectories T for the continuous video stream. The set is initialized as 'empty' when the stream starts. With each frame the set gets updated by adding, removing or updating its elements. An element of this set is given by {F i H , P i }, where 'i' indicates the i th element, and P i is the probability of that element bounding a human head. This probability is available to us from the SVM classifier trained to arrive at the refined set F H . In the text to follow, we refer to an element of T as a node for brevity.
To update nodes with each coming frame, we first match the potential nodes of the new frame with the current nodes in T . To that end, we compute η = ||(x o − x n ), (y o − y n ), (s o − s n )|| 2 , where (x o , y o ) indicates the center of the rectangle represented by a node in T , (x n , y n ) is the center of a rectangle in the new frame, and s o and s n are the seed values for the respective rectangles. We consider two nodes to be matched if η < δ m , where we empirically fix the value of δ m . If a new node does not match any existing node, it is added to T as a new element. If an existing node in T is not updated for Q consecutive frames, we remove that node from our set. The removed node increments our count of a person passing by the camera. When a node is removed, we determine the direction of the movement performed by the individual (i.e. 'enter' or 'exit') by analyzing the centers of the first and the last rectangle for that node. The information on the centers of rectangles (and their seeds), number of updates for each node, and the time stamp of the last update for each node are maintained in our approach by book-keeping.
Using the simple strategy explained above, we can track the trajectories of individual objects in the scene. However, tracking of 'human-heads' in the above method completely relies on the accuracy of F H . If a non-head object still eludes our refinement process discussed in the preceding Section, the approach may count extra individuals in the scene. To circumvent this problem we exploit the observation that humanheads generally follow similar trajectories in path-ways, which can be differentiated from the trajectories of non-head objects. Thus, we train binary SVM classifiers (one each for 'entering' and 'exiting' directions) to identify a given trajectory in T as 'head' or 'non-head'. We propose another feature for training the classifiers that is formed by concatenating a) the mean and variance of all nodes involved in a trajectory, b) the total number of updates for the trajectory, c) velocity of the trajectory computed as the rate of change in the center locations of the bounding rectangles, and d) the difference between the maximum and the minimum seed values for the trajectory. We use the SVMs trained over these features to refine our final count of the people entering or exiting the bus doors/path-ways.

V. EXPERIMENT
We evaluate the proposed method using our proposed dataset, PCDS, that contains a large number of pedestrians entering/exiting bus doors imaged by a Kinect camera installed on top of the door. The dataset provides the opportunity to thoroughly evaluate the major components of our approach individually as well as analyze its performance for the overall task of people counting. We first analyze the efficacy of our background subtraction procedure and compare its performance with the popular MOG [59] and KNN-based methods [64]. Then, we separately analyze the performance of our method for the tasks of human head identification, human head tracking and finally, people counting as a whole.

A. Background Removal
Background removal is a major task in many surveillance related problems. For our approach, reliable background subtraction is necessary for the success of subsequent processing of video frames. Therefore, we separately analyze the performance of our method for this task. We use the popular Gaussian mixture-based background segmentation method (MOG) [59] and the K-nearest neighbors (KNN) based method [64] to benchmark our technique. We note that other approaches for background subtraction also exist, however the selected baseline methods are chosen for their well-established Depth image KNN-based method [60] Our method MOG [55] [64]. Bottom-left: Background identified by [59]. Bottom-left: Proposed method. effectiveness for the depth videos. We carefully optimized parameter values of the baseline methods on our dataset using cross validation. For the proposed method, we empirically chose n c = 150 and n 2c = 500 in all our experiments. Fig. 10 shows a typical mask image generated by MOG [59], KNN-based method [64], and the proposed background subtraction procedure. As can be seen, the mask images generated by both KNN and MOG methods contain significant amount of noise which can be detrimental for the subsequent processing in our approach. On the other hand, the proposed method is able to preserve the masks of individual humans very well, with negligible noise. For further qualitative analysis of background subtraction, we also provide videos comparing our method with the existing approaches on the following URL: https://youtu.be/oiuYq Pfx6c.
Whereas our method achieves reliable background subtraction, it is also required to obtain those results efficiently for the overall task of real-time people counting. We show the computational time (in ms) for processing each frame of a typical frame sequence in our dataset for the proposed approach and the baseline methods in Fig 11. The time is computed on a 1.7GHz processor with 2GB RAM for the task of background subtraction. The proposed method averages around 1.0 ms/frame in comparison to 2.1 ms/frame and 4.5 ms/frame of MOG and KNN-based method respectively. High quality background subtraction with a small time required to process each frame makes our background subtraction highly desirable for the broader problem of real-time people counting.

B. Human Head Identification
An essential component of counting people in our approach is to accurately identify human heads in the scene. We identify human heads by first generating candidate head proposals and then refining them. In our approach, the process of generating the candidate proposals is intentionally kept relaxed, and it also results in identifying multiple non-head objects in the scene (e.g. shoulders, bag-packs) to be considered as potential 60 55 Fig. 11. Computational time for background subtraction for each frame. Timings for a sequence of 2,263 frames are shown. human heads. The refinement process (in Section IV-D) then discards the non-head objects to identify the human heads.
To analyze the performance of our method for human head identification, we first manually labeled 12,148 rectangle proposals in height images for people entering the buses as 'heads' and 'non-heads'. These proposals were generated automatically by the method in Section IV-C. We then trained and tested the SVM classifier employed in our approach using these proposals. We also performed the same routine for 10,108 candidate head proposals for the people exiting the buses. The details of the train-test distributions and the labels of proposals used in this analysis are provided in Table IV. In Fig. 12, we show the ROC curves for the classifiers trained for the refinement of head proposals. The curves show results of our three-fold experiments, with corresponding AUC values.
From Fig. 12, we can argue that the employed classifiers are able to identify human heads in the proposals successfully. We note that the classification performance depicted by Fig. 12 is better for the people exiting buses than for the people entering buses. The reason behind this phenomenon is that while providing the ground truth we only labeled those proposal rectangles as 'heads' that bounded complete human heads. For the case of people entering the buses, many half-heads appeared in the frames due to queuing of people on bus doors. On scrutiny, we found that most of those heads resulted in false positive identifications in our experiment. However, this is not problematic for the overall approach because the final results rely more strongly on tracking of heads on multiple frames, and the half-heads eventually transform into complete heads in the subsequent video frames. We also provide the details of precision, recall and the f1-scores for our head identification experiment in Table V.

C. Tracking
Our overall approach relies strongly on the tracking method introduced in Section IV-E. Similar to the head identification  Among the labeled tracks, we used around 30% samples for testing and the remaining samples were used for training the classifier. We also followed the same routine for 1,330 tracks for people exiting the buses. The information on the test-train distribution and the labels of the tracks used in our analysis is summarized in Table VI. We empirically selected δ m = 15 and Q = 8 in our experiments. In Fig. 13, we show the ROC curves of the classifiers used for head tracking in our approach. The figure also reports the AUC values for our three-fold experiments. It is easy to observe that our method is able to classify (i.e. track) the trajectories of human heads very accurately for both 'entering' and 'exiting' scenarios. Notice that no significant performance degradation is visible in Fig. 13a for the 'entering' scenario, which was the case in Fig. 12a. This is because tracking is performed over a sequence of frames and the incomplete heads (due to people queues) at the start of tracking eventually become irrelevant for the problem at hands. We also provide summary of the precision, recall and f1-scores of the tracking results in Table VII. The table indicates successful classification by the employed classifier.

D. People Counting
The main objective of our approach is to perform people counting in real-time. We evaluated the people counting performance of our approach using 2,000 test videos from PCDS. We used detection rate '∆' as the metric for evaluations, which is defined as follows.  where N V is the total number of videos in the test data, n i is the number of people passing in the i th video, and n i denotes the estimated number of people in the i th video.
In Table VIII, we report the detection rates of our method for the four different categories of videos introduced in Section III-A. We separately report the results for the 'entering' and 'exiting' scenarios. Based on these results, we can argue that the performance of our approach is acceptable for both scenarios. In PCDS, most of the people entering the buses use the front door. It was observed that due to significant glare from the glass of the front doors, the videos often contained large amount of noise. This generally made people counting at the front doors in the dataset more challenging. Nevertheless, the approach shows reasonable overall performance given the practical real-world conditions of the dataset.
Considering the potential low on-board computational capacity available for our method in the real-world deployment, we used a less powerful 1.7GHz Intel processor with 2GB RAM for evaluating our approach. Figure 14 shows the distribution of the average computational time taken by different components of our method on the used processor for a single frame. The overall average time for processing a single frame is about 22.1ms, amounting to approximately 45 frames per second, which can be considered as real-time performance.

VI. CONCLUSION
This article makes two important contributions to the problem of 'people counting' in real-world scenarios. Firstly, it presents the first large-scale benchmark public dataset for the problem. This dataset contains recorded depth videos, color videos and CSV format files with the labels containing the number of people passing through different scenes of bus doors. The videos account for a large variability in scene illumination, clutter, noise and other factors in the real-world environment, which makes the dataset particularly challenging. Secondly, the article presents a method for real-time people counting in cluttered scenes and evaluates the performance on the proposed dataset. The proposed method utilizes the depth video stream and computes a normalized height image of the scene after removing the background. The height image is essentially a projection of the scene depth directly below the camera, which helps in a clear segmentation of individual objects in the scene. This projection is used to identify heads of individuals in the scene. We utilize a 3D human model and adapt a seed fill method to reliably detect human heads. We also propose a compound feature for height images, that is utilized in our approach for head identification. Once reliably detected, individual human heads are tracked to compute their trajectory which is eventually utilized for people counting. We ascertain the effectiveness of our method by applying it to the proposed dataset. Our benchmark dataset will play a major role in advancing research in the areas of RGB-video, Depth-video and RGBD-video based people counting.  He has also served as a reviewer for these venues. During his PhD, he was recipient of multiple scholarships, and runner-up for the Canon Extreme Imaging Competition in 2015. Currently, he is a Research Fellow at UWA since July 2017. Previously, he has also served on the same position at the Australian National University for one year. His current research interests include people counting and tracking, adversarial machine learning, and hyperspectral image analysis.
HuanSheng Song received the B.S. and M.S. degrees in communication and electronic systems and the Ph.D. degree in information and communication engineering from Xian Jiaotong University, Xian, China, in 1985China, in , 1988, and 1996, respectively. Since 2004, he has been with the Information Engineering Institute, Changan University, Xian, where he became a Professor in 2006 and was nominated as the Dean in 2012. He has been involved in research on intelligent transportation systems for many years and has led a research team to develop a vehicle license plate reader and a traffic event detection system based on videos, which has brought about complete industrialization. His current research interests include image processing and recognition, as well as intelligent transportation systems. He is currently working as a teaching fellow at Changan University, Xian, China, from 2014. His current interests include linear and nonlinear feature extraction methods, pattern recognition, and remote sensing image processing. JianXin Li received received his PhD degree in computer science, from the Swinburne University of Technology, Australia, in 2009. He has been invited to be the PC-chair, proceedings chair, general chair in international conferences and workshops -ADMA2016, WWW2017, DASFAA2018, PC member in SIGMOD2017, CIKM2018, ICDM2018, ICDE2019, and reviewer in top journals like TKDE. His research interests include database query processing & optimization, social network analytics, and traffic network data processing.