Electronic product component detection method and system

By using a deformable template matching algorithm and RGB channel splitting and comparison, high-precision electronic product component inspection is achieved in multi-color temperature environments. This solves the matching drift problem caused by the deformation of the mobile phone frame surface in traditional inspection methods, and improves the inspection accuracy and reliability.

CN121033017BActive Publication Date: 2026-02-10FITOW (TIANJIN) DETECTION TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511544540.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-02-10
Estimated Expiration
2045-10-28

AI Technical Summary

Technical Problem

Traditional methods for inspecting electronic product components suffer from image edge distortion and parallax due to variations in the product's photographic position and height, resulting in unsatisfactory inspection results, especially in the inspection of mobile phone accessories where matching drift issues exist.

Method used

A deformable template matching algorithm is adopted, which achieves pixel-level detection through coarse positioning, fine matching and projection correction, combined with RGB channel splitting and comparison.

Benefits of technology

It significantly reduces the false negative rate under multi-color temperature mixed lighting conditions, achieving an accuracy similar to that of human eye detection, and solves the matching drift problem caused by the deformation of the curved surface of the mobile phone frame in traditional detection methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121033017B_ABST
    Figure CN121033017B_ABST
Patent Text Reader

Abstract

The application discloses an electronic product part detection method and system, which comprises the following steps: obtaining a to-be-detected image, extracting a to-be-detected part region; performing template matching on the to-be-detected part region, adjusting the to-be-detected image according to the matching relationship, projecting the to-be-detected image onto a reference image, and verifying whether the to-be-detected image and the reference image are coincident; when the to-be-detected image and the reference image are coincident, performing four-point correction on the projection contour of the to-be-detected part region and the reference contour; after the correction, cutting the reference image and the to-be-detected image into a reference sub-image and a to-be-detected sub-image respectively by using a marked detection frame; comparing the reference sub-image and the to-be-detected sub-image by using RGB channel splitting, and judging whether there is auxiliary material and whether the auxiliary material is deviated. The application has strong adaptability to shape changes, can process more extensive real-world scenes, and is especially good at matching non-rigid targets. The application solves the accurate positioning of a mobile phone outer frame, makes a to-be-detected product and a reference product highly coincident on an image, and thus can detect the accurate deviation of auxiliary material.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual inspection technology, and in particular to a method and system for inspecting electronic product components. Background Technology

[0002] In the mobile phone manufacturing process, a large number of auxiliary materials, such as metal foam, conductive pillars, and adhesive strips, are attached to the mid-frame. Machine vision is needed to detect the presence and misalignment of these auxiliary materials. This method uses C# and the Halcon algorithm library. The auxiliary materials to be detected are marked in the software, and the algorithm performs deformable template matching for positioning. The presence of auxiliary materials is detected based on color and texture differences. Misalignment is determined by whether there is an outer edge of the product within 0.2mm outside the frame. Traditional methods for inspecting electronic product components currently use rigid template matching. However, due to variations in the product's photographic position and height, the edges of the product in the image suffer from different lens distortions and parallaxes, making the detection of presence and misalignment ineffective. Summary of the Invention

[0003] Therefore, the purpose of this invention is to provide a method and system for testing electronic product components, which achieves pixel-level deviation detection for electronic product components to be tested, especially mobile phone accessories, through coarse positioning, fine matching, projection correction, etc.

[0004] To achieve the above objectives, the present invention provides a method for testing electronic product components, comprising the following steps:

[0005] S1. Obtain the image to be inspected and extract the area of ​​the component to be tested;

[0006] S2. A deformable template matching operator is used to perform local deformable matching on the area of ​​the component to be tested. The image to be tested is adjusted according to the matching relationship, and then projected onto the reference image to verify whether they coincide. When projecting the image to be tested onto the reference image to verify whether they coincide, the following steps are included:

[0007] Find the inverse matrix of the contour data in the reference image;

