Optical detection method for alignment precision of double-layer circuit board and related equipment

By using deep learning semantic segmentation and perspective distortion analysis, the alignment accuracy problem of double-layer circuit boards under non-parallel placement and mark occlusion conditions was solved, achieving high-precision 3D alignment detection and improving quality control in the circuit board manufacturing process.

CN121962062APending Publication Date: 2026-05-01SHENZHEN XINRUIXIN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN XINRUIXIN ELECTRONICS CO LTD
Filing Date
2026-01-15
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing methods for aligning and detecting double-layer circuit boards cannot accurately identify the position of the markers and correct spatial orientation errors when the reference markers are obscured or damaged and the boards are not placed parallel, resulting in distorted alignment accuracy assessments.

Method used

A deep learning semantic segmentation network is used to segment the transmitted light image and reflected light image of a double-layer circuit board, extract the upper and lower layer labeled segmentation maps, and calculate the tilt angle and vertical height offset by analyzing perspective distortion features. Combined with centroid coordinate perspective correction, the horizontal offset is calculated, and it is determined whether the synthesized offset is less than a preset threshold.

Benefits of technology

Under complex background and non-parallel placement conditions, high-precision three-dimensional spatial alignment error assessment was achieved, improving the robustness and accuracy of alignment detection and meeting the quality control requirements of high-density multilayer circuit board manufacturing and flexible circuit board assembly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121962062A_ABST
    Figure CN121962062A_ABST
Patent Text Reader

Abstract

The invention provides an optical detection method for alignment precision of a double-layer circuit board and related equipment, and the method comprises the steps: obtaining a transmitted light image and a reflected light image of the double-layer circuit board, and carrying out the semantic segmentation of the transmitted light image and the reflected light image, thereby obtaining a superposition segmentation image and a reference segmentation image; based on the upper layer mark contour information of the reference segmentation image, separating an upper layer mark and a lower layer mark from the superposed segmentation image, and calculating the inclination angle of the plate according to the perspective distortion characteristics of the upper layer mark contour; calculating the vertical height offset by combining the area ratio of the upper and lower layer marks and the inclination angle; extracting upper and lower layer mark centroid coordinates, performing perspective correction according to the inclination angle, and then calculating a horizontal offset; and judging whether a synthetic module value of the horizontal offset and the vertical height offset is smaller than a preset threshold value or not, and outputting a detection result. According to the method, mark identification under a complex background is realized through semantic segmentation, attitude correction is realized through perspective distortion analysis and three-dimensional offset calculation, and the accuracy of alignment detection of the double-layer circuit board is improved.
Need to check novelty before this filing date? Find Prior Art

Description

An optical inspection method and related equipment for the alignment accuracy of double-layer circuit boards Technical Field

[0001] This invention relates to the field of optical inspection technology, and in particular to an optical inspection method and related equipment for the alignment accuracy of double-layer circuit boards. Background Technology

[0002] As circuit board manufacturing processes evolve towards higher density and multilayer structures, alignment accuracy inspection of double-layer circuit boards has become a crucial step in ensuring product quality. Existing optical inspection methods typically employ dual-light source imaging technology, acquiring reference mark images of the upper and lower layers using both transmitted and reflected light sources. Image processing algorithms are then used to extract the center coordinates of the mark points and calculate the alignment deviation. These methods generally assume ideal inspection conditions: clear edges of the reference mark points, sufficient contrast, and strict parallel placement of the upper and lower layers. Under these conditions, the system can accurately identify the mark points using traditional image processing techniques such as fixed threshold segmentation, edge detection, or Hough transform, and then calculate the alignment offset based on two-dimensional plane coordinates, meeting conventional production requirements.

[0003] However, actual production environment testing conditions often deviate from ideal conditions. On the one hand, during processes such as exposure and etching, reference markers are easily affected by copper foil residue, solder resist contamination, or oxide film coverage, leading to weakened grayscale differences between the marked area and the background, blurred edges, and even partial occlusion. Traditional segmentation algorithms based on fixed thresholds are prone to undersegmentation or oversegmentation under such complex background interference, failing to reliably extract complete marker contours. On the other hand, during the assembly and positioning of double-layer boards, the upper board often has a tilt angle of 0.5° to 2° relative to the lower board due to factors such as the weight of the board itself, fixture accuracy errors, and substrate warping. This causes perspective distortion of the reference markers during transmitted light imaging, with circular markers appearing as ellipses. Consequently, the offset calculated directly based on two-dimensional plane coordinates includes systematic errors introduced by the tilt. Existing methods do not consider spatial position deviations in the vertical direction, only evaluating alignment accuracy in the horizontal plane. When the board has warping in the Z-axis direction, the detection results deviate significantly from the actual alignment state. Therefore, how to achieve high-precision and robust alignment error detection under the non-ideal conditions of degraded reference mark image quality and non-parallel placement of double-layer plates has become an urgent technical challenge. Summary of the Invention

[0004] The main objective of this invention is to solve the technical problem that existing double-layer circuit board alignment detection methods cannot accurately identify the position of the markers and correct spatial orientation errors when the reference markers are obscured or damaged and the boards are not placed in parallel, resulting in distorted alignment accuracy assessment.

[0005] The first aspect of this invention provides an optical detection method for the alignment accuracy of a double-layer circuit board. The method includes: acquiring a transmitted light image and a reflected light image of the double-layer circuit board, and performing semantic segmentation on the transmitted light image and the reflected light image respectively to obtain a superimposed segmentation image and a reference segmentation image; based on the contour information of the upper layer marker in the reference segmentation image, separating an upper layer marker segmentation image and a lower layer marker segmentation image from the superimposed segmentation image, and calculating the tilt angle of the upper layer board relative to the lower layer board based on the perspective distortion features of the marker contour in the upper layer marker segmentation image; calculating the vertical height offset of the upper layer board according to the area ratio of the upper layer marker segmentation image and the lower layer marker segmentation image and the tilt angle; extracting the centroid coordinates of the upper layer marker segmentation image and the lower layer marker segmentation image respectively, and calculating the centroid coordinate difference after perspective correction based on the tilt angle to obtain a horizontal offset; determining whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and outputting the detection result.

[0006] A second aspect of the present invention provides an optical inspection device for the alignment accuracy of a double-layer circuit board. The device comprises: a semantic segmentation module for acquiring transmitted light and reflected light images of the double-layer circuit board, and performing semantic segmentation on the transmitted light and reflected light images respectively to obtain a superimposed segmentation image and a reference segmentation image; and a separation and correction module for separating an upper-layer marker segmentation image and a lower-layer marker segmentation image from the superimposed segmentation image based on the contour information of the upper-layer marker in the reference segmentation image, and calculating the upper-layer marker segmentation image based on the perspective distortion features of the marker contour in the upper-layer marker segmentation image. The tilt angle of the upper layer relative to the lower layer; the vertical offset calculation module is used to calculate the vertical height offset of the upper layer based on the area ratio of the upper layer marking segmentation image to the lower layer marking segmentation image and the tilt angle; the horizontal offset calculation module is used to extract the centroid coordinates of the upper layer marking segmentation image and the lower layer marking segmentation image respectively, and calculate the difference of the centroid coordinates after perspective correction based on the tilt angle to obtain the horizontal offset; the result determination module is used to determine whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and output the detection result.

