# Repair Method and Mueganos Structure Applied to the Nesting Problem in Finite Materials
## 2 Methodology
### Calculation of Waste in Metric Values  
Material and item images are scaled from the original frame size using a factor scale for reducing the material and the items. The pixel coordinates are transformed into world coordinates for a real-world application. This process implies a camera calibration method [35] and direct linear transformation (DLT) [36]. Firstly, the camera is calibrated using a set of C chessboard images from different perspectives. A checkerboard image is a grid with alternating black and white squares. The grid is used to show the size of the squares in metric and pixel dimensions. The camera calibration provides the intrinsic parameters (Equation (1)), such as focal length and optical center, and distortion parameters (Equation (2)), such as the radial and tangential distortion coefficients. The camera calibration helps to reduce the distortion in the images. Table 1 shows the variables corresponding to this section. \[K= \begin{bmatrix}f_{x}&0&c_{x}\\ 0&f_{y}&c_{y}\\ 0&0&1\end{bmatrix} , \tag{1}\]  
\[d= \begin{bmatrix}k_{1}&k_{2}&p_{1}&p_{2}&k_{3}\end{bmatrix} . \tag{2}\]  
Once the camera parameters and distortion coefficients are obtained, the camera is fixed to a certain distance from the material. This arrangement makes it possible to obtain the transformation from 3D coordinates to 2D coordinates. This mapping is represented as  
\[\mathbf{x}_{i}=M\mathbf{X}_{i}, \tag{3}\] \begin{table}
\begin{tabular}{c c} \hline \hline
**Variable** & **Description** \\ \hline \(C\) & Number of chessboard images \\ \(f_{x},f_{y}\) & Focal length for axis \(x\) and \(y\), respectively \\ \(c_{x},c_{y}\) & Optical center \\ \(k_{1},k_{2},k_{3}\) & Radial distortion \\ \(p_{1},p_{2}\) & Tangential distortion \\ \(K\) & Calibration matrix \\ \(d\) & Distortion vector \\ \(\mathbf{x_{i}}\) & \(i\)-th 2D coordinate (pixel) \\ \(u,v\) & Pixel coordinates for axis \(x\) and \(y\), respectively \\ \(M\) & Projection matrix \\ \(m_{i}\) & \(i\)-th values from projection matrix \\ \(\mathbf{X_{i}}\) & \(i\)-th 3D coordinate (world) \\ \(X_{i},Y_{i},Z_{i}\) & World coordinates for axis \(x\), \(y\) and \(z\), respectively \\ \(waste_{p}\) & Waste of the material in pixels \\ \(waste_{m}\) & Waste of the material in m\({}^{2}\) \\ \(area_{p}\) & Area of the rectangle around the material in pixels \\ \(area_{m}\) & Area of the rectangle around the material in m\({}^{2}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Calibration variables resume. Figure 2: Binarized material and items. (**a**) Sample cowhide material to accommodate items. (**b**–**d**) Footwear items nesting in the sample material. where \(M\in\mathbb{R}^{3\times 4}\) represents the projection matrix, \(\mathbf{x}_{i}=[u_{i},v_{i},1]\) is the \(i\)-th 2D coordinate, and \(\mathbf{X}_{i}=[X_{i},Y_{i},Z_{i},1]\) represents the \(i\)-th 3D coordinate for all \(i=1,2,\ldots,n\), and \(n\) is the number of necessary points. A chessboard is placed over the material, and the arrangement is captured. The arrangement is shown in Figure 3. Each corner of the physical chessboard is matched with the corresponding pixels. The projection matrix used to transform the 2D coordinates to 3D coordinates is calculated as  
\[ \begin{bmatrix}X_{1}&Y_{1}&Z_{1}&1&0&0&0&0&-u_{1}X_{1}&-u_{1}Y_{1}&-u_{1}Z_{1}& -u_{1}\\ 0&0&0&X_{1}&Y_{1}&Z_{1}&1&-v_{1}X_{1}&-v_{1}Y_{1}&-v_{1}Z_{1}&-v_{1}\\ \vdots\\ X_{n}&Y_{n}&Z_{n}&1&0&0&0&0&-u_{n}X_{n}&-u_{n}Y_{n}&-u_{n}Z_{n}&-u_{n}\\ 0&0&0&X_{n}&Y_{n}&Z_{n}&1&-v_{n}X_{n}&-v_{n}Y_{n}&-v_{n}Z_{n}&-v_{n}\end{bmatrix} \begin{bmatrix}m_{11}\\ m_{12}\\ \vdots\\ m_{33}\\ m_{34}\end{bmatrix} =0. \tag{4}\]  
Lastly, the \(m_{i}\) parameters are obtained using the SVD method. Equation (4) is obtained from Equation (3). The waste is calculated by selecting a rectangle around the material. The area of the rectangle is computed in pixels and meters. The ratio \(r\)of waste in pixels and the pixel area are equivalent to meters and metric area, as shown in Equation (5).