[0008] Multiply the inverse matrix with the positioning matrix to project the image to be tested onto the reference image. When the difference between the projected image of the image to be tested and the reference image is taken, and only the background color is retained, it is determined that the projected image of the image to be tested coincides with the reference image.

[0009] S3. When the drawing to be inspected coincides with the reference drawing, perform four-point correction on the projected contour of the area of ​​the part to be inspected and the reference contour.

[0010] S4. After correction, use the marked detection frame to cut the reference image and the image to be inspected into reference sub-image and image to be inspected respectively; use the RGB channel to split and compare the reference sub-image and the image to be inspected to determine whether there are auxiliary materials and whether the auxiliary materials are deviated.

[0011] A further preferred embodiment includes S0 before detection, which involves creating a template and labeling the detection box, including:

[0012] S01, Preset the model number of each excipient to be tested;

[0013] S02. Using the baseline diagram of each auxiliary material, extract the baseline contour and generate a template;

[0014] S03. Mark the detection box for each type of excipient and use the detection box to display the movable range of each excipient.

[0015] More preferably, S1 includes: when extracting the test component area from the test image, first perform coarse positioning, extract the coarse positioning area to form a thumbnail, and record the original matrix of the test image and the thumbnail;

[0016] When performing template matching on the area of ​​the component to be tested in S2, the following is included:

[0017] Local deformable matching is performed using a deformable template matching operator;

[0018] Multiple locally deformable matchings from different angles are used to select the best matching result and the resulting contour is used as the final contour for template matching.

[0019] When adjusting the image to be inspected based on the matching relationship, the process includes: performing an affine transformation on the image to be inspected based on the original matrix to achieve contour positioning in the image to be inspected, and recording the matrix after the affine transformation of the original matrix as the positioning matrix.

[0020] More preferably, when using a deformable template matching operator for local deformable matching, the following steps are included:

[0021] S201. Based on the initial pose (x, y, θ) obtained from coarse localization, calculate the expected position of each feature point Pi in the template in image I;

[0022] S202. Define a local search window W_i centered on the expected location. The size of the window is determined by a preset locality constraint.

[0023] S203. Within the search window W_i, slide the descriptor D_i of feature point Pi and calculate the similarity with the corresponding region of image I.

[0024] S204. Obtain a response map R_i for that point. Each pixel value in the response map represents the matching confidence of point Pi at that location. Select the location with the highest confidence as the best candidate location for feature point Pi.

[0025] More preferably, in S202, the preset locality constraint includes:

[0026] Define the line connecting feature point Pi and its neighboring point Pj as an edge of the deformable template; use the maximum and minimum values ​​of feature point Pi and its neighboring point Pj as constraints for each edge E_ij.

[0027] Using a set of known deformed sample images, we statistically analyze the distribution of length changes for each side, and determine the length range based on the distribution of length changes for each side.

[0028] Save the deformable template formed by the final determined length range as a structured object:

[0029] Template = {P, D, E, L0, L_min, L_max},

[0030] Wherein, Template represents the template model structure; P is the geometric and grayscale description of the template itself, represented by feature vectors: gradient vector, direction vector, and deep learning embedding vector; D is the effective region of the template in the image, represented by the mask region; E is the similarity measure between the template and the candidate window, represented by the NCC normalized cross-correlation coefficient; L0 is the original resolution level used when constructing the template; and L_max is the highest resolution level backtracked during the search.

[0031] More preferably, when projecting the image to be inspected onto the reference image, the changed coordinates are calculated using the following formula:

[0032] X=

[0033] Y=

[0034] Z=

[0035] Where X, Y, and Z are the transformed pixel coordinates, x1, y1, and z1 are the original pixel coordinates, a is the distance deviation in the x-direction before and after the projection transformation, b is the distance deviation in the y-direction before and after the projection transformation, c is the distance deviation in the z-direction before and after the projection transformation; α is the angle deviation in the x-direction before and after the projection transformation, β is the angle deviation in the y-direction before and after the projection transformation, and γ is the angle deviation in the z-direction before and after the projection transformation.

