# An Advanced Deep Learning Approach for Multi-Object Counting in Urban Vehicular Environments
## 4 System Architecture
### Object Counting Stage  
The object counting mechanism is depicted in Figure 2. In this stage, the absolute distance between every individual object and the crossing line is estimated for all the  
Figure 3: Object detection accuracy changes if position of the crossing line is changed.  
Figure 2: Workflow of Object Counting Algorithm.  
detected objects. If the distance between an object and the crossing line is less than a threshold \(\tau\), and if the object is not in the tracked objects list, the system starts to track the object using the CSRT tracker. Then, the system increments the objects count and adds the identified object to the tracked objects list. The system continuously updates the state of each tracked object using the CSRT tracker. Once an object is added to the tracked objects list, it is is covered by a new bounding box (green colored box) as illustrated in Figure 3. The system keeps tracking each tracked object until it moves away from the crossing line by a threshold of \(\tau\). If an object moves away from the crossing line by more than the predefined threshold, the system discards it. The study has initialized the threshold value of \(\tau\) by trial and error methods, therefore, the value might fluctuate between different street environments. In our system, the threshold value is 30-pixel values.  
To make sure that each object is counted once, the system tracks objects until they move away from the crossing line by the predefined threshold. The intersection over union (IoU) is defined by the Equation shown in Figure 4. between the YOLO bounding box and the CSRT tracker bounding box is calculated. The IoU value is used to verify whether the system has counted the identified object. If the IoU between newly detected objects and any tracked object in the tracked objects list is less than a margin \(\mu\), then the system starts to track it and increment the object counts.  
Some objects might stand within a distance less than the predefined threshold for more than one frame due to congestion or other reasons, due to which redundancy in counting objects occurs. To overcome this issue, this study integrates IoU concepts in the proposed system. Each counted object must be known to the system so that it is counted once. The only possible way is to track every counted object until it moves away from the crossing line by the threshold value.  
The proposed counting algorithm is efficient over other counting algorithms in terms of less computational power since the system takes less time to track the objects. Instead of tracking the object from the entry and exit points of the frame, the proposed system tracks the object until it moves away from the crossing line by the predefined threshold. Since the probability of tracking failure is less when the tracking region is small, the proposed algorithm has fewer tracking failures over other algorithms that track the object within the entire frame. There won't be many changes in the background environment of the frame if the system tracks the object using a minimum number of frames. If the system  
Figure 4: Intersection over Union.  
continuously removes objects from the tracked objects list, the CSRT tracker will have minimum templates for searching which improves the tracking accuracy. The pseudocode of the proposed object-counting algorithm is shown in Algorithm 1.  
```
Input: frame, crossingLine Output: counts trackedObjects = [] counts = 0, threshold = 20, IoUMin = 0.2 detectedObjects = YOLO(frame) trackedObjects = CSRT.updateStatus(trackedObjects) for object in trackedObjects do displacement = findDistance(object.position, crossingLine) ifabsolute(displacement) \(\geq\) (threshold) then trackedObjects.remove(object) else -
```  
**Algorithm 1**Object Counting Algorithm V2