Gerber silk screen printing position number automatic identification method and system
Patent Information
- Application Number
- CN202611245424.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-10-30
AI Technical Summary
该方案未公开在栅格化之前依据光圈属性和图元几何关系生成位号检测框的技术手段
1. 按光圈对Gerber丝印图元进行分组并采用可逆二维偏移形成空间分区,可降低不同光圈图元之间的叠加和邻接干扰;通过设置安全间隔,可避免分区边界图元在网络提取时发生误连接。
Smart Images

Figure CN123016446A_ABST
Abstract
Description
[Technical Field] This invention relates to the field of PCB manufacturing data processing technology, and in particular to a method and system for automatic identification of Gerber silkscreen markings. [Background Technology] Surface Mount Technology (SMT) production typically uses Gerber manufacturing data for printed circuit boards (PCBs) as production data. Gerber files describe two-dimensional graphics such as circuit layers, solder mask layers, and silkscreen layers. After EDA design data is output as Gerber manufacturing data, the silkscreen layer mainly retains geometric information such as line segments, arcs, highlights, and area fills, but usually does not retain the semantic design association of "a certain set of graphics corresponding to a certain component reference number." Therefore, when only Gerber files are available, SMT engineers usually need to re-identify reference numbers such as R1, C25, and U103 from the silkscreen layer graphics.
[0001] Different PCB designers employ varying fonts, character sizes, orientations, character spacing, bottom-layer mirroring methods, and the use of underlines and hyphens. Complex boards may also use multiple apertures on the same silkscreen layer, along with non-reference elements such as component outlines, polarity markings, and decorative lines. Directly recognizing characters on the entire layer can easily lead to invalid detections and misidentifications due to non-character graphics, different line widths, adjacent elements, and differences in character orientation. Relying entirely on manual, one-by-one inspection results in a large workload, low efficiency, and a high risk of omissions.
[0002] Publication No. CN101281027A and Application No. CN200810112854.3 disclose a method and apparatus for detecting defective silkscreen markings. This method can perform layer and angle detection on silkscreen markings in PCB design and includes the determination of mirror images between the top and bottom layers. This solution focuses on silkscreen marking objects that can be directly selected during the design phase and does not address methods for automatically constructing candidate regions for reference numerals in Gerber geometric primitives lacking semantic associations.
[0003] Publication No. CN102819552A and application No. CN201210213179.X disclose a method and system for automatically reviewing PCB engineering files. By parsing Gerber files and combining them with graphics methods, engineering parameters such as layer, line width, line spacing, and holes are obtained. The focus of the processing is Gerber engineering parameter extraction and rule review. The continuous processing flow for aperture partitioning, candidate rectangle generation, and character recognition of silkscreen reference marks is not disclosed.
[0004] Publication No. CN109710264A and Application No. CN201811554684.4 disclose a method, system, device, and storage medium for converting Gerber files. This method improves the conversion efficiency of Gerber files to bitmaps by parsing Gerber instructions, classifying primitives, and converting vector coordinates into bitmaps based on conversion precision. However, this solution does not disclose the technical means of generating a reference locator detection box based on aperture attributes and primitive geometric relationships before rasterization.
[0005] Publication No. CN119478644A and Application No. CN202510065672.9 disclose an OCR recognition method and system for silkscreen printing on PCB components. The system primarily processes images of physical PCBs, determining silkscreen information through imaging, image quality evaluation, and OCR recognition. The input data and processing path of this scheme differ from Gerber vector manufacturing data.
[0006] Therefore, it is necessary to provide an automatic identification method for Gerber silkscreen layers that directly addresses the identification of reference numerals. Without relying on the original EDA reference numeral semantic object, this method utilizes the aperture, geometric position, and coordinate information of Gerber primitives to reduce interference from complex graphics, automatically constructs candidate regions for reference numerals, and completes the identification of silkscreen reference numerals in different arrangement directions. [Summary of the Invention] To overcome the above problems, this invention proposes an automatic identification method and system for Gerber silkscreen markings that can effectively solve the above problems.
[0007] The present invention provides a technical solution to solve the above-mentioned technical problems: a method for automatic identification of Gerber silkscreen markings, comprising: Step S1: Read the working silkscreen layer of the target Gerber file and determine whether the working silkscreen layer is the bottom silkscreen layer; if it is the bottom silkscreen layer, perform mirroring; if it is the top silkscreen layer, maintain the original orientation; traverse the elements in the working silkscreen layer, classify the elements according to the aperture identifier, and establish an aperture-element relationship table; create a layer to be identified, offset the elements associated with each aperture according to the reversible two-dimensional offset corresponding to different apertures, write them into the layer to be identified, and establish an aperture-offset table; Step S2: Extract the network from the layer to be identified, and calculate the network limit rectangle for each connected network in the same layer; perform candidate screening based on the element retrieval results inside the network limit rectangle, the number of network constituent elements, and the network geometric features, and establish an aperture-limit rectangle table; Step S3: According to the aperture attribute and the area of the rectangle, the aperture-limit rectangle table is filtered by aperture. The filtered limit rectangles are sorted horizontally and vertically in two dimensions and the spacing is fused to obtain the potential position limit rectangles. Step S4: Determine the physical coordinate range of the to-be-detected image according to the potential reference mark limit rectangle, convert the potential reference mark limit rectangle into image pixel coordinates to form a detection frame, and rasterize the to-be-identified layer to generate a binary to-be-detected image; Step S5: Intercept a candidate image from the to-be-detected image according to the detection frame, perform character recognition after direction normalization on the candidate image, and obtain the silk-screen reference mark and its corresponding candidate region information.
[0008] Preferably, the mirroring process takes the center of the limit rectangle of the working silk-screen layer or the center of a preset layer as the mirroring reference, so that the bottom silk-screen layer is converted to a readable viewing direction consistent with the top silk-screen layer; the coordinate transformation relationship before and after mirroring is recorded.
[0009] Preferably, let the width of the limit rectangle of the working silk-screen layer be W, the height be H, and the number of aperture types be K; both the horizontal offset base and the vertical offset base take 0 as the initial value and are set with a maximum base, and the maximum base is determined according to the arithmetic square root of K; when the smallest integer M not less than the arithmetic square root of K is used as the two-dimensional offset grid scale, the horizontal offset base i_x and the vertical offset base i_y satisfy 0≤i_x<M and 0≤i_y<M; for each aperture, a horizontal offset Δx=i_x×(W+Gx) and a vertical offset Δy=i_y×(H+Gy) are configured, where Gx and Gy are non-negative safety intervals, and when there is a risk of partition boundary contact, Gx and Gy are greater than the geometric adjacency tolerance used for network connectivity determination.
[0010] Preferably, before performing the two-dimensional offset, a cross-aperture association record is established according to the intersection, contact or preset adjacency relationship of different aperture elements in the original coordinate system; when the potential reference mark region involves more than two apertures, related elements or candidate regions are inversely restored to a unified local coordinate system according to the cross-aperture association record and the aperture-offset table, a composite candidate region is reconstructed according to their original relative positions, and a composite candidate image for character recognition is generated based on the composite candidate region.
[0011] Preferably, the candidate screening includes: establishing an intra-layer connected network according to the intersection, contact or preset geometric adjacency relationship between elements; calculating the network limit rectangle of each intra-layer connected network; performing element search inside the network limit rectangle according to a preset element search rule, and marking the network limit rectangle as a to-be-rechecked rectangle when the number of target elements in the search result is 0; then performing recheck according to at least one of the area, aspect ratio, filling rate of the to-be-rechecked rectangle and the statistics of the character scale in the same aperture, and excluding the network limit rectangle when a preset non-character criterion is satisfied; after the recheck is completed, the limit rectangle of the retained intra-layer connected network and its offset are recorded.
[0012] Preferably, the same aperture filtering includes: sorting the N limit rectangles corresponding to the same aperture in ascending order of area; taking the area of the limit rectangle located at the three-quarters position after sorting as the reference area A_ref, retaining the limit rectangles with areas in the range of 0.2A_ref to 5A_ref; retaining the corresponding limit rectangles for subsequent filtering or filtering according to a preset character size range; and using the aperture-offset table to perform aperture consistency verification.
[0013] Preferably, obtaining the potential position limit rectangles arranged horizontally includes: sorting them according to the y-coordinate of their centers, grouping limit rectangles with a center y-coordinate difference of less than 0.05mm into the same group; sorting the limit rectangles within each group according to their center x-coordinate; merging limit rectangles with an adjacent spacing of less than 0.5mm; for two limit rectangles with an adjacent spacing greater than 0.5mm and less than 1.5mm, searching the area between them, and when only one element of type line segment is found, merging the two limit rectangles and the area corresponding to the line segment together.
[0014] Preferably, when obtaining the potential position limit rectangle arranged vertically, the sorting and grouping relationship of the x and y coordinates are interchanged, and fusion is performed according to the spacing in the corresponding directions.
[0015] Preferably, the formation of the detection box includes: fusing or enclosing the potential position limit rectangle to determine the physical coordinate range of the image to be detected; converting the Gerber physical coordinates into image pixel coordinates according to a uniform rasterization resolution, and performing reverse mapping on the vertical coordinates according to the origin position of the image coordinate system; determining the detection box from the converted pixel coordinates; wherein the rasterization resolution is sufficient to preserve the finest line width and character spacing in the silkscreen to be identified.
[0016] Preferably, orientation normalization of the candidate image includes: when the number of columns in the candidate image is less than the number of rows, rotating the candidate image by 90 degrees to the horizontal direction of its long side, and recording the direction of the 90-degree rotation; inputting the candidate image into an orientation classifier, when the orientation label value returned by the orientation classifier is odd, rotating the corresponding candidate image clockwise by 180 degrees and recording the rotation mark, and keeping the current orientation when the orientation label value is even; and inputting the orientation-normalized candidate image into a position number character recognition model.
[0017] Preferably, when it is necessary to obtain the coordinate position of the recognition result in the original Gerber silkscreen layer, the origin of the cropping box, the 90-degree rotation direction, and the 180-degree rotation mark of the candidate image are saved; the coordinates obtained from character recognition are rotated in reverse order in the opposite order to the direction normalization, and the cropping box origin offset is superimposed to restore the pixel coordinates of the image to be detected; then the inverse transformation from pixel coordinates to the physical coordinates of the layer to be recognized is performed, and the reverse translation is performed according to the offset table corresponding to the cropping box; for the bottom silkscreen layer, the mirror transformation opposite to step S1 is performed to obtain the coordinate position in the original Gerber silkscreen layer.
[0018] This invention also provides an automatic identification system for Gerber silkscreen printing reference numbers, comprising: The silkscreen layer preprocessing module is used to read the Gerber working silkscreen layer, perform bottom layer mirroring, traverse elements and obtain element limit rectangles, establish an aperture-element relationship table, and generate the layer to be identified and the aperture-offset table according to the reversible two-dimensional offset corresponding to different apertures. The detection box acquisition module is used to perform network extraction, network limit rectangle screening, same aperture area screening, and horizontal and vertical two-dimensional fusion on the layer to be identified, generate potential position limit rectangles, and convert them into image pixel coordinate detection boxes. The image generation and recognition module is used to rasterize the layer to be recognized into a binary image to be detected, extract candidate images according to the detection box, perform direction normalization and character recognition, and output silkscreen position number and candidate region information.
[0019] Preferably, the system further includes a cross-aperture reconstruction module and a result mapping module; the cross-aperture reconstruction module is used to restore relevant elements or candidate regions to a unified local coordinate system and generate a composite candidate image based on the original spatial correlation of different aperture elements and their corresponding two-dimensional offsets; the result mapping module is used to restore the recognition results to the original Gerber silkscreen layer coordinates in reverse order based on the cropping, rotation, rasterization, two-dimensional offset and bottom mirror transformation records of the candidate image.
[0020] The present invention also provides an electronic device, including at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, wherein when the instructions are executed, the at least one processor performs the Gerber silkscreen reference number automatic identification method.
[0021] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the described method for automatic identification of Gerber silkscreen markings.
[0022] Compared with the prior art, the Gerber silkscreen marking automatic identification method and system of the present invention have the following advantages: 1. Grouping Gerber silkscreen primitives by aperture and using reversible two-dimensional offset to form spatial partitions can reduce the superposition and adjacent interference between primitives of different apertures; by setting a safety interval, it can avoid the misconnection of primitives at the partition boundary during network extraction.
[0023] 2. Preserve the original spatial relationships of different aperture elements, and restore cross-aperture elements to a unified local coordinate system to reconstruct the composite candidate region when needed. This can also take into account the case where the same character or position number is composed of multiple apertures.
[0024] 3. Before character recognition, candidate regions are generated using Gerber vector structures. The recognition range is gradually narrowed through network limit rectangle condition verification, same aperture area screening, aperture consistency verification, and horizontal and vertical two-dimensional fusion, thereby reducing the probability of non-character graphics entering the character recognition module.
[0025] 4. By employing two sets of candidate combination paths, one horizontal and one vertical, and combining a 0.05mm row and column grouping threshold, a 0.5mm direct fusion threshold, and line segment bridging judgment within the 0.5mm to 1.5mm range, it can handle different layout directions and common position number formats containing underscores and hyphens.
[0026] 5. By mirroring the bottom layer, rotating the candidate image 90 degrees, and correcting it 180 degrees after orientation classification, the candidate images of different layers and different arrangement orientations are unified to an orientation suitable for character recognition; after saving the coordinate transformation records of each level, the position of the recognition result in the original Gerber silkscreen layer can be restored in reverse order.
[0027] 6. The system identified 4,500 cases with the number of reference numbers ranging from 50 to 4,200, with an average recognition accuracy of 80.46% and an average time of 2.31 seconds. The longest case, which included 4,111 reference numbers, took 18.88 seconds. The system can automatically identify thousands of reference numbers within 20 seconds. [Attached Image Description] Figure 1 This is a flowchart of the automatic identification method for Gerber silkscreen markings of the present invention. Figure 2 This is a flowchart of the screen printing layer preprocessing and aperture partition offset process of the present invention; Figure 3 This is a flowchart of the detection frame acquisition and cross-aperture candidate reconstruction process of the present invention; Figure 4 This is a flowchart of the candidate image orientation normalization, character recognition, and coordinate recovery process of this invention.
Detailed Implementation Methods
[0028] It should be noted that in the embodiments of the present invention, all directional indications (such as up, down, left, right, front, back, etc.) are limited to relative positions on the specified view, rather than absolute positions.
[0029] Furthermore, in this invention, descriptions involving "first," "second," etc., are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0030] The present invention provides an automatic identification method for Gerber silkscreen markings, comprising silkscreen layer preprocessing, detection box acquisition, image to be detected generation, orientation normalization, and character recognition.
[0031] The silkscreen layer preprocessing includes the following steps: Read the working silkscreen layer of the target Gerber file and determine if it is the bottom silkscreen layer; mirror the bottom silkscreen layer with the center of its limiting rectangle or a preset layer center as the reference, while the top silkscreen layer retains its original orientation. Traverse all elements in the working silkscreen layer, obtaining and recording the primitive type, aperture, original geometric coordinates, and limiting rectangle of each element. Group elements with the same aperture into the same set, establish an aperture-element relationship table, and store them in a defined order.
[0032] For elements with different apertures, the relationships between intersecting, adjacent, or cross-aperture elements within a preset adjacency distance are further recorded in the original coordinate system. This relationship is used to handle cases where a character or a tag is composed of two or more apertures, avoiding the loss of the original spatial relationships between different aperture primitives after aperture partitioning.
[0033] Create the layer to be identified. Traverse the aperture-element relationship table, translate the elements corresponding to different apertures as a whole according to different two-dimensional offsets, and write them into the layer to be identified, and establish an aperture-offset table. Let the width of the working silkscreen layer's limit rectangle be W, the height be H, and the number of aperture types be K. Both the horizontal offset base and the vertical offset base are initialized to 0, and a maximum base determined by the arithmetic square root of K is set. When using the smallest integer M, which is not less than the arithmetic square root of K, as the two-dimensional offset grid scale, assign a unique grid position to each aperture in column-first or row-first order.
[0034] The lateral offset can be expressed as Δx = i_x × (W + Gx), and the longitudinal offset can be expressed as Δy = i_y × (H + Gy), where i_x and i_y are the grid base numbers corresponding to the current aperture, and Gx and Gy are non-negative safety intervals. When the original layer boundary primitives may come into contact with adjacent partitions after translation, Gx and Gy are taken as values greater than the geometric adjacency tolerance for network connectivity determination; when there is no risk of boundary contact, Gx and Gy can be taken as 0. Thus, W and H are used as the basic offset step sizes, and different aperture partitions are avoided from being misclassified as the same connected network at the boundary.
[0035] The detection box acquisition includes the following steps: First, traverse all elements in the layer to be identified and obtain the limiting rectangle of each element; then, establish a connected network in the same layer based on the intersection, connection or preset geometric adjacency relationship between elements, and calculate the limiting rectangle of the network in units of the connected network in the same layer.
[0036] The network's limiting rectangles are filtered based on certain conditions. Within each limiting rectangle, an element search is performed according to preset element retrieval rules. These rules predetermine the search targets, spatial relationships, and boundary inclusion methods. When the number of target elements in the search results is zero, the network's limiting rectangle is marked as a rectangle to be reviewed. To avoid mistakenly deleting legitimate characters composed of multiple line segments based on a single condition, the rectangle to be reviewed is checked against at least one of the following criteria: area, aspect ratio, fill rate, and scale statistics of characters with the same aperture. Removals are made if preset non-character criteria are met; otherwise, they are retained. For retained networks, the limiting rectangle and its offset are recorded.
[0037] The aperture-limit rectangle table is filtered by aperture area. When there are N limit rectangles for the same aperture, they are sorted in ascending order of area. The area at the third-to-last position after sorting is taken as the reference area A_ref, and limit rectangles with areas in the range of 0.2A_ref to 5A_ref are retained. Forced deletion is not performed using quantile areas; the corresponding limit rectangles are retained for subsequent filtering, or filtering is performed according to the range set based on the silkscreen character size. Further consistency verification is performed between the aperture identifier and the aperture-offset table.
[0038] The filtered limit rectangles are then sorted and merged in two dimensions. For horizontally arranged position numbers, they are sorted by the y-coordinate of their center. Limit rectangles with a center y-coordinate difference of less than 0.05 mm are grouped into the same row group, and then sorted by the center x-coordinate within each row group. Adjacent rectangles with a spacing of less than 0.5 mm are merged; when the spacing is greater than 0.5 mm but less than 1.5 mm, the middle region between the two rectangles is searched. If this region contains only one line segment element, that line segment is considered a candidate for underscore, hyphen, or internal connector in the position number, and the two rectangles, along with the line segment region, are merged. For vertically arranged position numbers, the sorting and grouping relationships of x and y are interchanged, and the same processing is performed according to the spacing in the corresponding direction.
[0039] 0.05mm, 0.5mm, and 1.5mm are preferred parameters. In Gerber files with significant differences in character size, the row and column grouping threshold, direct fusion threshold, and bridging search threshold can be adjusted proportionally based on statistical values of character height or width within the same aperture. However, a unified parameter determination rule is used for the same recognition task.
[0040] For characters or reference numerals composed of different apertures, based on the cross-aperture association records saved in the preprocessing stage, the relevant elements or candidate regions are reversed to a unified local coordinate system according to the two-dimensional offset of their respective apertures, while maintaining their original relative positions, thus reconstructing the composite candidate region. The composite candidate region can be directly rasterized from the restored vector elements to form a local binary image, or the image blocks of each partition can be combined according to their original relative coordinates to form a composite candidate image, thereby maintaining the complete outline of the cross-aperture characters.
[0041] After obtaining the potential limit rectangles, candidate regions are fused or enveloped to determine the physical coordinate range of the image to be detected, and the Gerber physical coordinates are converted to image pixel coordinates according to a uniform rasterization resolution. When the image coordinate system uses the top-left corner as the origin and the vertical axis downwards, the vertical coordinate in the Gerber coordinates is transformed; when using a coordinate system with the same direction as Gerber, it is directly transformed according to a uniform ratio. The transformed candidate limit rectangles form the detection box.
[0042] The layer to be identified is drawn as a binary image to be detected. The rasterization resolution is determined based on Gerber units, the finest silkscreen line width, character spacing, and the input size of the recognition model, so that the finest silkscreen line width and necessary character spacing are preserved in the image.
[0043] Initialize the tag number recognition module, setting the image or image data to be detected, the detection box set, and the recognition model parameters. Extract candidate images according to the detection boxes. If the number of columns in the candidate image is less than the number of rows, rotate it 90 degrees so that the long side is horizontal, and record the rotation direction. Input the candidate image into the orientation classifier; when the orientation label value is odd, rotate the candidate image 180 degrees clockwise and record the rotation mark; when the orientation label value is even, maintain the current orientation. Input the orientation-normalized candidate image into the tag number character recognition model to obtain the silkscreen tag number and candidate region information.
[0044] When it is necessary to restore the recognition result to the original Gerber coordinates, the origin of the cropping box, the 90-degree rotation direction, and the 180-degree rotation mark of the candidate image are saved. When the character recognition model returns local coordinates, inverse rotation is performed in the reverse order of direction normalization, and the cropping box origin offset is superimposed to restore the pixel coordinates of the image to be detected; then, an inverse transformation from pixel coordinates to the physical coordinates of the layer to be recognized is performed, and a reverse translation is performed according to the offset corresponding to the cropping box. The offset is obtained using the aperture-offset table; when the original working silkscreen layer is the bottom layer, a mirror transformation opposite to the preprocessing stage is performed to obtain the coordinate position in the original Gerber silkscreen layer. When character recognition only outputs the entire position number candidate box, the corresponding detection box can be directly used as the candidate region to perform subsequent inverse coordinate transformation.
[0045] This invention also provides an automatic Gerber silkscreen marking identification system, including a silkscreen layer preprocessing module, a detection box acquisition module, and an image generation and recognition module; it may further include a cross-aperture reconstruction module and a result mapping module. Each module performs the corresponding data processing steps in the above method.
[0046] The present invention also provides an electronic device and a computer-readable storage medium for performing the above-described method for automatic identification of Gerber silkscreen markings.
[0047] The technical problem this invention aims to solve is: how to stably construct candidate regions for reference points from Gerber vector primitives and automatically identify them when Gerber silkscreen layers lack semantic objects for reference points, different apertures and non-character primitives interfere with each other, characters are arranged horizontally or vertically, and there are underlines or hyphens, so as to reduce the workload and risk of omissions from manual inspection.
[0048] The present invention will be further described below with reference to the accompanying drawings.
[0049] See Figure 1 and Figure 2 Silkscreen layer preprocessing: Read the Gerber file and determine the working silkscreen layer to be processed. When the working silkscreen layer is the bottom layer, mirror it with the center of the limit rectangle of that layer as the mirror center; when the working silkscreen layer is the top layer, maintain the original orientation. After mirroring, record the mirror center and coordinate transformation relationship.
[0050] Traverse all elements in the working silk screen layer. The elements at least record the graphic primitive type, the affiliated aperture, original coordinates, and the element bounding rectangle. The elements are categorized according to the aperture identifiers to establish an aperture-element relationship table. The table entries include the aperture identifier and the element index set corresponding to the aperture, and are sorted deterministically according to the aperture number or the order of first occurrence.
[0051] Before two-dimensional offset, perform a spatial association check on elements of different apertures according to the original coordinates. When two elements of different apertures intersect, adjoin, or their shortest distance is less than a preset association distance, the association relationship between the two is recorded. The association record at least includes the element identifier, aperture identifier, and original coordinates. This record does not change the processing mode of independent offset of each aperture, and is used for subsequently restoring the original relative positions of cross-aperture graphic primitives.
[0052] Let the bounding rectangle of the working silk screen layer have a width W and a height H, and the number of aperture types be K. Create a blank layer to be identified. The horizontal offset base and the vertical offset base are initialized to 0, and the maximum base is set according to the arithmetic square root of K. Preferably, M=ceil(√K) is taken as the two-dimensional offset grid scale, and grid positions are allocated in a column-first manner; a row-first manner may also be adopted. Each aperture corresponds to a unique (i_x, i_y), where 0≤i_x<M and 0≤i_y<M, and the traversal ends after the K apertures are allocated.
[0053] Set Δx=i_x×(W+Gx) and Δy=i_y×(H+Gy) for the current aperture, translate all elements of this aperture as a whole and write them into the layer to be identified, and write the aperture identifier, Δx and Δy into the aperture-offset table. When there is no risk of contact between the boundaries of each partition, Gx and Gy are set to 0, and at this time the offset step sizes are W and H respectively; when boundary graphic primitives may come into contact, Gx and Gy are set to values greater than the geometric adjacency tolerance for network connectivity determination.
[0054] See Figure 3 . Same-layer network extraction and candidate screening: first traverse all elements in the layer to be identified and obtain the bounding rectangle of each element. Establish a spatial index, sequentially select an unvisited element as the starting element, retrieve elements that intersect with, adjoin, or satisfy a preset geometric adjacency condition with the starting element, and continue to search for unvisited adjacent elements until a complete same-layer connected network is formed. The above process is repeated for all elements to obtain a set of same-layer connected networks.
[0055] Calculate the network bounding rectangle of each same-layer connected network. Perform element search inside the network bounding rectangle. The retrieval objects, boundary inclusion modes and spatial relationships remain consistent in the same identification task. When the number of target elements is 0, the network bounding rectangle is first marked as a rectangle to be reviewed, and is not directly deleted.
[0056] A geometric verification is performed on the rectangle to be verified. The character scale range can be obtained statistically from candidate rectangles within the same aperture, and its area, aspect ratio, or fill rate can be used to determine whether it is a clearly non-character structure. For example, if the area of the rectangle to be verified significantly exceeds the character scale range within the same aperture and its aspect ratio conforms to long straight decorative lines or device outline features, it is judged as a non-character candidate and excluded; if its size is still within the character scale range, it is retained. This verification step is used to avoid mistakenly excluding legitimate characters composed of three or more line segments simply because no additional elements were detected internally.
[0057] Record the apertures used by the network and their limiting rectangles, and establish an aperture-limiting rectangle table. A network typically corresponds to a single aperture after aperture partitioning; when cross-aperture associations exist, they are reconstructed in subsequent steps using the original spatial association records from the preprocessing stage.
[0058] Aperture Area Filtering: Process each aperture individually in the aperture-limit rectangle table. Assume a certain aperture has N network limit rectangles. Sort the rectangles in ascending order of area, and take the area of the last three-quarters of the sorted rectangles as the reference area A_ref. The discrete index can be determined using ceil(0.75×N). Rectangles with an area not less than 0.2A_ref and not greater than 5A_ref are retained.
[0059] After area filtering is completed, the aperture identifier is used as the key to match the aperture-offset table, and only candidate rectangles whose offset source can be determined are retained.
[0060] Horizontal and vertical two-dimensional sorting and candidate fusion: For rectangles that have completed the filtering, the horizontal arrangement of the position numbers is processed first. Rectangles are sorted in ascending order according to the center y-coordinate, and rectangles with a center y-coordinate difference of less than 0.05mm are grouped into the same row group; within each row group, they are then sorted in ascending order according to the center x-coordinate.
[0061] The horizontal distance between two adjacent rectangles is the difference between the xmin of the latter rectangle and the xmax of the former rectangle; when the two rectangles overlap in the x-direction, the distance is recorded as 0. When the distance between adjacent rectangles is less than 0.5mm, the union of the two rectangles is taken as the limit rectangle and merged, and then compared with the next rectangle.
[0062] When the adjacent spacing is greater than 0.5mm and less than 1.5mm, an intermediate search area is established between the two. If there is only one line segment element in the intermediate search area, the line segment is used as a candidate for underscore, hyphen, or internal connector of position number, and the adjacent rectangles are merged with the line segment area; if this condition is not met, the current candidate position number is terminated and a new candidate position number is established.
[0063] The vertically arranged positions are processed according to the same principle, but the order and spacing calculation directions of x and y are interchanged.
[0064] 0.05mm, 0.5mm, and 1.5mm are a set of preferred values. For files with significantly different character sizes, the median height or width of candidate characters with the same aperture can be used as the scale benchmark, and row and column grouping thresholds, direct fusion thresholds, and bridging search thresholds can be generated according to pre-calibrated scaling factors.
[0065] Cross-aperture candidate reconstruction: When a character or reference number is formed by two or more apertures, different primitives are not directly recognized as a continuous image in separate aperture partitions. Based on the cross-aperture association records saved in the preprocessing stage, associated elements or candidate rectangles belonging to the same original local region are searched.
[0066] For each associated element, the Δx and Δy values corresponding to its respective aperture are read. The coordinates of the layer to be recognized are then subtracted from Δx and Δy to restore the unified local coordinate system after mirroring. The envelope rectangle of the associated element set is calculated based on the restored coordinates, and the original relative positions of each element are preserved before redrawing as a local binary image, forming a composite candidate image. Therefore, even if strokes constituting the same character are drawn using different apertures, the complete character outline can be restored before character recognition.
[0067] Image generation and coordinate correction: After obtaining the potential position limit rectangle, the overall physical coordinate range of the image to be detected is determined. The rasterization module sets a uniform number of pixels per millimeter or equivalent DPI. The rasterization resolution is set according to the finest silkscreen line width and character spacing, ensuring that the finest line width corresponds to at least one effective foreground pixel and that character spacing remains distinguishable.
[0068] When the image coordinate system has its origin at the top left corner, xmin in the physical coordinates is mapped to u_min, xmax to u_max, ymax to v_min, and ymin to v_max; the specific conversion coefficients are determined by the Gerber units and the rasterization resolution. Each potential location limit rectangle is transformed according to the same rule to form a detection box.
[0069] The layer to be recognized is drawn as a black and white binary image. Foreground pixels correspond to silkscreen primitives, and background pixels correspond to blank areas; the values of the foreground and background can be reversed according to the input requirements of the character recognition model.
[0070] See Figure 4 Direction normalization and character recognition: Initialize the character recognition module, setting the image or image data to be detected, the detection box set, and model parameters. Crop candidate images one by one according to the detection boxes, and record the origin coordinates of the cropping boxes in the image to be detected.
[0071] When the candidate image width is less than its height, it is rotated 90 degrees clockwise or counterclockwise to ensure the longer side is horizontal, and the rotation direction is recorded. The processed candidate image is then input into the orientation classifier. If the orientation label value is odd, it is rotated 180 degrees clockwise and the rotation mark is recorded; if the orientation label value is even, the current orientation is maintained.
[0072] The candidate image after orientation normalization is input into the tag number character recognition model to obtain the tag number string. When the recognition model provides the local coordinates of the character or text box, it simultaneously obtains the corresponding local limiting rectangle and recognition confidence score; when the recognition model only returns the string, the detection box corresponding to the input candidate image is used as the candidate region for that tag number.
[0073] Recognition Coordinate Recovery: When the character recognition model returns a local limiting rectangle, the inverse transformation is performed according to the recorded transformation order. If a 180-degree rotation has been performed, it is first rotated 180 degrees inversely around the center of the candidate image; if a 90-degree rotation has been performed, it is then rotated 90 degrees in the opposite direction. The local coordinates after the inverse rotation are added to the cropping box origin offset to restore the global pixel coordinates of the image to be detected.
[0074] Following the inverse transformation of the rasterization stage, the pixel coordinates of the image to be detected are restored to the physical coordinates of the layer to be identified. Based on the aperture of the candidate region, the aperture-offset table is consulted, and the corresponding Δx and Δy are subtracted to restore the coordinates to the working silkscreen layer after mirroring. If the original working silkscreen layer is the bottom layer, an inverse mirroring is performed according to the mirror center recorded in the preprocessing stage to obtain the coordinate positions in the original Gerber silkscreen layer.
[0075] The cross-aperture composite candidate image has been reconstructed in a unified local coordinate system. Its recognition result is directly restored to the coordinates of the working silkscreen layer after mirroring based on the local origin of the composite candidate image. Then, it is determined whether to perform reverse mirroring based on the layer.
[0076] This method was used to identify tag numbers in 4500 cases, with the number of tag numbers in each case ranging from 50 to 4200. The average recognition accuracy was 80.46%, and the average time was 2.31 seconds. The longest time taken was 18.88 seconds for a case containing 4111 tag numbers, demonstrating the ability to automatically identify thousands of tag numbers within 20 seconds.
[0077] Aperture partitions can be regular squares, stripes, or other deterministic layouts, as long as there is sufficient spacing between different partitions and reversible coordinate recovery can be performed using the recorded offsets.
[0078] For networks in the same layer, connected component search based on vector geometric intersection, adjacency search based on spatial index, or equivalent connectivity relationship establishment methods can be used.
[0079] The character recognition module can employ a recognition model capable of outputting character sequences; the direction classifier can employ a classification model capable of distinguishing between the current direction and the opposite direction. The specific structure of the recognition model does not affect the aforementioned Gerber primitive preprocessing, candidate region generation, and coordinate restoration steps.
[0080] For multi-board Gerber layouts, the layout can be divided into sub-regions according to the board frame area, and then the above processing steps can be performed separately. For applications that do not require outputting the original Gerber coordinates, the position number string and the corresponding detection box can be directly output after character recognition.
[0081] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any modifications, equivalent substitutions and improvements made within the concept of the present invention should be included within the patent protection scope of the present invention.
Claims
1. A method for automatic identification of Gerber silkscreen printing reference numbers, characterized in that, comprising: Step S1: Read the working silkscreen layer of the target Gerber file, and determine whether the working silkscreen layer is a bottom silkscreen layer; perform mirroring processing when the working silkscreen layer is the bottom silkscreen layer, and maintain the original direction when the working silkscreen layer is a top silkscreen layer; traverse elements in the working silkscreen layer, classify the elements according to aperture identifiers, and establish an aperture-element relationship table; create a to-be-identified layer, offset elements associated with each aperture according to reversible two-dimensional offsets corresponding to different apertures, write the offset elements into the to-be-identified layer, and establish an aperture-offset table; Step S2: Perform network extraction on the to-be-identified layer, and calculate a network limit rectangle by taking a connected network in the same layer as a unit; perform candidate screening according to an element retrieval result inside the network limit rectangle, the number of network constituent elements and network geometric features, and establish an aperture-limit rectangle table; Step S3: Perform same-aperture screening on the aperture-limit rectangle table according to aperture attributes and rectangle area, perform horizontal and vertical two-dimensional sorting and spacing fusion on the screened limit rectangles respectively, to obtain potential component reference designator limit rectangles; Step S4: Determine the physical coordinate range of a to-be-detected image according to the potential component reference designator limit rectangles, convert the potential component reference designator limit rectangles into image pixel coordinates to form detection frames, and rasterize the to-be-identified layer to generate a binary to-be-detected image; Step S5: Capture candidate images from the to-be-detected image according to the detection frames, perform character recognition after direction normalization is performed on the candidate images, to obtain silkscreen component reference designators and corresponding candidate region information thereof.
2. The method for automatic identification of Gerber silkscreen markings according to claim 1, characterized in that, The mirroring processing takes the center of the limit rectangle of the working silkscreen layer or a preset layer center as a mirroring reference, so that the bottom silkscreen layer is converted into a readable observation direction consistent with that of the top silkscreen layer; and a coordinate transformation relationship before and after mirroring is recorded.
3. The method for automatic identification of Gerber silkscreen printing reference numbers according to claim 1, characterized in that, ... The limit rectangle of the working silkscreen layer has a width W, a height H, and the number of aperture types is K; a horizontal offset base and a vertical offset base both take 0 as an initial value and are provided with a maximum base, and the maximum base is determined according to the arithmetic square root of K; when a minimum integer M not less than the arithmetic square root of K is adopted as a two-dimensional offset grid scale, the horizontal offset base i_x and the vertical offset base i_y satisfy 0≤i_x<M and 0≤i_y<M; a horizontal offset Δx=i_x×(W+Gx) and a vertical offset Δy=i_y×(H+Gy) are configured for each aperture, where Gx and Gy are non-negative safety intervals, and when there is a risk of partition boundary contact, Gx and Gy are greater than the geometric adjacency tolerance adopted for network connectivity determination.
4. The method for automatic identification of Gerber silkscreen markings according to claim 1, characterized in that, Before performing two-dimensional offset, establish cross-aperture association records according to the intersection, contact or preset adjacency relationship of different aperture elements in the original coordinate system; when a potential component reference designator region involves more than two apertures, according to the cross-aperture association records and the aperture-offset table, related elements or candidate regions are inversely restored to a unified local coordinate system, a composite candidate region is reconstructed according to the original relative positions thereof, and a composite candidate image for character recognition is generated based on the composite candidate region.
5. The method for automatic identification of Gerber silkscreen markings according to claim 1, characterized in that, The candidate screening includes: establishing a connected network at the same layer based on the intersection, connection, or preset geometric adjacency relationships between elements; calculating the network limit rectangle of each connected network at the same layer; performing element search within the network limit rectangle according to preset element retrieval rules; when the number of target elements in the search results is 0, marking the network limit rectangle as a rectangle to be verified; then verifying the rectangle to be verified based on at least one of the following: area, aspect ratio, fill rate, and scale statistics of characters with the same aperture; excluding the network limit rectangle if it meets the preset non-character criteria; after verification, recording the limit rectangles of the retained connected networks at the same layer and their offsets.
6. The method for automatic identification of Gerber silkscreen markings according to claim 1, characterized in that, The same aperture filtering includes: sorting the N limit rectangles corresponding to the same aperture in ascending order of area; taking the area of the limit rectangle located at the three-quarters position after sorting as the reference area A_ref, and retaining the limit rectangles with areas in the range of 0.2A_ref to 5A_ref; retaining the corresponding limit rectangles for subsequent filtering or filtering according to the preset character size range; and using the aperture-offset table to verify aperture consistency.
7. The method for automatic identification of Gerber silkscreen markings according to claim 1, characterized in that, Obtaining the potential limit rectangles arranged horizontally includes: sorting them according to the y-coordinate of their centers, grouping limit rectangles with a center y-coordinate difference of less than 0.05 mm into the same group; sorting the limit rectangles within each group according to their center x-coordinate; merging limit rectangles with adjacent spacing of less than 0.5 mm; for two limit rectangles with adjacent spacing greater than 0.5 mm and less than 1.5 mm, searching the area between them, and when only one element of type line segment is found, merging the two limit rectangles and the corresponding area of the line segment together.
8. The method for automatic identification of Gerber silkscreen markings according to claim 7, characterized in that, When obtaining the potential position limit rectangles arranged vertically, the sorting and grouping relationships of the x and y coordinates are interchanged, and fusion is performed according to the spacing in the corresponding directions.
9. The method for automatic identification of Gerber silkscreen markings according to claim 1, characterized in that, The formation of the detection box includes: fusing or enclosing the potential position limit rectangle to determine the physical coordinate range of the image to be detected; converting the Gerber physical coordinates into image pixel coordinates according to a uniform rasterization resolution, and performing reverse mapping on the ordinate according to the origin position of the image coordinate system; determining the detection box from the converted pixel coordinates; the rasterization resolution is sufficient to preserve the finest line width and character spacing in the silkscreen to be identified.
10. An automatic identification system for Gerber silkscreen printing reference numbers, characterized in that, include: The silkscreen layer preprocessing module is used to read the Gerber working silkscreen layer, perform bottom layer mirroring, traverse elements and obtain element limit rectangles, establish an aperture-element relationship table, and generate the layer to be identified and the aperture-offset table according to the reversible two-dimensional offset corresponding to different apertures. The detection box acquisition module is used to perform network extraction, network limit rectangle screening, same aperture area screening, and horizontal and vertical two-dimensional fusion on the layer to be identified, generate potential position limit rectangles, and convert them into image pixel coordinate detection boxes. The image generation and recognition module is used to rasterize the layer to be recognized into a binary image to be detected, extract candidate images according to the detection box, perform direction normalization and character recognition, and output silkscreen position number and candidate region information.
Citation Information
Patent Citations
Method and apparatus for detecting unqualified silk screen printing mark
CN101281027A
Method and apparatus for detecting unqualified silk screen printing mark
CN101281027B
Method and system for automatically examining and verifying Printed Circuit Board (PCB) project files
CN102819552A
Gerber file conversion method, system and device and storage medium
CN109710264A
Gerber file conversion methods, systems, devices, and storage media
CN109710264B