[0007] The aforementioned optical inspection method and related equipment for the alignment accuracy of double-layer circuit boards acquire transmitted light and reflected light images of the double-layer circuit boards, and perform semantic segmentation on the transmitted light and reflected light images respectively to obtain a superimposed segmentation image and a reference segmentation image. Based on the contour information of the upper layer mark in the reference segmentation image, the upper layer mark segmentation image and the lower layer mark segmentation image are separated from the superimposed segmentation image. Based on the perspective distortion features of the mark contour in the upper layer mark segmentation image, the tilt angle of the upper layer board relative to the lower layer board is calculated. According to the area ratio of the upper layer mark segmentation image and the lower layer mark segmentation image and the tilt angle, the vertical height offset of the upper layer board is calculated. The centroid coordinates of the upper layer mark segmentation image and the lower layer mark segmentation image are extracted respectively. After perspective correction of the extracted centroid coordinates according to the tilt angle, the difference of the centroid coordinates is calculated to obtain the horizontal offset. It is determined whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and the detection result is output. This application introduces a deep learning semantic segmentation network to replace the traditional fixed threshold algorithm, accurately extracting the marker outline in complex backgrounds such as blurred marker edges, copper foil residue, or contamination; by analyzing perspective distortion features to calculate the tilt angle, and combining area ratio and centroid coordinate perspective correction, it achieves accurate assessment of alignment error in three-dimensional space, solving the technical problem of distortion in alignment accuracy assessment when the reference marker is obscured or contaminated and the plates are not placed parallel.

[0008] Beneficial Effects: This invention's technical solution, through a dual-light source semantic segmentation detection architecture, effectively suppresses complex background interference such as blurred reference mark edges, copper foil residue, and solder mask contamination, significantly improving the robustness and accuracy of visual inspection of double-layer circuit board alignment. Compared to traditional fixed threshold segmentation methods, this solution uses a deep learning network to automatically extract semantic features, ensuring that the detection results are unaffected by marker quality degradation and background noise. By extracting perspective distortion features to calculate the tilt angle, and combining area ratio and centroid coordinate perspective correction, this solution can accurately assess three-dimensional alignment errors, providing reliable quality assurance for visual inspection applications such as high-density multilayer circuit board manufacturing and flexible circuit board assembly. High-precision three-dimensional alignment detection ensures accurate alignment of upper and lower layer circuits under non-parallel placement conditions, meeting the stringent positional accuracy requirements of precision electronic manufacturing, and significantly improving the quality control level and product qualification rate in the mass production process of circuit boards.

[0009] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0010] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0011] Figure 1 is a schematic diagram of the first embodiment of the optical detection method for the alignment accuracy of a double-layer circuit board in this invention; Figure 2 is a schematic diagram of the second embodiment of the optical detection method for the alignment accuracy of a double-layer circuit board in this invention; Figure 3 is a schematic diagram of an embodiment of the optical detection device for the alignment accuracy of a double-layer circuit board in this invention. Detailed Implementation

[0012] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0013] The terms "comprising" and "having," and any variations thereof, used in the embodiments of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.

[0014] To facilitate understanding of this embodiment, a detailed description of the optical detection method for the alignment accuracy of a double-layer circuit board disclosed in this embodiment of the invention is provided first. As shown in Figure 1, the method includes the following steps: 101. Acquire the transmitted light image and the reflected light image of the double-layer circuit board, and perform semantic segmentation on the transmitted light image and the reflected light image respectively to obtain a superimposed segmentation map and a reference segmentation map; In this embodiment, the step of performing semantic segmentation on the transmitted light image and the reflected light image respectively to obtain a superimposed segmentation map and a reference segmentation map includes: performing multi-scale feature extraction on the transmitted light image to obtain shallow features containing marked edges and deep features containing superimposed regions of upper and lower layers, and fusing the shallow features and the deep features to obtain a fused feature map; calculating the feature response intensity of the fused feature map in the channel dimension and spatial dimension respectively to generate a distinguishing weight, and performing weighted filtering on the fused feature map according to the distinguishing weight to generate a superimposed segmentation map that identifies the superimposed positions of upper and lower layer marks; performing convolutional feature extraction and feature fusion on the reflected light image, and performing weighted processing on the fused features to generate a reference segmentation map that identifies the position of the upper layer mark.

[0015] Specifically, firstly, transmitted light and reflected light images of the double-layer circuit board are acquired using an industrial camera. The transmitted light image is acquired by placing an LED surface light source under the double-layer circuit board. Light passes through the lower and upper layers from bottom to top and is received by the industrial camera above. The image simultaneously contains the superimposed projection of the upper reference mark (e.g., a 3mm diameter circular copper ring) and the lower reference mark. The reflected light image is acquired by placing a ring-shaped LED light source above the double-layer circuit board. Light shines on the surface of the upper layer and reflects into the camera. The image only contains the upper reference mark. The transmitted light image is then input into an improved U-Net convolutional neural network for semantic segmentation. This network contains a 5-level encoder and a 4-level decoder. The first level of the encoder uses 16 3×3 convolutional kernels to perform convolution operations on the input grayscale image. Each convolutional kernel calculates a weighted sum of local regions as it slides across the image, extracting edge gradients and texture direction information; these features are called shallow features. For example, when a convolutional kernel detects a sudden change in pixel grayscale value from 200 to 50, it generates a large response value, indicating the presence of a boundary. However, the network cannot determine whether this boundary belongs to a marker edge or a background impurity edge. With each level of the encoder, the spatial size of the feature map is halved through 2×2 max pooling, and the number of convolutional kernels doubles (32, 64, 128, 256). The extracted features gradually shift from local geometric information to overall semantic information. By the fourth and fifth levels of the encoder, the feature map size is reduced to 1 / 8 and 1 / 16 of the original image, respectively. At this point, the deep features extracted by the network can identify "this is a complete circular marker region" or "this is an overlapping region formed by the superposition of two markers," but due to the reduced spatial resolution, the precise location information of the marker edges is lost. The decoder then progressively enlarges the feature map size through transposed convolution operations. Before each decoding level, the shallow features of the corresponding layer of the encoder are passed over via skip connections and concatenated with the features of the current decoding layer along the channel dimension. Specifically, the feature map output from the third stage of the encoder is 75×75×128 pixels, and the feature map after upsampling in the second stage of the decoder is also 75×75×64 pixels. These two are then stitched together in the channel direction to obtain a fused feature map of 75×75×192 pixels. This stitching operation allows the fused feature map to simultaneously contain the precise edge localization capability of shallow features and the semantic recognition capability of deep features. For example, when the edge of a marker is partially blurred due to copper foil residue, shallow features can provide the edge coordinates of the clear portion, while deep features infer that the blurred portion belongs to the marker area rather than the background based on the overall circular shape of the marker. The combination of these two features enables the extraction of the complete contour. After four stages of decoding, a fused feature map of the same size as the original image (300×300 pixels) is finally generated. This feature map contains 16 channels, each representing a specific feature response pattern.

[0016] To enhance the network's ability to recognize labeled regions, an attention weighting mechanism is introduced into the fused feature map. First, the feature response intensity of each channel is calculated, and global average pooling and global max pooling are performed on each of the 16 channels. Global average pooling averages the 300×300 pixel values ​​of each channel; for example, the average value of channel 5 is 87.3, representing the average activation level of that channel's feature across the entire image. Global max pooling extracts the maximum pixel value of each channel; for example, the maximum value of channel 5 is 243, representing the strongest response of that channel in a local region. These two sets of 16-dimensional vectors are then input into a fully connected layer containing 8 nodes. The fully connected layer performs linear transformations and non-linear activations on the input, essentially learning the importance weights of each channel feature. The outputs of the two fully connected layers are summed element-wise, and then the values ​​are compressed to between 0 and 1 using the sigmoid function, resulting in 16 channel weight coefficients; for example, the weight of channel 5 is 0.92, and the weight of channel 12 is 0.15. A weight close to 1 indicates that the channel contributes significantly to label recognition, while a weight close to 0 indicates that the channel primarily responds to background noise. The 16 weight coefficients are multiplied pixel-by-pixel by the corresponding channels of the fused feature map to achieve channel weighting.

