## 2 Materials and Methods
### vePOD Faster R-CNN: Vehicle-Edge Cooperative Object Detection for Privacy Preservation
#### 2.5.1 Secure ROI Pooling  
A region of interest (ROI) pooling generates fixed-size feature maps for each bounding box so that the detection network can classify the object in each bounding box.  
The following operations are performed by the ROI pooling: (1) extracting region proposal specific feature maps; (2) dividing the extracted feature maps into a fixed number of patches based on the shape of the expected output feature map; and (3) selecting the maximum-valued element from each patch.  
The secure ROI pooling takes feature-level secret shares and region proposals as its input from a vehicle. The operation (3) in the ROI pooling, i.e., selecting the maximum-valued element from each patch, involves non-linear computation (i.e., maximum). We develop a secure function to make it work correctly on a secret share.  
Our approach is to compare the relative difference between secrets. For example, for two secrets V and D. which are partitioned into secret shares \((V_{1},V_{2})\) and \((D_{1},D_{2})\)  
Figure 2: Structure and major components of vePOD Faster R-CNN. Blue blocks represent the operations performed on a vehicle and green blocks are those executed on an edge server; the yellow block can be done on the same or a different vehicle.  
where \(V=V_{1}+V_{2}\) and \(D=D_{1}+D_{2}\), the secure function aims to determine whether \(V\) is greater than \(D\) without a reconstruction of the secrets. To achieve this, it calculates the difference \(\eta=V-D=(V_{1}+V_{2})-(D_{1}+D_{2})=(V_{1}-D_{1})+(V_{2}-D_{2})\), and checks if \(\eta\) is greater than zero. For each extracted feature-map patch, the secure function calculates \(\eta\) for each pair of elements. By collecting those \(\eta\)'s from edge servers, we can know the relative difference of each secret, from which the maximum-valued element in secret shares can be identified.  
Algorithm 1 sketches the secure function for ROI pooling. In the secure ROI pooling, each patch is flattened to a one-dimensional array with size \(L_{ij}=width(P_{ij})*height(P_{ij})\). Then, it creates a table \(T_{ij}\) with size \((L_{ij})^{2}\) and computes \(T_{ijmn}=P_{ij}[m]-P_{ij}[n]\). Table \(\{T_{ij}\}\) stores the relative difference \(\eta\) of \(P_{ij}[m]\) and \(P_{ij}[n]\) on an edge server that has the \(i_{th}\) secret share and the \(j_{th}\) patch. Edge servers \(E_{i}\) and \(E_{q}\) exchange \(T_{ij}\), \(T_{qj}\) through a trusted server and calculate \(T_{j}=T_{ij}+T_{qj}\). \(T_{j}[m][n]\) is the relative difference of the feature map \(F\) on patch \(j\), i.e., \(T_{j}[m][n]=P_{j}[m]-P_{j}[n]\). If all the values in row \(k\) are positive, then the corresponding value in \(P_{j}\) is greater than the others.  
As the number of secret shares \(n\) increases, the secure ROI pooling scales well as \(T_{j}=\sum_{n=1}^{N}T_{nj}\).  
```
1:for each region proposal do
2: Scale the proposal by a scaling factor: \(SP_{i}=P_{i}*\gamma\)
3:endfor
4: Extract region-based features \(F\) with the scaled proposal's coordinates \(\mu,\upsilon\)
5: Calculate a width stride = width(\(\kappa\))/\(w\) and a height stride = height(\(\kappa\))/\(h\)
6: Divide \(\kappa\) into patches \(P_{ij}\) based on the width stride and height stride
7:for each patch \(P_{ij}\)do
8: Flatten \(P_{ij}\), the size of path \(L_{ij}=width(P_{ij})*height(P_{ij})\)
9: Create relative difference table T with a size \(L_{ij}*L_{ij}\)
10:\(T_{ijmn}=P_{ij}[m]-P_{ij}[n]\)
11:\(E_{i}\) shares relative difference table \(T_{ij}\) with \(E_{q}\), collect relative difference table \(T_{qj}\), calculate \(T_{j}=T_{ij}+T_{qj}\)
12:for each row in \(T\)do
13:if all values in the row are greater than 0 then
14: return the index of the row, \(k\)
15:endif
16:endfor
17: return \(P_{ij}[k]\)
18:endfor
```  
**Algorithm 1** Secure Function for ROI Pooling