## 3 Methods
### Wire Spacing Detection Method
#### 3.3.3 Coordinate Extraction  
To accurately identify the wire spacing, the actual location of the wire needs to be obtained. [PERSON] [14] proposed a detection method; this method divides the edge of each wire, and then the least squares method for arc fitting is used. The obtained arc of the center of the circle is used to indicate the location of each wire, but when this method is applied to the wire used in this paper and the results are not ideal. The results of the calculation shown in Figure 13 show that the fitted circles are of different sizes and the center of the circle is not in a straight line, which can produce a large error. Figure 12: ROI image of contour: (**a**) coil image, (**b**) binary image, (**c**) edge image. Figure 13: A recognition method is proposed in [14]. The reason for this misidentification is that the wire used in this experiment was already flattened in the front-end machine before it was wrapped, as shown in Figure 14, and the cross-section changed from a circle to a runway-like shape, so a large deviation was created in this method for coordinate segmentation, and the subsequently fitted circle produced incorrect results. To correct the identification results, for this kind of flattened wire, analysis of its contour shape proposed an intersection of the perpendicular lines method, used to find the true position information of each wire, the method design process is shown in Figure 15:  
The specific steps are:  
1. Contour extraction. Iterate over the contour image to get the coordinates of the wire contour edge. 2. Pixel expansion. The pixel width of the wire is known from the previous calculation, and what needs to be accomplished in this step is to expand the pixels on both sides of the outline of Figure 12c. As shown in Figure 16, the actual number of pixels to be expanded is determined to be one-third of the pixel width of the wire after our tests, and this value is set to \(m\). 3. Determine the peak and valley coordinates. In the above figure, starting from the left endpoint pixel of the expanded contour, we compare the height size of \(m\) neighboring pixel points on each side of this pixel point; if the height of this pixel point is less than or equal to the pixel points on both sides, it will be considered as a wave peak of the contour line, and this pixel point will be kept, traverse to the end of the right side to get all the pixel points that may be wave peaks, change the judgment symbol, and traverse again to get all the wave valley pixel points; the result is expressed as step 1 in Figure 17.  
Figure 14: Wire flattening model: 1-Original line diameter; 2-Roller spacing; 3-New line width; 4-New line height. Figure 15: The design process of the intersection of the perpendicular lines method. For a location where the crest or trough may not be a single point, as judged in step 1 of Figure 17, with multiple points, this case takes the median point of all points as the extreme value point and uses the bubble sorting method to simplify the trough coordinates as an example, with the following simplified steps:  
1. Create two empty sets, and store all the trough coordinate points in the previous step into the first set. 2. Select the first coordinate point in the collection as the target value. 3. Starting from the second coordinate, compare the pixel distance from the first coordinate point in turn. As long as the distance is less than \(m\) pixels, these coordinate points are considered adjacent troughs, and the series of trough coordinates are put into another empty set; calculate the median point of these points, and denote the length of this set as \(L\). 4. Delete \(L\) coordinates from the beginning of the first set, and return to the second step until the length of the first set is 0. 5. Each cycle will get a coordinate, and this step of processing yields a combination of all the extreme and minimal values from step 2 in Figure 17.
4. Shape judgment.