[0017] Subsequently, the feature response intensity in the spatial dimension is calculated. Average pooling and max pooling are performed on the 16 channels of the fused feature map along the channel direction, resulting in two 300×300 single-channel feature maps. In the average pooling map, each pixel value represents the average response at that location across all channels, while the max pooling map represents the strongest response at that location. These two feature maps are concatenated along the channel direction to form a 300×300×2 dual-channel image, which is then input into a 7×7 convolutional layer. This layer uses a large kernel to capture a large range of contextual information around each pixel, outputting a 300×300 single-channel spatial weight map. After sigmoid activation, the value of each pixel in the image represents the probability that the location belongs to the labeled region. For example, the weight at the center of the labeled region is 0.98, the weight at the edge of the labeled region is 0.85, and the weight in the background region is 0.03. The spatial weight map is multiplied pixel-by-pixel with the channel-weighted feature map to suppress the feature response at the background location and enhance the features of the labeled region. Finally, a 1×1 convolutional layer and sigmoid activation are used to output a superimposed segmentation map. The segmentation image is a 300×300 binary image, with a pixel value of 255 (white) for the marked area and a pixel value of 0 (black) for the background area, indicating the overlapping position of the upper and lower layer marks in the transmitted light image. Based on the camera calibration parameter of 11.26 micrometers / pixel, the positioning accuracy of this segmentation image can reach one pixel, or 11.26 micrometers, meeting the circuit board alignment accuracy requirement within 30 micrometers.

[0018] Finally, for processing the reflected light image, the same U-Net network architecture is used, but the encoder is reduced to 4 levels to reduce computational load, because the reflected light image only contains upper-layer markers and the background is relatively simple. After the network inputs the reflected light image, it goes through a complete process of encoding-decoding-feature fusion-attention weighting, outputting a reference segmentation map. This segmentation map is also a 300×300 binary image, identifying the precise location and contour shape of the upper-layer markers. The role of the reference segmentation map is to provide prior information on the shape and location of the upper-layer markers for subsequent steps. For example, when the overlay segmentation map contains two adjacent circular marker regions, by extracting the center coordinates (e.g., x=150, y=200) and radius (e.g., r=133 pixels) of the upper-layer marker in the reference segmentation map, the region matching these coordinates and radius can be located in the overlay segmentation map, thus confirming that the region is the upper-layer marker, and the remaining region is the lower-layer marker, achieving accurate separation of the upper and lower-layer markers. Compared to traditional fixed threshold segmentation, this deep learning-based semantic segmentation method improves the recognition accuracy by more than 15% when the marked edges are blurred or contaminated, ensuring the reliability of subsequent tilt angle calculation and offset measurement.

[0019] 102. Based on the contour information of the upper-layer mark in the reference segmentation image, separate the upper-layer mark segmentation image and the lower-layer mark segmentation image from the overlay segmentation image, and calculate the tilt angle of the upper plate relative to the lower plate based on the perspective distortion features of the mark contour in the upper-layer mark segmentation image. In this embodiment, after obtaining the overlay segmentation image and the reference segmentation image, it is necessary to separate the upper-layer mark and the lower-layer mark from the overlay segmentation image. Since the transmitted light penetrates the double-layer plate to form an image, the projection of the upper and lower layer marks in the overlay segmentation image overlaps and is displayed as a white area, which cannot be directly distinguished. At this time, the characteristic that the reference segmentation image only contains the upper-layer mark is used for separation. First, the Canny edge detection algorithm is used to extract the contour boundary of the white mark area in the reference segmentation image to obtain the boundary pixel coordinate sequence. Moments are calculated on the coordinate sequence to extract the shape parameters and position parameters of the contour. The shape parameters include the area, perimeter, and circularity of the contour, where the circularity is defined as 4π×area / perimeter², the circularity of an ideal circle is 1, and the circularity of an ellipse or irregular shape is less than 1. The location parameters are the geometric center coordinates of the contour, obtained by calculating the average of the coordinates of all boundary pixels. For example, the geometric center coordinates of the extracted upper-layer marker are (x=135, y=180), with an area of ​​55,000 pixels and a circularity of 0.998. Then, all white connected regions are searched in the overlay segmentation map, and the same contour parameters are extracted for each region. The geometric center coordinates of each region in the overlay map are compared with the geometric center coordinates of the upper-layer marker in the reference map, and the coordinate distance difference is calculated. When the distance difference between the center coordinates of a region and the reference coordinates is less than 5 pixels (approximately 56 micrometers), that region is determined to be part of the upper-layer marker segmentation map; the remaining white regions in the overlay segmentation map are determined to be part of the lower-layer marker segmentation map. For example, in an overlay image containing two marked regions, region A has its center coordinates at (133, 178), and its distance from the reference coordinates (135, 180) is √[(135-133)²+(180-178)²]=2.83 pixels, which is less than the 5-pixel threshold, thus it is confirmed as the upper-layer mark. Region B has its center coordinates at (210, 185), and its distance is 75 pixels, thus it is determined to be the lower-layer mark. This separation method based on geometric center matching avoids confusion errors when the upper and lower-layer marks partially overlap.

[0020] After separation, perspective distortion analysis is performed on the upper-layer marker segmentation image to calculate the tilt angle. When the upper plate is tilted, the circular markers undergo perspective distortion in transmitted light imaging, appearing as ellipses. A least-squares ellipse fitting algorithm is used on the white area of ​​the upper-layer marker segmentation image. This algorithm substitutes the pixel coordinates of all marker boundaries into the ellipse equation Ax² + Bxy + Cy² + Dx + Ey + F = 0, and solves for the coefficients A, B, C, D, E, and F by minimizing the sum of squared distances from the boundary points to the ellipse, thus determining the best-fit ellipse. After fitting, the major axis length *a* and minor axis length *b* of the ellipse are calculated based on the coefficients of the ellipse equation. For example, the fitted ellipse has a major axis length of 266.00 pixels and a minor axis length of 265.87 pixels. Calculating the ratio of the major axis to the minor axis yields the ellipticity *k* = a / b = 266.00 / 265.87 = 1.00049. Based on perspective geometry, after the circular mark is tilted by an angle θ, the ratio of the minor axis to the major axis of the projected ellipse is equal to cos(θ), i.e., b / a = cos(θ). Therefore, cos(θ) = 1 / k = 1 / 1.00049 = 0.99951. The tilt angle θ is calculated using the inverse cosine function as θ = arccos(0.99951) = 0.0313 radians = 1.79 degrees. When the tilt angle is between 0.5 and 2 degrees, the corresponding ellipticity is between 1.000038 and 1.00061, with the difference between the major and minor axes being only 0.01 to 0.16 pixels, requiring a high-precision ellipse fitting algorithm for accurate extraction. This angle measurement based on perspective distortion requires no additional sensors; it obtains the spatial orientation of the board only through image analysis, providing an angular basis for tilt compensation in subsequent 3D offset calculations and ensuring the accuracy of alignment accuracy assessment in non-parallel states.

[0021] 103. Calculate the vertical height offset of the upper plate based on the area ratio of the upper-layer marker segmentation image and the lower-layer marker segmentation image, and the tilt angle. In this embodiment, calculating the vertical height offset of the upper plate based on the area ratio of the upper-layer marker segmentation image and the lower-layer marker segmentation image, and the tilt angle, includes: calculating the pixel area ratio of the upper-layer marker segmentation image and the lower-layer marker segmentation image; scaling and compensating the pixel area of ​​the upper-layer marker segmentation image based on the cosine value corresponding to the tilt angle to obtain the compensated upper-layer marker area, and calculating the area ratio of the compensated upper-layer marker area to the lower-layer marker area; calculating the vertical height offset of the upper plate based on the deviation between the compensated area ratio and a preset standard ratio, and a preset pixel-to-physical size conversion coefficient.

