## 3 A Prototype System for Pedestrian Positioning
### Stereovision Camera
#### 3.6.2 Error Analysis  
As the object recedes from the camera, the disparity \(x_{d}\) decreases. An error in calculating the shift \(x_{d}\) becomes more significant. Calculating the derivative of \(z\) with respect to \(x_{d}\) in Equation (24) gives Equation (32). The accuracy of determining the distance \(z\) decreases with its squared value. As the stereo-camera is digital, the values of \(x_{L}\), \(x_{R}\) are quantized and so is \(x_{d}\). It means that \(z\) manifests discontinuities as \(x_{d}\) changes to an adjacent quantum. Let \(\epsilon\) denote the size of the pixel in metrical units. For the sake of simplicity, \(x_{d}\) will have units of metres or pixels, whereby the appropriate unit will be clear from the context or mentioned implicitly. Let us assume at this stage that the error of determining \(x_{d}\) can be \(\pm\frac{\epsilon}{2}\) or \(\pm\frac{\mathrm{pixel}}{2}\). Figure 10 exemplifies the effect of such quantization.  
\[\Delta z\approx-\frac{Bf}{x_{d}^{2}}\Delta x_{d}\approx-\frac{z^{2}}{Bf} \Delta x_{d} \tag{32}\]  
The error of determining the disparity does not only come from quantizing \(x_{d}\), in which case, the disparity maps presented in Section 3.8 would be devoid of any artifacts or falsely calculated disparities--see [36] for full clarification.  
Figure 10: An illustration of the quantization effect on estimating the \(z\) coordinate. (**a**) The plot of \(z\) and errors thereof as a function of disparity \(x_{d}\). Dots symbolize the depth \(z\) calculated from \(z=Bf/x_{d}\). Bars symbolizes errors of \(z\) when \(x_{d}\) is encumbered with an error of \(\pm\frac{\epsilon}{2}\) or \(\pm\frac{\mathrm{pixel}}{2}\), (**b**) The absolute error of \(z\) as a function of the depth \(z\).  
The camera used in this work calculates disparity by correlating small blocks (e.g., 7 \(\times\) 7 pixels) and looking for best match. The probability density function of the disparity error is disputable in this case. Let it be the Gaussian distribution, expressed by Equation (33), where \(\Delta x_{d}\) denotes the disparity error.  
\[f_{d}(\Delta x_{d})=\frac{1}{\sqrt{2\pi}\sigma_{d}}\exp\left(-\frac{\Delta x_{ d}^{2}}{2\sigma_{d}^{2}}\right) \tag{33}\]  
The probability density function of \(\Delta z\) can be calculated from Equation (34). The function \(f_{z}\) is conditioned on \(z\), _i.e._, the error \(\Delta z\) depends on the value of \(z\) as mentioned before.  
\[f_{z}(\Delta z|z)=\left|\frac{\partial(\Delta x_{d})}{\partial(\Delta z)} \right|f_{d}(x_{d}) \tag{34}\]  
Equation (32) holds for small \(x_{d}\). The exact value of \(\Delta z\) can be computed from Equation (35). The formula necessary for the transformation is given by Equation (36).  
\[\Delta z =\frac{Bf}{x_{d}+\Delta x_{d}}-z \tag{35}\] \[\frac{\partial(\Delta x_{d})}{\partial(\Delta z)} =-\frac{Bf}{(\Delta z+z)^{2}} \tag{36}\]  
Thus, \(f_{z}\) can be calculated from Equation (37).  
\[f_{z}(\Delta z|z)=\frac{Bf}{(\Delta z+z)^{2}}\frac{1}{\sqrt{2\pi}\sigma_{d}} \exp\left(-\frac{(Bf\Delta z)^{2}}{2\sigma_{d}^{2}(z+\Delta z)^{2}}\right) \tag{37}\]  
The shape of the function \(f_{z}(\Delta z|z)\) for different values of \(z\) is presented in Figure 11. The function is skewed as one should have suspected and decays slower for \(\Delta z\) greater than 0.  
Figure 11: (**a**) A plot of \(f_{z}(\Delta z|z)\) for different values of \(z\). As \(z\) increases the conditional probability density function widens. (**b**) A 3D plot of \(f_{z}\). For illustration purposes, \(\sigma_{d}\) was assumed 6 pix, whereby, to account for the units, \(f\) = 279 pix was substituted.