[0036] More preferably, in S3, when the image to be inspected coincides with the reference image, the four-point correction of the projected contour of the area of ​​the component to be inspected and the reference contour includes:

[0037] When the projected image of the image to be inspected coincides with the reference image, the template outline of the reference image is converted into lines and drawn onto the image to be inspected.

[0038] Extract the product outline of the component area from the reference image and the image to be inspected respectively;

[0039] The product outline is divided into straight line segments and curved line segments;

[0040] Connect and extend adjacent straight line segments to form two horizontal line segments and two vertical line segments;

[0041] The two horizontal line segments and the two vertical line segments are fitted into four straight lines by using the line fitting operator;

[0042] Find the pairwise intersections of the horizontal and vertical lines to obtain the coordinates of the four corner points;

[0043] Establish the mapping relationship from corner point A of the reference image to corner point B of the image to be inspected, substitute the coordinates of the four corner points, and solve for the projection matrix parameters;

[0044] The projection matrix is ​​applied to the image to be inspected, perspective transformation is performed, and the pixel-level difference between the contour of the image to be inspected and the contour of the reference image is calculated.

[0045] Further preferably, S4 includes:

[0046] Using the labeled detection boxes, the baseline image and the image to be inspected are respectively cropped into a baseline sub-image and an image to be inspected;

[0047] The reference sub-image and the sub-image to be tested are split into three RGB channels respectively; the gray value difference between the reference sub-image and the sub-image to be tested is calculated in each channel; if the gray value difference of each channel is less than or equal to a preset threshold, it is determined that the auxiliary material is present; otherwise, it is determined that the auxiliary material is not present.

[0048] A further preferred embodiment, when excipients are present, also includes calculating excipient deviations:

[0049] Extend each edge of the detection frame outward by a fixed length, calculate the difference between the reference sub-image and the sub-image to be inspected using the offset detection function, and detect whether the auxiliary material is offset by comparing the gray values.

[0050] The present invention also provides an electronic product component inspection system for implementing the above-mentioned electronic product component inspection method, comprising: an image acquisition module, a template matching module, a contour correction module, and a deviation judgment module;

[0051] The image acquisition module is used to acquire the image to be inspected and extract the area of ​​the component to be tested.

[0052] The template matching module is used to perform deformable template matching on the area of ​​the part to be tested, adjust the image to be tested according to the matching relationship, and project the image to be tested onto the reference image to verify whether they overlap.

[0053] The contour correction module is used to perform four-point correction of the projected contour of the part to be tested and the reference contour when the drawing to be inspected coincides with the reference drawing.

[0054] The deviation judgment module is used to cut the reference image and the image to be inspected into reference sub-images and the image to be inspected respectively using the marked detection box after correction; and to compare the reference sub-image and the image to be inspected by splitting the RGB channel to determine whether there are auxiliary materials and whether the auxiliary materials are deviated.

[0055] This application discloses a method and system for inspecting electronic product components. It addresses the issue of misalignment caused by deformation of the phone's frame and compression deformation of components with small, irregular shapes, such as mobile phone accessories, through deformable template matching. This overcomes the misalignment problem inherent in traditional rigid matching methods. The system employs a projection transformation matrix to correct the overlap between the reference image and the image to be inspected. By fitting the projection matrix to the contour corner points, it completely eliminates trapezoidal distortion caused by height differences. Furthermore, it uses RGB three-channel splitting and comparison to quantify the grayscale differences in the presence or absence of accessories, ensuring that even if one channel fails (e.g., red light overexposure), the remaining channels can still be used for detection. In workshop environments with mixed color temperatures and lighting, this significantly reduces the false negative rate, approaching the limits of human visual discrimination. By utilizing a positioning-discrimination-quantization approach, and adjusting positioning after feeding back the quantization results, a closed-loop inspection chain with multiple technologies working synergistically is formed, elevating industrial vision inspection to a new level. Attached Figure Description