[0022] Specifically, the vertical height offset is first calculated using the area difference between the upper and lower markers in the transmitted light image. First, the pixel area ratio of the upper and lower marker segmentation images is calculated. The pixel area is obtained by traversing the segmentation images and counting the number of white pixels (pixel value 255). For example, if the upper marker segmentation image contains 54,500 white pixels and the lower marker segmentation image contains 53,000 white pixels, the initial pixel area ratio is calculated to be 54,500 / 53,000 = 1.028. This area ratio reflects the difference in the projected size of the upper and lower markers during transmitted light imaging. The physical reason for this difference is that transmitted light, emitted from the lower light source, passes upwards through the double-layer plate to reach the camera, and propagates in a divergent path. When the upper plate is relatively higher than the lower plate, the upper marker is closer to the camera sensor, and according to the projection magnification principle of geometric optics, its projected area on the imaging surface increases; conversely, when the upper plate is relatively lower, the projected area decreases. However, the initial pixel area ratio is affected by two factors: one is the projection magnification or reduction caused by the vertical height offset, and the other is the perspective compression caused by the tilt angle. The influence of the tilt angle needs to be eliminated before the vertical offset information can be accurately extracted.

[0023] Next, scaling compensation is applied to the upper-layer mark area based on the cosine value corresponding to the tilt angle. When the upper-layer plate tilts by an angle θ, the mark plane is no longer perpendicular to the principal axis of the transmitted light, causing the projected area to shrink due to perspective effects. According to the principles of projection geometry, after the plane tilts by an angle θ, its projected area becomes cos(θ) times the original area. However, since the mark is a two-dimensional plane, its area is the square of its length, so the area shrinkage coefficient caused by the tilt is cos²(θ). The scaling compensation calculation formula is: compensated upper-layer mark area = upper-layer mark pixel area / cos²(θ), where θ is the tilt angle calculated in the previous steps. For example, if the tilt angle θ = 1.79 degrees, cos(1.79°) = 0.99951, cos²(1.79°) = 0.99902. Dividing the upper-layer mark pixel area of ​​54500 by 0.99902, the compensated area is 54500 / 0.99902 ≈ 54553 pixels. The compensation operation is equivalent to "virtually rotating" the upper-layer marker to a state parallel to the lower-layer marker, eliminating the influence of tilt on the area. The compensated area ratio is then calculated: Compensated area ratio = 54553 / 53000 = 1.029. This ratio only reflects the contribution of vertical height offset and no longer includes the interference of tilt angle.

[0024] Finally, the vertical height offset is calculated based on the deviation between the compensated area ratio and the preset standard ratio. The preset standard ratio refers to the theoretical area ratio of the upper and lower layer markings under ideal conditions (parallel upper and lower boards with no vertical offset). This ratio is determined based on the reference marking dimensions marked in the circuit board design documents. For example, the diameter of the upper and lower layer reference markings can be specified as 3.0 mm, therefore the preset standard ratio = (3.0 / 3.0)² = 1.000. If different marking sizes are used in the design, such as an upper layer diameter of 3.0 mm and a lower layer diameter of 2.8 mm, then the standard ratio = (3.0 / 2.8)² = 1.148. The deviation between the compensated area ratio and the preset standard ratio is calculated as: Area ratio deviation = 1.029 - 1.000 = 0.029. This deviation quantitatively describes the degree to which the vertical position of the upper board deviates from the designed height. Converting the area ratio deviation into a physical height offset requires using a preset pixel-to-physical size conversion coefficient. The conversion coefficient was obtained through system calibration: During the initial installation of the testing equipment on the production line, a precision lifting platform, along with a standard thickness gauge (accuracy 0.01 mm), was used to fix the upper plate at a standard height (e.g., plate spacing 1.50 mm). Transmitted light images were captured, and the area ratio at this point was calculated as a baseline value. Then, metal shims of known thickness (e.g., 0.05 mm, 0.10 mm, 0.15 mm) were placed under the upper plate. Images were captured and the area ratio was calculated after each elevation, recording the correspondence between the shim thickness and the deviation of the area ratio. The conversion relationship was obtained through linear fitting: Vertical height offset (mm) = Area ratio deviation × K, where K is the conversion coefficient. Calibration experiments showed that for a typical configuration with a plate spacing of 1.5 mm and a camera working distance of approximately 150 mm, the conversion coefficient K is approximately 3.4 mm. Substituting the aforementioned area ratio deviation of 0.029, the calculation was: Vertical height offset = 0.029 × 3.4 ≈ 0.099 mm. However, in actual production, the vertical offset of a qualified circuit board is usually controlled within 0.05 mm. For example, when the area ratio deviation is 0.0084, the calculated vertical height offset is 0.0084 × 3.4 ≈ 0.0285 mm, or 28.5 micrometers. This result indicates that the upper board is about 28.5 micrometers higher than the design position, which is within the acceptable range. This vertical offset measurement method based on area change utilizes the projection characteristics of transmitted light imaging. It eliminates the need for laser displacement sensors or contact thickness gauges, achieving quantitative detection of Z-axis offset solely through image analysis. This overcomes the shortcomings of traditional methods that only evaluate in-plane offset while ignoring vertical errors.

[0025] 104. Extract the centroid coordinates of the upper-layer marker segmentation image and the lower-layer marker segmentation image respectively, and calculate the centroid coordinate difference after performing perspective correction on the extracted centroid coordinates according to the tilt angle to obtain the horizontal offset; in this embodiment, the step of calculating the centroid coordinate difference after performing perspective correction on the extracted centroid coordinates according to the tilt angle to obtain the horizontal offset includes: calculating the coordinate correction coefficients in the tilt direction and perpendicular to the tilt direction according to the tilt angle (wherein the calculation of the coordinate correction coefficients in the tilt direction and perpendicular to the tilt direction according to the tilt angle includes: ellipticalizing the marker outline in the upper-layer marker segmentation image). Circular fitting is performed to extract the direction angle of the minor axis, obtaining the tilt direction. Based on the tilt direction, the coordinate axes requiring perspective correction are determined. The reciprocal of the cosine function is calculated based on the tilt angle, and the result is used as the coordinate correction coefficient for the coordinate axis corresponding to the tilt direction. The coordinate correction coefficient for the coordinate axis perpendicular to the tilt direction is set to 1. The centroid coordinates of the upper-layer marker segmentation image are multiplied by the corresponding coordinate correction coefficient in the tilt direction to obtain the corrected upper-layer centroid coordinates. The Euclidean distance between the corrected upper-layer centroid coordinates and the centroid coordinates of the lower-layer marker segmentation image in the horizontal plane is calculated to obtain the horizontal offset.

