# A Cascaded Ensemble of Sparse-and-Dense Dictionaries for Vehicle Detection
## 4 Detection with CESDD
### Sliding-Window Classification  
On receiving an input image, an image pyramid is built by up-sampling and down-sampling the image to multiple scale levels. Sliding-window scan process is performed on this pyramid by moving windows of proper aspect ratios (window width over window height) throughout all positions on each image plane in the pyramid. In the case of vehicle detection in driver view on streets, like the case of the KITTI2017 dataset, vehicle bounding boxes' aspect ratios vary in a limited range depending on the vehicle orientations, from the large aspect ratio of side view to a small aspect ratio of front view, as is shown in Figure 4. This indicates that one single aspect ratio for scan window is not enough to capture vehicles of various orientations. Thus, we adopted two distinct aspect ratios for scan windows: one close to the ratios of side views, and another one close to front views; these two aspect ratio values were censensed from the KITTI2017 training set label information. Window patches obtained using these aspect ratios are then resized to a uniform size, for the convenience of subsequent classification; these window patches are further processed into proper features as described in Section 3.2. CESDD-based classification is then carried out for all processed window patches; comprehensive description on classification with CESDD is detailed in Section 3.3, and the cooperation of CESDD with downstream AdaBoost process is described in Lines 5\(\sim\)13 in Algorithm 2. After window classification, initial detections are obtained.  
Figure 7: Illustration of downstream AdaBoost classification process in CESDD. An input window patch is initially represented by Level 1 SDDs and classified by corresponding weak classifiers to generate initial classification, and then, based on the initial classification result, selectively represented by SDDs in Level 2 and accordingly selectively classified by the rest weak classifiers; at last, classifications of activated weak classifiers are aggregated by learned weights to produce final classification.  
```
input : Learned CESDD-based window classifier; input image img output : Detections BBoxes (bounding boxes with corresponding confidence scores) initialize :BBoxes = [] // Pre-processing
1 Build image pyramid \(Pyr\) by resizing img into multiple scales; // Sliding-window scan and classification for each level L in Pyr do
2 for each window position \(p\) in image plane of level L do
3 Extract features for current window (anchored at \(p\)) as d; // Window-wise classification with CESDD and downstream AdaBoost Coding for d over SDDs in Level 1 ensemble and evaluate corresponding reconstruction residues \(\{\mathbf{r}_{1}\}\);
4 Perform Level 1 AdaBoost classification using \(WCs_{1}\) with corresponding SDD residues as inputs and generate initial classification \(cls_{\text{init}}\);
5 ifd is initially classified as positive according to \(cls_{\text{init}}\)then
6 Coding over Level 2 background category SDDs to obtain corresponding reconstruction residues \(\{\mathbf{r}_{2}\}\);
7 Perform Level 2 AdaBoost classification using \(WCs_{2}\) with corresponding SDD residues as inputs and aggregate with classifications of \(WCs_{1}\) to generate \(cls_{\text{final}}\);
8
9 else
10 Coding over Level 2 vehicle category SDDs to obtain corresponding reconstruction residues \(\{\mathbf{r}_{3}\}\);
11 Perform Level 2 AdaBoost classification using \(WCs_{3}\) with corresponding SDD residues as inputs and aggregate with classifications of \(WCs_{1}\) to generate \(cls_{\text{final}}\);
12
13 end if
14 ifd is classified as vehicle according to \(cls_{\text{final}}\)then
15 Store current detection information (bounding box and corresponding confidence score) into BBoxes;
16
17 end if
18
19 end for
20
21 end for // Post processing Perform mean-shift-based NMS to refine detections BBoxes;
```  
**Algorithm 2**Algorithm of vehicle detection with CESDD