[0056] Figure 1 This is a flowchart illustrating a method for testing electronic product components according to the present invention.

[0057] Figure 2 This is a schematic diagram of the electronic product component testing system of the present invention.

[0058] Figure 3 This is a flowchart illustrating the local deformable matching of the deformable template matching operator of the present invention. Detailed Implementation

[0059] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0060] like Figure 1 As shown, one embodiment of the present invention provides a method for detecting electronic product components, which performs coarse positioning, fine matching, and projection correction for irregularly shaped micro-components, especially mobile phone accessories, to achieve pixel-level detection accuracy. The method includes the following steps (using mobile phone accessories as an example):

[0061] The process before detection also includes S0, which creates a template and labels the detection boxes, including:

[0062] S01. Preset the model of each auxiliary material to be tested; first, place the standard sample in the conveyor belt, adjust the camera's exposure and gain to make the product and the conveyor belt have obvious edge color difference, which is convenient for extracting the product's outline later; create a new product model and write the corresponding process in the software, and import the newly created product data and images into the annotation interface.

[0063] S02. Using the baseline image of each auxiliary material, extract the baseline contour and generate a template; put the baseline image into the algorithm to create the template, and use threshold segmentation, morphological analysis and Canny edge detection operators to extract the product contour. Based on the contour information, use boundary expansion to establish template data, find the contour in the baseline image, save the outer contour of the baseline image to the hard drive, and the product annotation is completed.

[0064] S03. Mark the detection frame for each auxiliary material and use the detection frame to display the movable range of each auxiliary material; in the marking interface, mark the movable range of each auxiliary material by drawing a frame. If it exceeds 0.2mm (can be set), it is considered that the auxiliary material is misaligned. If there is no product in the frame, it is considered that the auxiliary material is missing.

[0065] During formal testing, the following are included:

[0066] S1. Obtain the image to be tested and extract the area of ​​the excipient to be tested; more preferably, S1 includes:

[0067] When extracting the test area of ​​the auxiliary material based on the test image, coarse positioning is first performed, the coarse positioning area is extracted to form a thumbnail, and the original matrix of the test image and the thumbnail is recorded.

[0068] S2. Perform template matching on the area of ​​the auxiliary material to be tested, adjust the image to be tested according to the matching relationship, and project the image to be tested onto the reference image to verify whether they overlap; S2 includes template matching on the area of ​​the auxiliary material to be tested, including:

[0069] Local deformable matching is performed using a deformable template matching operator;

[0070] Multiple locally deformable matchings from different angles are used to select the best matching result and the resulting contour is used as the final contour for template matching.

[0071] When adjusting the image to be inspected based on the matching relationship, the following are included:

[0072] The matched final contour is affinely transformed onto the image to be inspected based on the original matrix to achieve contour localization in the image to be inspected. The matrix after the affine transformation of the original matrix is ​​recorded as the localization matrix.

[0073] like Figure 3 As shown, the process of using a deformable template matching operator for local deformable matching includes the following steps:

[0074] S201. Based on the initial pose (x, y, θ) obtained from coarse localization, calculate the expected position of each feature point Pi in the template in image I; x and y are the initial horizontal and vertical coordinates, respectively, and θ is the initial angle.

[0075] S202. Define a local search window W_i centered on the expected position. The size of the window is determined by a preset locality constraint (i.e., the possible range of movement of the point).

[0076] More preferably, in S202, the preset locality constraint includes:

[0077] Define the line connecting feature point Pi and its neighboring point Pj as an edge of the deformable template; use the maximum and minimum values ​​of feature point Pi and its neighboring point Pj as constraints for each edge E_ij.

[0078] Using a set of known deformed sample images, we statistically analyze the distribution of length changes for each side, and determine the length range based on the distribution of length changes for each side.

