## 5 Hardware Design of the Proposed Algorithm
### Hardware Architecture of the proposed 3D Shape Reconstruction System
#### 5.3.2 Hardware Architecture of the 3D Reconstruction Algorithm  
As mentioned in the workflow, the algorithm of 3D shape reconstruction takes as inputs the 2D coordinates of laser spot projections from both images and the calibration parameters of both catadioptric systems. In order to take profit of pipeline, two hardware systems are designed to be executed in a parallel way for each image. Each system represents the hardware module of the transformation from air 2D projections to the 3D underwater coordinates of the world point. In Figure 12, we present the successive under sub-blocks of the 3D shape reconstruction module. The 2D/3D transformation algorithm consists on four steps, which are respectively:  
1. Scaramuzza calibration function block;
2. Normalization block;
3. Refraction angle estimation block;
4. Distance measurement and real point coordinates estimation block. Figure 11: Hardware architecture of laser spots extraction modules. (a) Scaramuzza calibration function block  
The first bloc takes as input the 2D extracted coordinates and the system calibration parameters. The estimated polynomial function is applied on the pixel coordinates to generate the coordinates of the ray vector crossing the water as given in the expression (Equation (4)). Figure 13 gives the hardware blocks arranged to perform this task. The pixel coordinates are obtained by dividing the extracted position \"N0\" by the number of lines in the image. A hardware block called \"Black Box\" is inserted to perform the division. This primitive permits the designer to reuse an existing VHDL code that divides two integers of 20 bits and gives as outputs: the quotient \"\(y\)\" representing the \(y\)-axis position and the rest \"\(x\)\" representing the \(x\)-axis position. The calibration function is applied on \"\(\rho\)\" value which is, in fact, the radius value corresponding to the 2D coordinates (\(x_{p}\), \(y_{p}\)): such that \(x_{p}=u-u_{0}\) and \(y_{p}=v-v_{0}\) (red box). The center image coordinates values (\(u_{0}\), \(v_{0}\)) were obtained in the calibration process as described in Section 3.2. A sub-block named \"norme2D\" is used to approximate the square root function. The algorithm processes as follows: we convert the floating number into an integer and a rest. We use a \"Black-box\" block that calls a VHDL code to provide the square root of the integer part \"\(r\)\". We assume then that the square root \"\(\rho\) of the floating number is between \"\(r\)\" and \"\(r+1\)\". At first, we compare \"\(\rho^{2}-r^{2}\)\" and \"\((r+1)^{2}-\rho^{2}\)\" to take the closer value as the first boundary and its half the second one. Successive  
Figure 12: Hardware sub-systems of the 2D/3D transformation. Figure 13: Hardware architecture of the calibration application function bloc. iterations are applied on each chosen boundaries in order to be as close as possible to the exact square root \"\(\rho\)\" of the input floating number. The number of iterations is limited depending on a defined accuracy. The last sub-system is designed to calculate the 3D norm of the ray vector coordinates to be sent to the further processing using the same approach. (b) Normalization block  
The normalization function, given by the expression (Equation (8)), applies the Euclidian 3D norm of the ray vector \"\(r\)\" using as inputs its 3D coordinates. A 32-bit divider is called by the \"Black-box\" element to perform the division and a 32-bit approximation subsystem to perform the square root function. \[\left[ \begin{array}{c}X_{r}^{N}\\ Y_{r}^{N}\\ Y_{r}^{N}\end{array} \right]=\frac{1}{\sqrt{{X_{r}}^{2}+{Y_{r}}^{2}+{Z_{r}}^{2}}} \left[ \begin{array}{c}X_{r}\\ Y_{r}\\ Z_{r}\end{array}