## 3 A Prototype System for Pedestrian Positioning
### 3D Matching Algorithm
The method of analysing \(\mathbf{L_{S}}\) depends on many empirical factors that were verified during many trials. The idea is following:  
1. Reject the part of the depth map \(\mathbf{L_{S}}\) that is below the optical axis of the camera. 2. Divide vertically the upper part of \(\mathbf{L_{S}}\) into \(n_{S}=5\) equal regions \(\mathbf{S}_{j}\), \(j=1\dots n_{S}\)--see Figure 13(a). This forces to compare the depth maps \(L_{S}\) and \(L_{V}\) in different regions, which, to some extend, decorrelate random bias errors. 3. for \(j=1\) to \(n_{S}\)* From the area \(\mathbf{S}_{j}\), pick at random a small square window \(\mathbf{W}_{j}\) of \(W_{W}\) by \(W_{W}\) measurements, where \(W_{W}=24\ \mathrm{pix}\). * Check if \(\mathbf{W}_{j}\) is devoid of artifacts like sun illumination, falsely determined disparity _etc._--_c.f._ Figure 13(b). * Calculate the angle \(\alpha_{j}\) at which the camera sees the object pointed by \(\mathbf{W}_{j}\) (compare with the angle \(\alpha\) in Figure 9). * Calculate the distance \(d_{Sj}\) to an object encompassed by \(\mathbf{W}_{j}\). * Check what the virtual camera sees at the angle \(\alpha_{j}\) from coordinates \([x^{\prime}_{V},y^{\prime}_{V},z^{\prime}_{V},\phi^{\prime}_{V}]^{T}\). Calculate in this direction the distance to the nearest object \(d_{Vj}\). * Compare the distances \(d_{Sj}\) and \(d_{Vj}\) by the distance error function \(f_{Lj}\). * Return the comparison error between \(\mathbf{L_{S}}\) and \(\mathbf{L_{V}}\) as \(f_{L}(\mathbf{L_{S}},\mathbf{L_{V}})=f_{L1}\cdot f_{L2}\cdot f_{L3}\cdot f_{ L4}\cdot f_{L5}\). * **Figure 13. (a)*
* An example of a disparity map \(\mathbf{K}\). Darker colours correspond to smaller values of disparity, thus larger distances. Example windows for each region \(\mathbf{S}_{j}\)\((j=1\ldots 5)\) are denoted by \(\mathbf{W}_{1}\) through \(\mathbf{W}_{5}\). One can see that for windows \(\mathbf{W}_{2}\) and \(\mathbf{W}_{3}\) the depth map was determined correctly and these windows should be compared with corresponding windows in the \(\mathbf{L}_{V}\) depth map. (b) The disparity values \(x_{d}\) for each window \(\mathbf{W}_{j}\) as a function of the \(x_{\mathrm{pix}}\) coordinate in the disparity picture. For \(\mathbf{W}_{1}\), \(\mathbf{W}_{4}\) and \(\mathbf{W}_{5}\) windows, the disparity \(x_{d}\) changes from 0 \(\mathrm{pix}\) to \(\approx\)2 \(\mathrm{pix}\) which corresponds to distances \(\infty\) to \(\approx\)16 m. These windows should be rejected from further analysis. **Ad. 1, 2. *
* The areas \(\mathbf{S}_{j}\) are shown in Figure 13(a). **Ad. 3a. *
* The window \(\mathbf{W}_{j}\) is picked at random from the corresponding area \(\mathbf{S}_{j}\), according to Figure 13(a). **Ad. 3b. ** By trial and error, the empirical measure (40) was proposed to check if the disparity map for \(\mathbf{W}_{j}\) is devoid of artifacts. \(x_{d}^{\max}\) (41) and \(x_{d}^{\min}\) (42) are the maximum and minimum values of disparities for a given window \(\mathbf{W}_{j}\)  
\[k_{j} =\frac{x_{d}^{\max}(\mathbf{W}_{j})-x_{d}^{\min}(\mathbf{W}_{j})}{x_{d}^{ \max}(\mathbf{W}_{j})} \tag{40}\] \[x_{d}^{\max}(\mathbf{W}_{j}) =\max(\mathbf{K}(x_{\mathrm{pix}},y_{\mathrm{pix}}));\forall(x_{ \mathrm{pix}},y_{\mathrm{pix}})\in\mathbf{W}_{j}\] (41) \[x_{d}^{\min}(\mathbf{W}_{j}) =\min(\mathbf{K}(x_{\mathrm{pix}},y_{\mathrm{pix}}));\forall(x_{ \mathrm{pix}},y_{\mathrm{pix}})\in\mathbf{W}_{j} \tag{42}\]  
Window \(\mathbf{W}_{j}\) is stated to be devoid of artifacts if \(k_{j}>k_{\mathrm{thr}}\), where an empirical value of \(k_{\mathrm{thr}}\approx 0.8\). **Ad. 3c. ** The angle \(\alpha_{j}\) at which the stereovision camera sees the object encompassed by the \(\mathbf{W}_{j}\) window can be calculated from Equation (43), where \(x^{(c)}\) denotes the \(x\) coordinate of the centre of \(\mathbf{W}_{j}\). \[\alpha_{j}=\arctan\frac{x_{j}^{(c)}}{f_{\mathrm{pix}}} \tag{43}\]  
**Ad. 3d. ** The distance \(d_{Sj}\) to the object pointed by \(\mathbf{W}_{j}\) can be calculated from Equation (44).