[0079] The deformable template formed by the final determined length range is saved as a structured object: Template = {P, D, E, L0, L_min, L_max}. Here, Template represents the template model structure; P – the geometric and grayscale description of the Pattern template itself, which can be represented by feature vectors (gradient vectors, direction vectors, deep learning embedding vectors); D – the effective region of the template in the image (or Definition Domain), often represented by a mask or convex hull; E – the similarity metric between the template and the candidate window (E – Energy / Response / Score Map), representing the NCC normalized cross-correlation coefficient; L0 – the Base Level (pyramid level 0) – the "original resolution" level used when constructing the template. Multi-scale search downsamples from L0 level by level to form an image pyramid, accelerating coarse localization while preserving details; L_min – the "coarsest" level allowed during the Minimum Pyramid Level search. The smaller the value, the larger the downsampling factor, the smaller the search window, and the faster the speed, but the lower the positioning accuracy; typically L_min ≥ 2; L_max – the "finest" level to which the Maximum Pyramid Level is backed during the search. Generally, L_max = 0 (back to the original image), but it can also be limited to 1 to save memory / time. The final matching coordinates and angles are refined to sub-pixel levels at the L_max layer.

[0080] S203. Within the search window W_i, slide the descriptor D_i of feature point Pi and perform similarity calculation (such as zero-mean normalized cross-correlation ZNCC) with the corresponding region of the image.

[0081] S204. Obtain a response map R_i for that point. Each pixel value in the response map represents the matching confidence of point Pi at that location. Select the location with the highest confidence as the best candidate location for feature point Pi.

[0082] More preferably, in S2, when the image to be inspected is projected onto the reference image to verify whether they overlap, the process includes:

[0083] Find the inverse matrix of the contour data in the reference image;

[0084] Multiply the inverse matrix with the positioning matrix to project the image to be tested onto the reference image. When the difference between the projected image of the image to be tested and the reference image is taken, and only the background color is retained, it is determined that the projected image of the image to be tested coincides with the reference image.

[0085] Furthermore, when projecting the image to be inspected onto the reference image, the transformed coordinates are calculated using the following formula:

[0086] X=

[0087] Y=

[0088] Z=

[0089] Where X, Y, and Z are the transformed pixel coordinates, x1, y1, and z1 are the original pixel coordinates, a is the distance deviation in the x-direction before and after the projection transformation, b is the distance deviation in the y-direction before and after the projection transformation, and c is the distance deviation in the z-direction before and after the projection transformation; α is the angle deviation in the x-direction before and after the projection transformation, β is the angle deviation in the y-direction before and after the projection transformation, and γ is the angle deviation in the z-direction before and after the projection transformation. In this application, a, b, and c are the XYZ deviations obtained from the coordinate difference matrix after template matching between the reference image and the image to be detected, and α, β, and γ are the angle deviations around XYZ after template matching.

[0090] S3. When the image to be tested coincides with the reference image, perform four-point correction on the projected contour of the area to be tested and the reference contour; specifically including:

[0091] When the projected image of the image to be inspected coincides with the reference image, the template outline of the reference image is converted into lines and drawn onto the image to be inspected.

[0092] Extract the product outline of the auxiliary material area from the baseline image and the image to be inspected respectively;

[0093] The product outline is divided into straight line segments and curved line segments;

[0094] Connect and extend adjacent straight line segments to form two horizontal line segments and two vertical line segments;

[0095] The two horizontal line segments and the two vertical line segments are fitted into four straight lines by using the line fitting operator;

[0096] Find the pairwise intersections of the horizontal and vertical lines to obtain the coordinates of the four corner points;

[0097] Establish the mapping relationship from corner point A of the reference image to corner point B of the image to be inspected, substitute the coordinates of the four corner points, and solve for the projection matrix parameters;

[0098] The projection matrix is ​​applied to the image to be inspected, perspective transformation is performed, and the pixel-level difference between the contour of the image to be inspected and the contour of the reference image is calculated.

[0099] When the difference exceeds the threshold, a second four-point correction is performed.

[0100] S4. After correction, use the marked detection frame to cut the reference image and the image to be inspected into reference sub-image and image to be inspected respectively; use the RGB channel to split and compare the reference sub-image and the image to be inspected to determine whether there are auxiliary materials and whether the auxiliary materials are deviated.

