## 3 Methodology
### Object Re-Identification
#### Spatial Location Graph  
For every frame with multiple instance objects, the spatial location graph is estimated based upon the pairwise distance between the objects in the frame, using Equation (9). Let \(G_{i}(O,D)\) and \(G_{j}(O,D)\) be the graphs with objects as nodes and their distances as edges for two similar frames \(i\) and \(j\). The objects in frame \(j\) are matched with the objects in \(i\), based on comparing the distances between the objects in \(j\) and \(i\) such that the difference between the distances is always minimal. For instance, if frame \(i\) has 4 objects, \(O_{11},O_{22},O_{33},O_{44}\), of which \(O_{i1}\) and \(O_{i2}\) belong to the same class, and \(D_{i}^{12},D_{i}^{13}\) denotes the distance between objects, then to re-identify objects \(O_{1}\) in frame \(j\), the sub-graph distances of \(G_{i}[O_{1}^{{}^{\prime}}]\) and \(G_{i}[O_{2}^{{}^{\prime}}]\) are compared with \(G_{i}[O_{1}^{{}^{\prime}}]\). \(O_{j1}\) is deduced to be the same as the object in \(i\) for which the difference between distances is minimal. The overall object re-ID algorithm is shown in Algorithm 2 while the complete re-ID pipeline is shown in Figure 11.  
Figure 10: Comparison of frame 260/70 with its estimated depth. Using the depth and distance measures, the actual distance between the two objects can be estimated.  
Figure 9: Spatial location graph generated for a frame using the centre of the bounding box coordinates and Euclidean distance between them.  
```
Input: Objects_list per frame, shot boundary and LSU similarity Output: Object IDs per frame
1 shots = [] forobject = object_list[0]:object_list[len(object_list)]do
2 ifcount(objects) in all_frames <= 1 then
3 single_instance.append(object)
4
5 else
6 multi_instance.append(object)
7 forobject = single_instance[0]:single_instance[len(single_instance)]do
8 id = 1
9 for i = 1:classdo
10 for i = 1:ndo
11 if i==0 then
12\(object_{id}\) = id
13\(id\) = \(id+1\)
14
15 else
16 if\(similarity(frame_{n},1:frame_{n-1}>\textit{threshold},\)then
17 Let frame \(a\) be the frame most similar to frame \(n\)\(object_{id}=O_{id}^{a}\)
18 else
19\(object_{id}\) = id
20\(id\) = \(id+1\)
21
22
23 forobject = multiple_instance[0]:multiple_instance[len(multiple_instance)]do
24 id = 1
25 for i = 1:classdo
26 for i = 1:ndo
27 if i==0 then
28\(object_{id}\) = id
29\(id\) = id + 1
30
31 else
32 if\(similarity(frame_{n},1:frame_{n-1}>\textit{threshold},\)then
33 Let frame \(a\) be the frame most similar to frame \(n\)\(object\_list=graph\_compare(G_{n}[O_{class}^{\prime}],\)\(G_{a}[O_{class}^{\prime}])\) forobject_id in object_listdo
34\(object_{id}\) = object_id
35 else
36\(object_{id}\) = id
37\(id\) = id + 1
```  
**Algorithm 2**Multi-object re-ID.  
```
Input: Objects_list per frame, shot boundary and LSU similarity Output: Object IDs per frame
1 shots = [] forobject = object_list[0]:object_list[len(object_list)]do
2 ifcount(objects) in all_frames <= 1 then
3 single_instance.append(object)
4 else
5 multi_instance.append(object)
6
7 forobject = single_instance[0]:single_instance[len(single_instance)]do
8 id = 1
9 for i = 1:classdo
10 if\(i==0\)then
11\(object_{id}\) = id
12
13 else
14 if\(similarity(frame_{n},1:frame_{n-1}>\textit{threshold},\)then
15\(object_{id}\) = id
16 else
17\(object_{id}\) = id
18
19 else
20\(object_{id}\) = id
21
22
23 else
24\(object_{id}\) = id
25
26
27
28
29
30
31 end for
```  
**Algorithm 3**Multi-object re-ID.