[0026] Specifically, the centroid coordinates of the upper and lower labeled segmentation images are extracted first. The centroid coordinates are the geometric center of the labeled region. They are calculated by summing the x-coordinates of all white pixels within the labeled region and dividing by the total number of pixels to obtain the centroid's x-coordinate; similarly, by summing the y-coordinates and dividing by the total number of pixels to obtain the centroid's y-coordinate. For example, if the upper labeled segmentation image contains 54,500 white pixels, the sum of their x-coordinates is 7,357,500, and the sum of their y-coordinates is 9,810,000. Therefore, the centroid coordinates are calculated as follows: 上层 =7357500 / 54500=135.0, y 上层 =9810000 / 54500=180.0, which is the coordinate (135.0, 180.0). The centroid coordinates of the lower layer marker are calculated using the same method. Assuming the lower layer marker contains 53000 white pixels, the sum of the x-coordinates is 7144200, the sum of the y-coordinates is 9646500, and the centroid coordinates are... 下层 =7144200 / 53000=134.8, y 下层=9646500 / 53000=182.0, i.e., coordinates (134.8, 182.0). Due to the tilt of the upper plate, the centroid coordinates of the upper markers are affected by perspective projection, and the coordinate difference cannot be directly calculated; perspective correction is required first. The first step in perspective correction is to determine the tilt direction and coordinate correction coefficients. Ellipse fitting is performed on the upper marker segmentation image. The aforementioned fitting results have output the lengths of the major and minor axes of the ellipse, as well as the orientation angle of the minor axis. The minor axis orientation angle refers to the angle between the minor axis of the ellipse and the x-axis of the image, ranging from -90 degrees to 90 degrees. For example, if the fitted output minor axis orientation angle is -5 degrees, this angle indicates that the minor axis is almost along the x-axis, indicating that the upper plate is mainly tilted along the y-axis (when a circle is tilted around the y-axis, the minor axis of the projected ellipse is along the x-axis). The minor axis direction indicates the direction in which the markers are perspective compressed, i.e., the tilt direction. The coordinate axes requiring perspective correction are determined based on the minor axis direction angle: When the minor axis direction angle is between -45° and 45°, the minor axis is nearly horizontal, and the tilt direction is determined to be the y-axis, requiring correction of the y-coordinate, while the x-coordinate remains uncorrected; when the minor axis direction angle is between 45° and 90° or between -90° and -45°, the minor axis is nearly vertical, and the tilt direction is determined to be the x-axis, requiring correction of the x-coordinate, while the y-coordinate remains uncorrected. For a minor axis direction angle of -5°, the tilt direction is determined to be the y-axis. The coordinate correction coefficient is calculated as follows: Based on the aforementioned tilt angle θ = 1.79°, the cosine value cos(1.79°) = 0.99951. The coordinate correction coefficient is the reciprocal of the cosine value, 1 / cos(1.79°) = 1 / 0.99951 = 1.00049. The physical meaning of this coefficient is as follows: After the upper plate is tilted by an angle θ along the y-axis, the projected length of the mark in the y-direction is shortened to cos(θ) times the original length, and the y-coordinate of the centroid is also reduced proportionally. Therefore, it is necessary to multiply by 1 / cos(θ) to stretch the y-coordinate back to its equivalent value before tilting. For the x-coordinate, since the tilt direction is perpendicular to the x-axis, the mark does not experience perspective compression in the x-direction, and the coordinate correction coefficient is set to 1, meaning that the x-coordinate does not require correction.

[0027] Next, the centroid coordinates of the upper-layer labeled segmentation image are multiplied by the corresponding coordinate correction coefficient along the tilt direction. Since the tilt direction is the y-axis, the y-coordinate is corrected as follows: y 上层校正 =y 上层 ×1.00049=180.0×1.00049=180.09. The x-coordinate remains unchanged: x 上层校正 =x 上层 ×1=135.0. The corrected centroid coordinates of the upper layer are (135.0, 180.09). The purpose of perspective correction is to convert the centroid coordinates of the upper layer mark from the perspective projection position under the tilted state to the position where the mark center should be if the upper layer plate is not tilted, thus eliminating the visual offset error introduced by the tilted posture.

