# A Room Monitoring System Using Deep Learning and Perspective Correction Techniques
## The Model of Room Monitoring System
### Proposed Person Detection Scheme
#### 3.3.3 Merging of the Bounding Boxes
The function \(calculate\_iou()\) is used to calculate the IoU of two boxes, as shown in Equation (4). 5. Lines (13-17) show that if IoU value of the coupled neighboring bounding boxes is greater than the IoU threshold, these two coupled neighboring bounding boxes can be merged to create a new bounding box. \(list\_new\_box\) adds the new bounding box and removes the coupled neighboring bounding boxes. 6. Lines (18-20) determine that the complete bounding boxes in the overlapping areas and their IoU values are less than the IoU threshold. \(list\_new\_box\) removes these bounding boxes. This approach reduces false-positive detection. Finally, the program returns a list of new bounding boxes of tile images. After collection of the intermediate results, the bounding boxes of intermediate results and the full-frame must be merged to obtain the final results. The steps are detailed in Algorithm 2. ```
1.Input:\(list\_tile\_box=\{box_{i}(y_{1},x_{1},y_{2},x_{2}),i=[0,m-1]\}\)
2.\(list\_full\_frame=\{box_{i}(y_{1},x_{1},y_{2},x_{2}),i=[0,k-1]\}\)
3.\(m\): number of boxes of tiles in intermediate results \(k\): number of boxes of full-frame
4.Output:\(list\_final\_box=\{box_{i}(y_{1},x_{1},y_{2},x_{2}),i=[0,t-1]\}\)
5.\(t\): number of final boxes
6. setThreshold_iou
7. setThreshold_beta
8.\(status\_tile\_box[]\)
9.\(status\_full\_frame=[]\)
10.\(list\_final\_box[]\)
11.for\((i,box)\) in enumerate(\(list\_tile\_box\)):
12.\(status\_tile\_box[i]\)=True
13.for\((i,box)\) in enumerate(\(list\_full\_frame\)):
14.\(status\_full\_frame[i]\)=True
15.\(newBox\)=[]
16.whilethreshold_beta > 0:
17.for\((i,tileBox)\) in enumerate(\(list\_tile\_box\)):
18.if\(status\_tile\_box[i]\)=False: continue
19.\(iou=0\)
20.\(bta=0\)
21.\(maxBox=[]\)
22.for\((j,fullBox)\) in enumerate(\(list\_full\_frame\)):
23.if\(status\_full\_frame[j]\)==False: continue
24.if\(iou<calculate\_iou(tileBox,fullBox)\):
25.\(iou=calculate\_iou(tileBox,fullBox)\)
26.\(maxBox\_toLl=fullBox\)
27.\(indexBox\_toLl=j\)
28.if\(beta<calculate\_beta(tileBox,fullBox)\):
29.\(bta=calculate\_beta(tileBox,fullBox)\)
30.\(maxBox\_BTA=fullBox\)
31.\(indexBox\_BTA=j\)
32.if\((iou>=threshold\_iou)\):
33.\(newBox=union(tileBox,maxBox\_toU)\)
34.\(list\_final\_box.append(newBox)\)
35.\(status\_tile\_box[i]\)=False
36.\(status\_full\_frame[index\_loU]\)= False
37.\(\text{{\it}}(bta>=threshold\_beta)\)
38.\(newBox=union(tileBox,maxBox\_BTA)\)
39.\(list\_final\_box.append(newBox)\)
40.\(status\_tile\_box[i]\)=False: continue
41.\(iou=0\)
42.for\((j,fullBox)\) in enumerate(\(list\_full\_frame\)):
43.if\(status\_full\_frame[j]\)==False: continue
44.\(iou=calculate\_iou(tileBox,fullBox)\)
45.if\(iou=0\):
46.\(list\_final\_box.append(tileBox)\)
47.\(status\_tile\_box[i]\)=False
48.for\((i,fullBox)\) in enumerate(\(list\_full\_frame\)):
49.\(status\_full\_frame[i]\)==False: continue
50.\(iou=0\)
51.for\((j,tileBox)\) in enumerate(\(list\_tile\_box\)):
52.for\((j,tileBox)\) in enumerate(\(list\_tile\_box\)):
53.if\(status\_tile\_box[j]\)==False: continue
54.\(iou=calculate\_iou(tileBox,fullBox)\)
55.if\(iou\) l = 0:
56.if\(iou=0\):
57.\(list\_final\_box.append(fullBox)\)
58.\(status\_full\_frame[i]\)=False
59.\(threshold\_beta=threshold\_beta-\alpha\)
60.return\(list\_final\_box\)
```  
**Algorithm 2** Merging the bounding boxes of intermediate results and full-frame1. Lines (1, 2) contain the input and output information of the algorithm. The input includes \(list\_tile\_box\) and \(list\_full\_frame\). \(list\_tile\_box\) contains the bounding boxes of intermediate results, and \(list\_full\_frame\) contains the bounding boxes of the full-frame. \(list\_final\_box\) is the result returned by the algorithm. It includes the final bounding boxes. 2. The parameters are set using Lines (3-7). _threshold_iou_ and _threshold_bta_ are the predefined thresholds of IoU and BTA, respectively, that are used to consider whether two neighboring bounding boxes are merged. 3. Lines (8-11) set the initial status of all boxes.