[0101] Using the labeled detection boxes, the baseline image and the image to be inspected are respectively cropped into a baseline sub-image and an image to be inspected;

[0102] The reference sub-image and the sub-image to be tested are split into three RGB channels respectively; the gray value difference between the reference sub-image and the sub-image to be tested is calculated in each channel; if the gray value difference of each channel is less than or equal to a preset threshold, it is determined that the auxiliary material is present; otherwise, it is determined that the auxiliary material is not present.

[0103] In this application, the grayscale differences of each channel can also be weighted and fused. When the weighted fused grayscale difference is less than or equal to a second preset threshold, it is determined that auxiliary material exists; otherwise, it is determined that auxiliary material does not exist. In this embodiment, when weighting and fusing the grayscale differences of each channel, a fixed weight method can be used, which divides the RGB three channels into different weights based on historical data and then performs fusion according to these weights. However, images are usually affected by changes in lighting and background. Therefore, in this embodiment, the information entropy of each channel image is calculated to divide the weights. The higher the entropy value, the richer the information of the channel, and the higher the weight.

[0104] A further preferred embodiment, when excipients are present, also includes calculating excipient deviations:

[0105] Extend each edge of the detection frame outward by a fixed length, calculate the difference between the reference sub-image and the sub-image to be inspected using the offset detection function, and detect whether the auxiliary material is offset by comparing the gray values.

[0106] Specifically, it includes:

[0107] S401. Based on the aligned reference sub-image and the sub-image to be inspected obtained above, as well as the marked detection box;

[0108] S402. Extend each edge of the detection frame outward by a fixed length as a buffer zone. Ideally, this area is a pure background. The buffer zone formed by extending the detection frame serves as the detection area for offset detection.

[0109] S403. Using the offset detection function to calculate the difference is to quantify the difference between the reference sub-map and the sub-map to be tested in the extended region.

[0110] Using the coordinates of the four extended regions of the buffer (top, bottom, left, and right), corresponding image blocks are cropped from the baseline and test images, respectively.

[0111] Calculate the absolute difference image between two image patches. That is, subtract the reference image and the test image in the upper buffer to form the upper absolute difference image, and so on to obtain the lower absolute difference image, the left absolute difference image, and the right absolute difference image.

[0112] S404. Analyze the absolute difference image, that is, calculate the difference map of each of the four edge regions.

[0113] For example, calculate the average value of the pixels in the *th row of the upper absolute difference image. If this value suddenly increases, it indicates that the filler material may have shifted upwards, causing the top area, which should be the background, to now appear as filler material.

[0114] Similarly, calculate the lower absolute difference image, the left absolute difference image, and the right absolute difference image to determine whether a deviation has occurred in the corresponding direction.

[0115] S405. Determine the magnitude of the deviation by comparing the grayscale values ​​to detect the calculated result of the deviation difference of the auxiliary materials.

[0116] Setting a threshold: An empirical threshold is needed. This threshold needs to be determined through a large number of experiments, so that it can capture the true offset while ignoring minor lighting and image noise.

[0117] For each edge region (top, bottom, left, right), if its calculated difference value (such as the average difference of a specific row / column as described above) is greater than the empirical threshold.

[0118] Then it can be determined that the auxiliary material has been displaced in the opposite direction, and the magnitude of the displacement is defined according to the position of the row / column.

[0119] The present invention also provides an electronic product component inspection system for implementing the above-mentioned electronic product component inspection method, comprising: an image acquisition module, a template matching module, a contour correction module, and a deviation judgment module;

[0120] The image acquisition module is used to acquire the image to be inspected and extract the area of ​​the component to be tested.

[0121] The template matching module is used to perform template matching on the area of ​​the component to be tested, adjust the image to be tested according to the matching relationship, and project the image to be tested onto the reference image to verify whether they overlap.

