## 2 Identification of Sheet Metal Parts  
### Positioning and Structure Extraction of Two-Dimensional Laser-Generated Code  
The two-dimensional laser-generated code contains the sheet metal part's identity information. However, the placement of the part affects the image of the two-dimensional laser-generated code, and the contrast varies from placement to placement. As shown in the low-contrast image in Figure 1, the high-band edges of the two-dimensional code structure are prone to weakening and blurring, resulting in positioning failure and unclear information extraction. As a result, to improve the accuracy of two-dimensional code decoding, this paper proposes a two-dimensional code localization and structure extraction method. First, the morphological closed operation is used to coarsely locate the two-dimensional code region according to the law of two-dimensional code arrangement. Second, the contour topology of the position detection pattern is used for fine localization. Finally, the structure of the QR code is extracted by segmenting the encoding module using the projection method. The morphological closure operation expands and then contracts the image, which effectively excludes the QR code's internal voids. This operation effectively reduces the complexity of the features and achieves encoding structure homogeneity. The image is then binarized. The four-linked two-pass method labels the set of all connected domains. Some noise points are removed because they are too small in area and lack descriptive shape power. The two-dimensional code position is initially determined based on the height-to-width ratio of the smallest outer rectangle of the connected domains. The position detection patterns serve as the foundation for precise positioning of the two-dimensional code, and three position detection patterns can be used to calculate the position and offset angle of the two-dimensional code. The patterns have an obvious multilayer nested contour topology. One pattern's contours can be identified as the external or internal boundary of the hole. These can be represented, like in Figure 2, by the labels \(cX\) and \(hX\), where \(X\) stands for a number, \(c\) for \"contour\", and \(h\) for \"hole\" or inner contour. A contour tree can be constructed using this label. In Figure 2, for instance, \(c0\) represents the contour of the root node, \(h00\) represents the child node of \(c0\), and \(h00\) also contains the new child node \(c000\). The contour tree of the pattern can be used to determine the topology of  
Figure 1: Image of laser-generated QR code: (**a**) image of a normal two-dimensional laser-generated code and (**b**) image of a low-contrast two-dimensional laser-generated code. the contour. Because this feature has a high level of anti-interference, the topology, shape, and statistical moments of the contours can be used to locate the position detection patterns. The specific judgment conditions are as follows:  
\[\left\{ \begin{array}{l}W_{\text{c0}}/H_{\text{c0}}=W_{h00}/H_{h00}=W_{\text{c00 }}/H_{h000}\approx 1\\ L_{\text{c000}}:L_{h00}:L_{\text{c0}}\approx 3:4:5\\ m_{\text{c0}}(x,y)\approx m_{h00}(x,y)\approx m_{\text{c000}}(x,y)\end{array} \right. \tag{1}\]  
As shown in Equation (1), \(W\) and \(H\) represent the length and width of the contour's minimum external rectangle, \(L\) represents the contour's length, and m represents the contour's center. By using Equation (1), it is possible to locate three position detection patterns. Figure 3 illustrates the location of the smallest external rectangle and the center coordinates \(m(x,y)\) of the three location detection graphs of the QR code used in Equation (1). In Figure 3, \(m_{i}\) is the position detection pattern's center coordinates, and \(p_{i}\) is the QR code's four vertices. The center point coordinates \(m_{1}\) of position 1 and \(m_{2}\) of position 2 are used to calculate the equation of the line \(l_{m_{1}m_{2}}:ax+by+c=0\).