[0028] Finally, the Euclidean distance between the upper and lower centroid coordinates in the horizontal plane after correction is calculated to obtain the horizontal offset. The Euclidean distance calculation formula is: Horizontal offset = √[(x 上层校正 - x 下层 )² + (y 上层校正 - y 下层 The horizontal offset is calculated as follows: √[(135.0 - 134.8)² + (180.09 -182.0)²] = √[0.2² + (-1.91)²] = √[0.04 + 3.65] = √3.69 = 1.92 pixels. Converted to physical distance: 1.92 pixels × 11.26 micrometers / pixel = 21.6 micrometers. This result shows that the offset of the upper and lower layer mark centers in the horizontal plane is 21.6 micrometers, meeting the alignment accuracy requirement of 30 micrometers. Perspective correction ensures that even if the upper plate is tilted by 1.79 degrees, the calculated horizontal offset still accurately reflects the true relative position of the mark center. Without correction, the distance between the original centroid coordinates (135.0, 180.0) and the lower layer coordinates (134.8, 182.0) is √[0.04+4.0] = 2.01 pixels, corresponding to 22.6 micrometers, which differs from the corrected result by 1 micrometer. Although the difference is small, in the extreme case where the tilt angle reaches 2 degrees, the perspective compression of the y-coordinate reaches 0.06%, resulting in an error of about 0.08 pixels on a 133-pixel radius marker, which translates to a physical distance of about 0.9 micrometers. This accounts for 3% of the accuracy requirement of 30 micrometers, and its impact cannot be ignored.

[0029] 105. Determine whether the combined modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and output the detection result.

[0030] In this embodiment, determining whether the combined modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold and outputting the detection result includes: calculating the sum of the squares of the horizontal offset and the vertical height offset to obtain the offset sum value, and performing a square root operation on the offset sum value to obtain the combined offset modulus value in three-dimensional space; comparing the combined offset modulus value with the preset offset threshold, and if the combined offset modulus value is less than the preset offset threshold, it is determined that the alignment is qualified; otherwise, it is determined that the alignment is unqualified, and the detection result is output.

[0031] Specifically, the sum of the squares of the horizontal offset and the vertical height offset is first calculated to obtain the offset sum. Then, the square root of this sum is taken to obtain the composite offset modulus. This calculation uses the Euclidean distance formula in three-dimensional space: Composite offset modulus = √(Horizontal offset² + Vertical height offset²), where the horizontal offset is the distance between the centroids of the upper and lower layer markers in the horizontal plane, and the vertical height offset is the distance the upper plate deviates from the standard height in the Z-axis direction. For example, if the horizontal offset calculated in the previous steps is 21.6 micrometers, and assuming the vertical height offset is 28.5 micrometers, the offset sum is calculated using the formula: Offset sum = 21.6² + 28.5² = 466.56 + 812.25 = 1278.81; then, the square root of the offset sum is taken: Composite offset modulus = √1278.81 = 35.8 micrometers. This composite offset modulus represents the straight-line distance between the center points of the upper and lower layer markers in three-dimensional space, comprehensively reflecting the xy-direction offset in the horizontal plane and the z-axis offset in the vertical direction. The reason for using a composite modulus instead of evaluating offsets in each direction separately is that the ultimate goal of circuit board alignment is to ensure accurate connectivity between vias on upper and lower layers. Vias are three-dimensional cylindrical structures, and the spatial distance between the markings on upper and lower layers directly determines the reliability of via alignment. Evaluating offset in a single direction alone cannot reflect the true deviation in spatial position. For example, when both horizontal and vertical offsets are 50 micrometers, although each may seem within acceptable limits individually, the three-dimensional spatial distance reaches 70.7 micrometers, approaching the edge of non-compliance. Therefore, a composite modulus is needed for unified evaluation.

[0032] Subsequently, the synthesized offset modulus value is compared with a preset offset threshold to determine whether the alignment is qualified. The preset offset threshold is determined according to the design specifications of the circuit board, and this threshold is derived from the requirements for the interlayer alignment accuracy in the product technical specifications. For high-density circuit boards, the line width and line pitch are at the 0.1 mm level, and the via diameter is 0.2 - 0.3 mm. The preset offset threshold is set to 80 microns to ensure sufficient margin in the connection area of the upper and lower layer copper foils during via drilling. For ordinary-density circuit boards, the line width and pitch are more than 0.2 mm, and the via diameter is more than 0.4 mm. The threshold is relaxed to 150 microns. Taking the high-density board as an example, the preset offset threshold is 80 microns. The synthesized offset modulus value of 35.8 microns calculated above is less than the threshold of 80 microns, and the alignment is determined to be qualified. The system outputs the detection results, including the synthesized offset modulus value of 35.8 microns, the horizontal offset of 21.6 microns, the vertical height offset of 28.5 microns, the tilt angle of 1.79 degrees, and the qualification determination "qualified". The detection results are presented to the operator through the display screen and recorded in the quality database as the alignment accuracy statistical data of this batch of circuit boards. When the synthesized offset modulus value exceeds the threshold, the system determines that the alignment is unqualified and triggers an alarm. The operator judges the adjustment direction according to the specific values of the horizontal offset and the vertical height offset: if the vertical offset is much larger than the horizontal offset, it means that the main problem is the height deviation of the upper layer board, and the positioning fixture needs to be adjusted or the substrate warpage needs to be checked; if the horizontal offset is large, the position of the positioning pins in the xy direction needs to be adjusted. This determination method based on three-dimensional synthesized offset comprehensively reflects the spatial position relationship between the upper and lower layer boards, avoids the defect of the traditional method that only evaluates the planar offset and ignores the vertical offset, and ensures the accuracy of the alignment quality assessment.

[0033] In the embodiment of the present invention, by obtaining the transmitted light image and the reflected light image of the double-layer circuit board, semantic segmentation is respectively performed to obtain the superimposed segmentation map and the reference segmentation map; based on the upper layer marker contour information of the reference segmentation map, the upper and lower layer markers are separated from the superimposed segmentation map, and the tilt angle of the board is calculated according to the perspective distortion characteristics of the upper layer marker contour; the vertical height offset is calculated by combining the area ratio and the tilt angle of the upper and lower layer markers; the centroid coordinates of the upper and lower layer markers are extracted, and the horizontal offset is calculated after perspective correction according to the tilt angle; it is judged whether the synthesized modulus value of the horizontal offset and the vertical height offset is less than the preset threshold, and the detection results are output. This application realizes marker recognition under complex backgrounds through semantic segmentation, and realizes attitude correction through perspective distortion analysis and three-dimensional offset calculation, improving the accuracy of double-layer circuit board alignment detection.

[0034] Please refer to Figure 2. Another embodiment of the optical detection method for the alignment accuracy of a double-layer circuit board in this application includes: 201. Obtaining the transmitted light image and the reflected light image of the double-layer circuit board, and performing semantic segmentation on the transmitted light image and the reflected light image respectively to obtain a superimposed segmentation map and a reference segmentation map; In this embodiment, step 201 is similar to step 101 in the first embodiment, and will not be described again here.

[0035] 202. Extract the contour shape parameters and geometric center coordinates of the upper-layer markers in the reference segmentation image. In this embodiment, after generating the overlay segmentation image and the reference segmentation image, the contour of the white-marked area in the reference segmentation image is extracted first. The findContours function in the OpenCV image processing library is used to perform contour detection on the reference segmentation image. This function scans the binary image line by line, and marks the start point of the contour when a pixel value changes from 0 to 255. The coordinates of all boundary pixels are tracked and recorded along the boundary of the white area to form a contour point sequence. Geometric feature parameters, including geometric center coordinates, area, perimeter, and circularity, are calculated on the extracted contour point sequence. The geometric center coordinates are obtained by calculating the average coordinates of all white pixels in the contour area. Specifically, the x-center is obtained by summing the x-coordinates of all white pixels in the contour and dividing by the total number of pixels, and the y-center is obtained by summing all y-coordinates and dividing by the total number of pixels. For example, referencing the segmentation image, the upper layer is marked as a circle with a diameter of 3 mm (equivalent to a diameter of 266 pixels based on the camera calibration parameter of 11.26 micrometers / pixel). The outline contains approximately 55,000 white pixels, and the calculated geometric center coordinates are (135, 180). The area is the total number of white pixels contained in the outline, 55,000. The perimeter is obtained by summing the distances between adjacent outline points. For a circle with a diameter of 266 pixels, the theoretical perimeter is π × 266 ≈ 836 pixels. The formula for calculating roundness is: Roundness = 4π × Area / Perimeter², substituting the values, we get Roundness = 4 × 3.14159 × 55000 / 836² ≈ 0.998. The closer the roundness is to 1, the closer the outline is to an ideal circle. When the marking has edge defects, copper foil residue, or solder mask contamination, the irregularity of the outline leads to an increased perimeter, and the roundness will decrease to below 0.95.

[0036] 203. Locate the marked region corresponding to the geometric center coordinates in the overlay segmentation map, and match the located marked region with the contour shape features to determine the upper-layer marked segmentation map. In this embodiment, all white connected regions are extracted by using the same findContours function on the overlay segmentation map. Assume two marked regions are detected. The geometric center coordinates of region A are (133, 178), area is 54500 pixels, perimeter is 830 pixels, and circularity is 0.995; the geometric center coordinates of region B are (358, 182), area is 53000 pixels, perimeter is 815 pixels, and circularity is 0.993. Calculate the distance between the geometric center coordinates of each region in the overlay map and the center coordinates (135, 180) of the upper-layer mark in the reference map. The distance is calculated using the Euclidean distance formula: distance = √[(x1-x2)²+(y1-y2)²]. The distance between region A and the reference coordinates is √[(135-133)²+(180-178)²]=√8≈2.8 pixels, which translates to a physical distance of approximately 32 micrometers. The distance between region B and the reference coordinates is √[(135-358)²+(180-182)²]=√49733≈223 pixels, which translates to a physical distance of approximately 2510 micrometers. The distance matching threshold is set to 5 pixels (corresponding to 56 micrometers). This threshold is selected based on the fact that the reference segmentation image and the overlay segmentation image are images of the same upper-layer mark under different light sources. Theoretically, the center coordinates should be completely consistent. However, due to slight refraction of the light path when the transmitted light penetrates the double-layer plate and the blurring of the image edges, there is an error of 1-3 pixels in the contour extraction. Therefore, a tolerance of 5 pixels is set. Region A's distance of 2.8 pixels is less than the threshold, and its area of ​​54500 differs from the reference marker of 55000 by only 0.9%, while its circularity of 0.995 differs from the reference value of 0.998 by only 0.3%, thus satisfying the matching conditions. Region B's distance of 223 pixels far exceeds the threshold, so it is excluded from the match. Region A is determined as the upper-level labeled segmentation map. This segmentation map is a 300×300 binary image, with only the pixel position corresponding to region A marked as 255 (white), and the remaining positions marked as 0 (black).

[0037] 204. Based on the upper-level marked segmentation map, the remaining marked regions in the overlay segmentation map are determined as the lower-level marked segmentation map. In this embodiment, an image XOR operation is used, which compares the two images pixel by pixel: when a certain position in the overlay segmentation map is white (255) and the same position in the upper-level marked segmentation map is also white (255), it indicates that the position belongs to the upper-level mark, and the XOR result outputs black (0) to remove it; when a certain position in the overlay segmentation map is white (255) but the same position in the upper-level marked segmentation map is black (0), it indicates that the position belongs to the lower-level mark, and the XOR result outputs white (255) to retain it. For example, coordinates (133, 178) are located in the upper-layer marked region. In both the overlay and upper-layer marked images, this position has a value of 255. The XOR operation 255⊕255=0, resulting in a black output. Coordinates (358, 182) are located in the lower-layer marked region. In the overlay image, this position has a value of 255, while in the upper-layer marked image, it has a value of 0. The XOR operation 255⊕0=255, resulting in a white output. After performing the XOR operation on all pixels of the image, the lower-layer marked segmentation image is obtained. This image contains only the 53,000 white pixels of region B, and the upper-layer marked region is completely removed. The advantage of this separation method is that even if the upper and lower layer marked regions partially overlap in the transmitted light image, the XOR operation can accurately separate the overlapping parts, ensuring that the pixels in the upper and lower layer marked segmentation images are not duplicated.

[0038] 205. Perform ellipse fitting on the marker contours in the upper-layer marker segmentation image to obtain the major and minor axis lengths of the ellipse. In this embodiment, after obtaining the upper-layer marker segmentation image, ellipse fitting is performed on the marker contours to measure perspective distortion. The fitting is performed using the `fitEllipse` function from the OpenCV library. This function uses a least-squares algorithm, substituting the coordinates of all boundary points of the contour into the ellipse equation Ax² + Bxy + Cy² + Dx + Ey + F = 0. By solving for the parameters A, B, C, D, E, and F that minimize the sum of the squared distances from all boundary points to the ellipse, the best-fit ellipse is determined. The key advantage of this function is that it uses a sub-pixel precision algorithm, performing bilinear interpolation on the boundary point coordinates during the fitting process, refining integer pixel coordinates into floating-point coordinates instead of directly using integer pixel coordinates. Therefore, it can detect minute changes at the 0.01 pixel level. Input the coordinates of all boundary points of the upper-layer marker contour (approximately 836 points), and the function outputs the parameters of the fitted ellipse, including the ellipse center coordinates, major axis length, and minor axis length. For example, the fitted result would be: ellipse center (135.2, 180.1), major axis length a = 266.00 pixels, minor axis length b = 265.87 pixels. It's important to note that fitEllipse also outputs the rotation angle of the ellipse's major axis relative to the image's horizontal axis (e.g., 25 degrees). This angle only indicates the placement of the markers in the image and is unrelated to the tilt of the upper panel; this parameter is not used in subsequent calculations.

[0039] 206. Calculate the ratio of the major axis length to the minor axis length to obtain the ellipticity parameter; in this embodiment, the ellipticity parameter is then calculated to quantify the degree of perspective distortion. The ellipticity is defined as the ratio of the major axis length to the minor axis length: ellipticity k = a / b, where a is the major axis length and b is the minor axis length. Substituting the values, we get: k = 266.00 / 265.87 = 1.00049. The ellipticity reflects the degree of deformation caused by the tilt of the circular mark. When the upper and lower plates are strictly parallel, the transmitted light projection of the circular mark is still circular, the major axis equals the minor axis, and the ellipticity k = 1.000. When the upper plate is tilted, the mark plane is no longer perpendicular to the transmitted light direction, and the light rays pass obliquely through the mark, producing a perspective projection effect. According to the principles of perspective geometry, after a circle tilts by an angle θ around its diameter, the minor axis length of the projected ellipse shortens to cos(θ) times the original diameter, while the major axis length perpendicular to the tilt direction remains unchanged. Therefore, the ratio of the major and minor axes is k = 1 / cos(θ). In actual production, the tilt angle is controlled between 0.5 and 2 degrees, corresponding to an ellipticity range of 1.000038 to 1.00061. Taking a marker with a diameter of 266 pixels as an example, at a tilt of 0.5 degrees, the minor axis shortens to 266 × cos(0.5°) = 265.99 pixels, with a difference of 0.01 pixels between the major and minor axes; at a tilt of 2 degrees, the minor axis is 266 × cos(2°) = 265.84 pixels, with a difference of 0.16 pixels. Using sub-pixel precision ellipse fitting can accurately detect these minute differences.

[0040] 207. Calculate the inverse cosine value based on the ellipticity parameter to obtain the tilt angle of the upper plate relative to the lower plate. In this embodiment, the tilt angle is finally calculated based on the ellipticity. From the perspective geometry: cos(θ) = b / a = 1 / k, the tilt angle is: θ = arccos(1 / k), where arccos is the inverse cosine function. Substituting k = 1.00049, we calculate: cos(θ) = 1 / 1.00049 = 0.99951, θ = arccos(0.99951) = 0.0313 radians = 1.79 degrees. The calculation results show that the upper plate is tilted 1.79 degrees relative to the lower plate. This angle is within the allowable range of 0.5-2 degrees in actual production. The measurement accuracy of the tilt angle depends on the accuracy of the ellipse fitting. When fitEllipse can distinguish a difference of 0.01 pixels in the major and minor axes, the corresponding angular resolution is approximately 0.02 degrees. For example, a 0.5-degree tilt corresponds to a 0.01-pixel difference, 1 degree corresponds to 0.04 pixels, and 2 degrees corresponds to 0.16 pixels. These differences are all within the detection capability of the sub-pixel algorithm. The significance of tilt angle measurement is to provide perspective correction parameters for subsequent steps. When calculating the difference in centroid coordinates between the upper and lower layer marks, the coordinates of the upper layer mark need to be corrected according to the tilt angle to eliminate the systematic error introduced by perspective projection and ensure the accuracy of the horizontal offset calculation. If the tilt angle exceeds 2 degrees, the system will determine that the assembly status is abnormal and issue an alarm, prompting the operator to adjust the positioning fixture or check the warping of the substrate.

[0041] 208. Calculate the vertical height offset of the upper plate based on the area ratio of the upper and lower marked segmentation images and the tilt angle; 209. Extract the centroid coordinates of the upper and lower marked segmentation images respectively, and calculate the centroid coordinate difference after perspective correction based on the tilt angle to obtain the horizontal offset; 210. Determine whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and output the detection result.

[0042] In this embodiment, steps 208-210 are similar to steps 103-105 in the first embodiment, and will not be described again here.

[0043] In this embodiment, by acquiring transmitted light and reflected light images of the double-layer circuit board, semantic segmentation is performed to obtain a superimposed segmentation map and a reference segmentation map. Based on the upper-layer marker contour information of the reference segmentation map, the upper and lower layer markers are separated from the superimposed segmentation map, and the board tilt angle is calculated based on the perspective distortion features of the upper-layer marker contour. The vertical height offset is calculated by combining the area ratio of the upper and lower layer markers and the tilt angle. The centroid coordinates of the upper and lower layer markers are extracted, and the horizontal offset is calculated after perspective correction based on the tilt angle. It is determined whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset threshold, and the detection result is output. This application achieves marker recognition in complex backgrounds through semantic segmentation and achieves posture correction through perspective distortion analysis and three-dimensional offset calculation, thereby improving the accuracy of double-layer circuit board alignment detection.

[0044] The optical detection method for the alignment accuracy of a double-layer circuit board in the embodiments of the present invention has been described above. The optical detection device for the alignment accuracy of a double-layer circuit board in the embodiments of the present invention is described below. Referring to Figure 3, one embodiment of the optical detection device for the alignment accuracy of a double-layer circuit board in the embodiments of the present invention includes: a semantic segmentation module 301, used to acquire transmitted light images and reflected light images of the double-layer circuit board, and to perform semantic segmentation on the transmitted light images and the reflected light images respectively to obtain a superimposed segmentation image and a reference segmentation image; a separation and correction module 302, used to separate an upper-layer marker segmentation image and a lower-layer marker segmentation image from the superimposed segmentation image based on the contour information of the upper-layer marker in the reference segmentation image, and based on the contour information of the upper-layer marker in the reference segmentation image... The perspective distortion features of the marker outline in the upper-layer marker segmentation image are used to calculate the tilt angle of the upper plate relative to the lower plate; the vertical offset calculation module 303 is used to calculate the vertical height offset of the upper plate based on the area ratio of the upper-layer marker segmentation image and the lower-layer marker segmentation image and the tilt angle; the horizontal offset calculation module 304 is used to extract the centroid coordinates of the upper-layer marker segmentation image and the lower-layer marker segmentation image respectively, and calculate the difference of the centroid coordinates after perspective correction based on the tilt angle to obtain the horizontal offset; the result judgment module 305 is used to determine whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and output the detection result.

[0045] In this embodiment of the invention, transmitted light images and reflected light images of a double-layer circuit board are acquired, and semantic segmentation is performed to obtain a superimposed segmentation image and a reference segmentation image. Based on the upper-layer marker contour information of the reference segmentation image, the upper and lower layer markers are separated from the superimposed segmentation image, and the board tilt angle is calculated based on the perspective distortion features of the upper-layer marker contour. The vertical height offset is calculated by combining the area ratio of the upper and lower layer markers and the tilt angle. The centroid coordinates of the upper and lower layer markers are extracted, and the horizontal offset is calculated after perspective correction based on the tilt angle. It is determined whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset threshold, and the detection result is output. This application achieves marker recognition in complex backgrounds through semantic segmentation and achieves posture correction through perspective distortion analysis and three-dimensional offset calculation, thereby improving the accuracy of double-layer circuit board alignment detection.

[0046] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system or system / unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0047] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An optical inspection method for the alignment accuracy of a double-layer circuit board, characterized in that, The optical detection method for the alignment accuracy of the double-layer circuit board includes: acquiring transmitted light images and reflected light images of the double-layer circuit board, and performing semantic segmentation on the transmitted light images and reflected light images respectively to obtain a superimposed segmentation image and a reference segmentation image; based on the contour information of the upper layer mark in the reference segmentation image, separating the upper layer mark segmentation image and the lower layer mark segmentation image from the superimposed segmentation image, and calculating the tilt angle of the upper layer board relative to the lower layer board based on the perspective distortion features of the mark contour in the upper layer mark segmentation image; calculating the vertical height offset of the upper layer board according to the area ratio of the upper layer mark segmentation image and the lower layer mark segmentation image and the tilt angle; extracting the centroid coordinates of the upper layer mark segmentation image and the lower layer mark segmentation image respectively, and calculating the centroid coordinate difference after perspective correction according to the tilt angle to obtain the horizontal offset; determining whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and outputting the detection result.

2. The optical detection method for the alignment accuracy of a double-layer circuit board according to claim 1, characterized in that, The step of performing semantic segmentation on the transmitted light image and the reflected light image to obtain a superimposed segmentation map and a reference segmentation map includes: performing multi-scale feature extraction on the transmitted light image to obtain shallow features containing marked edges and deep features containing superimposed upper and lower layers, and fusing the shallow features and the deep features to obtain a fused feature map; calculating the feature response intensity of the fused feature map in the channel dimension and spatial dimension respectively to generate a discrimination weight, and performing weighted filtering on the fused feature map according to the discrimination weight to generate a superimposed segmentation map that identifies the superimposed positions of the upper and lower layer marks; performing convolutional feature extraction and feature fusion on the reflected light image, and performing weighted processing on the fused features to generate a reference segmentation map that identifies the positions of the upper layer marks.

3. The optical detection method for the alignment accuracy of a double-layer circuit board according to claim 1, characterized in that, The step of separating the upper-layer marker segmentation map and the lower-layer marker segmentation map from the overlay segmentation map based on the contour information of the upper-layer marker in the reference segmentation map includes: extracting the contour shape parameters and geometric center coordinates of the upper-layer marker in the reference segmentation map; locating the marker region corresponding to the geometric center coordinates in the overlay segmentation map, and matching the located marker region with the contour shape features to determine the upper-layer marker segmentation map; and determining the remaining marker region in the overlay segmentation map as the lower-layer marker segmentation map based on the upper-layer marker segmentation map.

4. The optical detection method for the alignment accuracy of a double-layer circuit board according to claim 1, characterized in that, The calculation of the tilt angle of the upper plate relative to the lower plate based on the perspective distortion features of the mark outline in the upper mark segmentation image includes: performing ellipse fitting on the mark outline in the upper mark segmentation image to obtain the length of the major axis and the length of the minor axis of the ellipse; calculating the ratio of the length of the major axis to the length of the minor axis to obtain the ellipticity parameter; and calculating the inverse cosine value based on the ellipticity parameter to obtain the tilt angle of the upper plate relative to the lower plate.

5. The optical inspection method for the alignment accuracy of a double-layer circuit board according to claim 1, characterized in that, The step of calculating the vertical height offset of the upper plate based on the area ratio of the upper and lower marked segmentation images and the tilt angle includes: calculating the pixel area ratio of the upper and lower marked segmentation images; scaling the pixel area of ​​the upper marked segmentation image based on the cosine value corresponding to the tilt angle to obtain the compensated upper marked area, and calculating the area ratio of the compensated upper marked area to the lower marked area; and calculating the vertical height offset of the upper plate based on the deviation between the compensated area ratio and a preset standard ratio and a preset pixel-physical size conversion coefficient.

6. The optical detection method for the alignment accuracy of a double-layer circuit board according to claim 1, characterized in that, The step of calculating the centroid coordinate difference after performing perspective correction on the extracted centroid coordinates based on the tilt angle to obtain the horizontal offset includes: calculating the coordinate correction coefficients in the tilt direction and perpendicular to the tilt direction based on the tilt angle; multiplying the centroid coordinates of the upper layer marker segmentation image by the corresponding coordinate correction coefficient in the tilt direction to obtain the corrected upper layer centroid coordinates; and calculating the Euclidean distance between the corrected upper layer centroid coordinates and the centroid coordinates of the lower layer marker segmentation image in the horizontal plane to obtain the horizontal offset.

7. The optical inspection method for the alignment accuracy of a double-layer circuit board according to claim 1, characterized in that, The step of determining whether the combined modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold and outputting the detection result includes: calculating the sum of the squares of the horizontal offset and the vertical height offset to obtain the offset sum value, and performing a square root operation on the offset sum value to obtain the combined offset modulus value in three-dimensional space; comparing the combined offset modulus value with the preset offset threshold, and if the combined offset modulus value is less than the preset offset threshold, it is determined that the alignment is qualified; otherwise, it is determined that the alignment is unqualified, and the detection result is output.

8. An optical inspection device for the alignment accuracy of a double-layer circuit board, characterized in that, The optical detection device for the alignment accuracy of the double-layer circuit board includes: a semantic segmentation module, used to acquire transmitted light images and reflected light images of the double-layer circuit board, and perform semantic segmentation on the transmitted light images and the reflected light images respectively to obtain a superimposed segmentation image and a reference segmentation image; a separation correction module, used to separate the upper-layer mark segmentation image and the lower-layer mark segmentation image from the superimposed segmentation image based on the contour information of the upper-layer mark in the reference segmentation image, and calculate the tilt angle of the upper plate relative to the lower plate based on the perspective distortion features of the mark contour in the upper-layer mark segmentation image; a vertical offset calculation module, used to calculate the vertical height offset of the upper plate according to the area ratio of the upper-layer mark segmentation image and the lower-layer mark segmentation image and the tilt angle; a horizontal offset calculation module, used to extract the centroid coordinates of the upper-layer mark segmentation image and the lower-layer mark segmentation image respectively, and calculate the difference of the centroid coordinates after perspective correction according to the tilt angle to obtain the horizontal offset; and a result determination module, used to determine whether the composite modulus of the horizontal offset and the vertical height offset is less than a preset offset threshold, and output the detection result.

9. An optical inspection device for the alignment accuracy of a double-layer circuit board, characterized in that, The optical inspection device for the alignment accuracy of the double-layer circuit board includes: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the optical inspection device for the alignment accuracy of the double-layer circuit board to perform the various steps of the optical inspection method for the alignment accuracy of the double-layer circuit board as described in any one of claims 1-7.

10. A computer-readable storage medium storing instructions thereon, characterized in that, When the instructions are executed by the processor, they implement the various steps of the optical detection method for the alignment accuracy of a double-layer circuit board as described in any one of claims 1-7.