[0122] The contour correction module is used to perform four-point correction of the projected contour of the part to be tested and the reference contour when the drawing to be inspected coincides with the reference drawing.

[0123] The deviation judgment module is used to cut the reference image and the image to be inspected into reference sub-images and the image to be inspected respectively using the marked detection box after correction; and to compare the reference sub-image and the image to be inspected by splitting the RGB channel to determine whether there are auxiliary materials and whether the auxiliary materials are deviated.

[0124] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.

Claims

1. A method for testing electronic product components, characterized in that, Includes the following steps: S1. Obtain the image to be inspected and extract the area of ​​the component to be tested; S2. Perform local deformable matching on the area of ​​the component to be tested using a deformable template matching operator. The process of performing local deformable matching using the deformable template matching operator includes the following steps: S201. Based on the initial pose (x, y, θ) obtained from coarse localization, calculate the expected position of each feature point Pi in the template in the image; S202. Define a local search window W_i centered on the expected location. The size of the window is determined by a preset locality constraint. S203. Within the search window W_i, slide the descriptor D_i of feature point Pi and calculate the similarity with the corresponding region of image I. S204. Obtain the response map R_i of a feature point Pi. Each pixel value in the response map represents the matching confidence of the feature point Pi at that position. Select the position with the highest confidence as the best candidate position of the feature point Pi. The image to be inspected is adjusted according to the matching relationship, and then projected onto the reference image to verify whether they overlap. The verification of overlap includes the following process: Find the inverse matrix of the contour data in the reference image; Multiply the inverse matrix with the positioning matrix to project the image to be tested onto the reference image. When the difference between the projected image of the image to be tested and the reference image is taken, and only the background color is retained, it is determined that the projected image of the image to be tested coincides with the reference image. S3. When the drawing to be inspected coincides with the reference drawing, perform four-point correction on the projected contour of the area of ​​the part to be inspected and the reference contour. S4. After correction, use the marked detection frame to cut the reference image and the image to be inspected into reference sub-image and image to be inspected respectively; use the RGB channel to split and compare the reference sub-image and the image to be inspected to determine whether there are auxiliary materials and whether the auxiliary materials are deviated.

2. The method for testing electronic product components according to claim 1, characterized in that, The process before detection also includes S0, which creates a template and labels the detection boxes, including: S01, Preset the model number of each excipient to be tested; S02. Using the baseline diagram of each auxiliary material, extract the baseline contour and generate a template; S03. Mark the detection box for each type of excipient and use the detection box to display the movable range of each excipient.

3. The method for testing electronic product components according to claim 1, characterized in that, S1 includes: when extracting the test component area from the test image, first perform coarse positioning, extract the coarse positioning area to form a thumbnail, and record the original matrix of the test image and the thumbnail; When performing template matching on the area of ​​the component to be tested in S2, the following is included: Local deformable matching is performed using a deformable template matching operator; Multiple locally deformable matchings from different angles are used to select the best matching result and the resulting contour is used as the final contour for template matching. When adjusting the image to be inspected based on the matching relationship, the process includes: performing an affine transformation on the image to be inspected based on the original matrix to achieve contour positioning in the image to be inspected, and recording the matrix after the affine transformation of the original matrix as the positioning matrix.

4. The method for testing electronic product components according to claim 3, characterized in that, In S202, the preset locality constraint includes: Define the line connecting feature point Pi and its neighboring point Pj as an edge of the deformable template; use the maximum and minimum values ​​of feature point Pi and its neighboring point Pj as constraints for each edge E_ij. Using a set of known deformed sample images, we statistically analyze the distribution of the length variation of each side, and determine the length range based on the distribution of the length variation of each side. Save the deformable template formed by the final determined length range as a structured object: Template = {P,D, E, L0, L_min, L_max}. Here, Template represents the template model structure; P is the geometric and grayscale description of the template itself, using feature vectors: gradient vector, direction vector, and deep learning vector. of Embedded vector representation; D is the effective region of the template in the image, represented by the mask region; E is the similarity measure between the template and the candidate window, representing: NCC normalized cross-correlation coefficient; L0 is the original resolution level used when constructing the template; L_max is the highest resolution level backtracked during the search.

5. The method for testing electronic product components according to claim 3, characterized in that, In S2, When projecting the image to be inspected onto the reference image, the changed coordinates are calculated using the following formula: X= Y= Z= Where X, Y, and Z are the transformed pixel coordinates, x1, y1, and z1 are the original pixel coordinates, a is the distance deviation in the x-direction before and after the projection transformation, b is the distance deviation in the y-direction before and after the projection transformation, c is the distance deviation in the z-direction before and after the projection transformation; α is the angle deviation in the x-direction before and after the projection transformation, β is the angle deviation in the y-direction before and after the projection transformation, and γ is the angle deviation in the z-direction before and after the projection transformation.

6. The method for testing electronic product components according to claim 5, characterized in that, In S3, when the drawing to be inspected coincides with the reference drawing, the four-point correction of the projected contour of the area of ​​the part to be inspected and the reference contour includes: When the projected image of the image to be inspected coincides with the reference image, the template outline of the reference image is converted into lines and drawn onto the image to be inspected. Extract the product outline of the component area from the reference image and the image to be inspected respectively; The product outline is divided into straight line segments and curved line segments; Connect and extend adjacent straight line segments to form two horizontal line segments and two vertical line segments; The two horizontal line segments and the two vertical line segments are fitted into four straight lines by using the line fitting operator; Find the pairwise intersections of the horizontal and vertical lines to obtain the coordinates of the four corner points; Establish the mapping relationship from corner point A of the reference image to corner point B of the image to be inspected, substitute the coordinates of the four corner points, and solve for the projection matrix parameters; The projection matrix is ​​applied to the image to be inspected, perspective transformation is performed, and the pixel-level difference between the contour of the image to be inspected and the contour of the reference image is calculated.

7. The method for testing electronic product components according to claim 1, characterized in that, S4 includes: Using the labeled detection boxes, the baseline image and the image to be inspected are respectively cropped into a baseline sub-image and an image to be inspected; The reference sub-image and the sub-image to be tested are split into three RGB channels respectively; the gray value difference between the reference sub-image and the sub-image to be tested is calculated in each channel; if the gray value difference of each channel is less than or equal to a preset threshold, it is determined that the auxiliary material is present; otherwise, it is determined that the auxiliary material is not present.

8. The method for testing electronic product components according to claim 7, characterized in that, When excipients are present, the calculation of excipient deviation is also included: Extend each edge of the detection frame outward by a fixed length, calculate the difference between the reference sub-image and the sub-image to be inspected using the offset detection function, and detect whether the auxiliary material is offset by comparing the gray values.

9. A component testing system for electronic products, characterized in that, The steps for implementing the electronic product component testing method according to any one of claims 1-8 include: an image acquisition module, a template matching module, a contour correction module, and a deviation judgment module; The image acquisition module is used to acquire the image to be inspected and extract the area of ​​the component to be tested. The template matching module is used to perform deformable template matching on the area of ​​the part to be tested, adjust the image to be tested according to the matching relationship, and project the image to be tested onto the reference image to verify whether they overlap. The contour correction module is used to perform four-point correction of the projected contour of the part to be tested area and the reference contour when the test drawing coincides with the reference drawing; the deviation judgment module is used to cut the reference drawing and the test drawing into reference sub-drawings and test sub-drawings respectively using the marked detection box after correction; the reference sub-drawings and test sub-drawings are compared using RGB channels to determine whether there are auxiliary materials and whether the auxiliary materials are deviated.

Citation Information

Patent Citations

  • Printed circuit board defect image registration method, apparatus and device, and storage medium

    CN114170229A

  • Mechanical and electrical product neglected loading detection method based on virtual and real edge matching

    CN115034577A

  • Projection image correction method and device, equipment and storage medium

    CN117998065A