PCB board piece sorting and positioning method based on machine vision
Patent Information
- Application Number
- CN202610973809.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-01
- Publication Date
- 2026-10-09
AI Technical Summary
[0005]为解决现有技术因PCB翘曲及光照干扰导致定位精度低、缺乏可靠性评估的技术问题,本发明提供了一种基于机器视觉的PCB板件分拣定位方法,包括:
式中,表示置信度评分;
为所有有效定位特征点的特征显著度之和;
为一致性系数;
为有效距离标准差;
为有效平均分布距离;
为自然对数函数;
为第五极小正数。
Smart Images

Figure CN122888018A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology. More specifically, this invention relates to a machine vision-based method for sorting and positioning PCB boards. Background Technology
[0002] In the electronics manufacturing services industry, the automatic sorting and positioning of PCB boards is a key link in surface mount technology production lines. As modern electronic products rapidly develop towards miniaturization, integration, and high density, the size of the pads on PCB boards is shrinking dramatically, and the layout of electronic components is becoming increasingly compact. This trend of precision manufacturing places extremely high demands on the visual positioning accuracy and stability of automated production equipment. That is, the equipment not only needs to capture images during high-speed transmission, but also needs to achieve precise positioning at the micron level to ensure production efficiency and yield.
[0003] Existing technologies typically employ visual positioning methods based on template matching or edge detection. Specifically, this method uses a high-resolution industrial camera to acquire real-time grayscale images of PCB boards, uses preset reference points or board edge contours as key features, performs grayscale correlation matching or geometric feature comparison with a standard reference template, and calculates the translation and rotation angles in the image coordinate system to determine the position and orientation of the board in the two-dimensional plane, thereby guiding the subsequent robotic arm to perform sorting or mounting actions.
[0004] However, existing technologies have significant limitations when facing complex and ever-changing real-world production environments. First, PCB boards inevitably experience slight warping after multiple processes, causing non-linear geometric shifts in the actual pad positions relative to the theoretical template. Traditional rigid template matching algorithms struggle to adapt to this elastic deformation, directly impacting positioning accuracy. Second, the solder paste or plating on the pad surface has high reflectivity, making it highly susceptible to changes in ambient lighting in the workshop. This easily creates unstable highlights or shadows in the image, leading to edge extraction algorithm failure or feature center drift. Finally, existing sorting strategies often rely solely on a single threshold for pass / fail judgment based on matching scores, lacking a multi-dimensional assessment of the overall graspability and positioning reliability of the board. This makes it difficult to effectively distinguish between perfectly matched and barely matched boards, resulting in fluctuating failure rates during subsequent robotic arm grasping. Therefore, existing technologies cannot extract deep feature information characterizing the true posture and grasping reliability of PCBs affected by lighting interference and deformation, leading to technical problems such as low positioning accuracy and lack of reliability assessment due to PCB warping and lighting interference. Summary of the Invention
[0005] To address the technical problems of low positioning accuracy and lack of reliability assessment in existing technologies due to PCB warping and light interference, this invention provides a PCB board sorting and positioning method based on machine vision, comprising: PCB board surface images are acquired using an industrial camera and preprocessed to extract candidate pad regions and their geometric grayscale features. The feature saliency of each candidate pad region is calculated based on the difference between its grayscale value and the average grayscale value of the PCB board background. Effective positioning feature points are selected based on these saliency values, and the weighted centroid coordinates of the PCB board are calculated. The effective distance standard deviation and effective average saliency are obtained based on the distance relationship between the effective positioning feature points and the weighted centroid coordinates of the PCB board. The consistency coefficient of the PCB board is calculated based on the spatial distribution of the effective positioning feature points. This consistency coefficient is then combined with the... The system calculates a confidence score based on the statistical characteristics of the number and significance of the features, which comprehensively represents the image clarity, board flatness, and the rationality of the feature distribution. Based on the confidence score, it generates sorting instructions that include passing or rejecting. For PCB boards that generate a passing instruction, it calculates the rotation angle based on effective positioning feature points. It converts the weighted centroid coordinates and rotation angle of the PCB board into the physical coordinates of the robotic arm based on the hand-eye calibration matrix pre-stored in the system, and sends the instruction. The confidence score and the sorting instruction are labeled on the surface image of the PCB board, generating a visualization result image and storing it.
[0006] This invention reduces interference from factors such as lighting by preprocessing and extracting images, accurately separating effective feature regions. By calculating multiple key indicators such as feature saliency and consistency coefficient, it achieves multi-dimensional evaluation of board status, no longer relying on a single judgment standard. Through reasonable threshold settings and sorting logic, it effectively distinguishes between qualified and unqualified boards, reducing sorting errors caused by inaccurate positioning or insufficient evaluation. The entire method is progressively structured, with scientifically sound data processing and judgment logic, improving positioning accuracy and sorting reliability, reducing the failure rate of robotic arm grasping, ensuring production efficiency and product quality, and effectively addressing various challenges in complex production environments.
[0007] Preferably, the candidate pad region and its geometric grayscale features are extracted, including: Real-time images of the PCB board surface are captured, and Gaussian filtering is used to remove random noise from the PCB board surface image to obtain a grayscale image of the PCB board. The segmentation threshold is automatically calculated using the Otsu's method, and the grayscale image of the PCB board is binarized to obtain candidate pad regions. All candidate pad regions are traversed, and the area and perimeter of each candidate pad region are calculated. The arithmetic mean of the grayscale values of all pixels within the candidate pad region is calculated and recorded as the grayscale value of the candidate pad region. At the same time, non-candidate pad regions in the grayscale image of the PCB board are defined as background regions, and the mean grayscale value of the PCB board background is calculated.
[0008] Preferably, the feature saliency satisfies the following expression: ; In the formula, Indicates the first The saliency of the features of each candidate pad region; For the first Gray values of candidate pad regions; The average grayscale value of the PCB board background; For the first Perimeter of each candidate pad region; For the first The area of each candidate pad region; Pi is a constant. It is the first minimum positive number; It is the second smallest positive number; Represents an exponential function with the natural constant as the base; This represents the absolute value function.
[0009] This invention combines the differences between the region and the background with its own shape characteristics to calculate relevant indicators, which can effectively distinguish between high-quality target regions and low-quality interference regions. This makes the subsequent selection of effective feature points more based on the data, reduces the impact of unsuitable regions on the positioning results, improves the accuracy of the selection of effective feature points, and helps subsequent steps obtain more accurate results.
[0010] Preferably, obtaining the effective distance standard deviation and the effective mean significance includes: Sort all candidate pad regions by feature saliency in ascending order, calculate the difference between two adjacent feature saliencies, and use the position with the largest difference as the split point. Define the region after the split point as a valid positioning feature point. Obtain the region center coordinates of all valid positioning feature points. Using feature saliency as weight, calculate the weighted average of the region center coordinates of all valid positioning feature points to obtain the weighted centroid coordinates of the PCB board. Calculate the effective distribution distance from each valid positioning feature point to the weighted centroid coordinates of the PCB board. Calculate the effective average distribution distance of all distribution distances. Calculate the standard deviation of the effective distance and the effective average saliency.
[0011] Preferably, the consistency coefficient satisfies the following expression: ; In the formula, Represents the consistency coefficient; This represents the total number of effectively located feature points. For the first The saliency of each effective localization feature point; The effective average significance; For the first Effective distribution distance of each effective localization feature point; For effective average distribution distance; and These are the third and fourth smallest positive numbers; This represents the absolute value function.
[0012] This invention comprehensively considers the differences in the quality and position distribution of effective feature points to calculate the correlation coefficient, which can reflect the flatness of the board surface, help identify whether the board has deformation or other problems, provide key reference for subsequent sorting judgment, reduce sorting errors caused by undetected board deformation, improve the accuracy of judging the board status, and make the sorting results more in line with actual needs.
[0013] Preferably, the confidence score satisfies the following expression: ; In the formula, Indicates the confidence score; It is the sum of the feature saliences of all valid localization feature points; The consistency coefficient; The effective distance standard deviation; For effective average distribution distance; It is the natural logarithm function; It is the fifth smallest positive number.
[0014] This invention integrates multiple key data to calculate a comprehensive score, taking into account various aspects such as image, board, and feature distribution, avoiding the limitations of judging by a single indicator, making the evaluation of boards more comprehensive and objective, and providing a reliable basis for the generation of sorting instructions.
[0015] Preferably, generating a sorting instruction that includes pass or reject includes: Obtain the system's preset confidence threshold; compare the calculated confidence score with the confidence threshold; if the confidence score is greater than the confidence threshold, the PCB board is determined to be accurately positionable and its flatness is qualified, and a pass instruction is generated; if the confidence score is less than or equal to the confidence threshold, the board is determined to have severe warping, contamination, or abnormal lighting, and a rejection instruction is generated.
[0016] This invention uses the average of all scores as the judgment standard, making the threshold setting more in line with the actual situation, avoiding the limitations of fixed thresholds, making sorting judgment more flexible and adaptable, and more accurately distinguishing between qualified and unqualified boards, reducing missed or false detections, ensuring the accuracy of sorting results, and maintaining the stable progress of the production process.
[0017] Preferably, calculating the rotation angle includes: The weighted centroid coordinates of the PCB board are used as the gripping center of the board; the principal component analysis method is used to calculate the principal axis direction of the board based on the regional center coordinate distribution of all effective positioning feature points, thereby obtaining the rotation angle; the weighted centroid coordinates and rotation angle of the PCB board are sent to the downstream robotic arm through the communication interface.
[0018] Preferably, the weighted centroid coordinates and rotation angles of the PCB board are converted into physical coordinates of the robotic arm based on the hand-eye calibration matrix pre-stored in the system, and instructions are sent, including: The system calls the pre-stored hand-eye calibration matrix; substitutes the weighted centroid coordinates and rotation angle of the PCB board into the hand-eye calibration matrix to calculate the physical grasping coordinates and target posture angle in the robot arm base coordinate system; constructs control instructions containing physical grasping coordinates, target posture angle and action type; sends the control instructions to the robot arm controller through the industrial communication interface, drives the robot arm to move to the target position to grasp the PCB board, and places it in the corresponding qualified or waste material box according to the sorting instructions.
[0019] Preferably, generating and storing the visualization result includes: The grayscale image of the PCB board is used as the base image, and the recognition box of the effective positioning feature points is superimposed on the base image. The calculated weighted centroid position of the PCB board and the directional arrow representing the rotation angle are drawn on the base image. The confidence score and sorting instructions calculated in this case are labeled on the image to generate a visualization result image containing complete decision information. The visualization result image and the original data packet are stored in the system database to complete this sorting cycle.
[0020] The beneficial effects of this invention are as follows: In the production process, minimal manual intervention is required, achieving an automated workflow from image acquisition and data processing to mechanical execution. This reduces the uncertainties caused by human operation and improves the level of automation and stability of production. Precise positioning and sorting not only ensure product quality and reduce resource waste but also maintain the smooth progress of the production process, improving overall production efficiency. Simultaneously, complete visual recording and data storage provide strong support for the traceability, analysis, and optimization of the production process, facilitating continuous improvement of production processes and system performance to adapt to the production needs of different types of boards, thus providing a valuable contribution to the automation development of the electronics manufacturing industry. Attached Figure Description
[0021] Figure 1 The flowchart illustrates a PCB board sorting and positioning method based on machine vision according to the present invention. Figure 2 This diagram schematically illustrates the details of pad quality differentiation based on feature saliency in this invention. Figure 3 This diagram illustrates the correlation between the plate consistency coefficient and flatness in this invention. Figure 4 The diagram illustrates the PCB board sorting decision results based on confidence scores in this invention. Detailed Implementation
[0022] This invention discloses a PCB board sorting and positioning method based on machine vision, referring to... Figure 1 This includes steps S1-S4: S1: Acquire PCB board surface images using an industrial camera and perform preprocessing to extract candidate pad areas and their geometric grayscale features.
[0023] It should be noted that in the complex lighting environment of automated SMT production lines, the optical properties of PCB board surfaces exhibit nonlinear dynamic changes. One type is the grayscale attenuation of solder pads due to oxidation, characterized by low local grayscale values but regular geometric edges. Simultaneously, noise caused by flux residue or reflection is characterized by extremely high local grayscale values but jagged or broken edges. Both situations coexist in high-speed batches. For this phenomenon, relying solely on a single grayscale threshold will lead to ambiguity in the vision system, making it difficult to distinguish between real solder pads and high-gloss noise. From an image signal processing perspective, real metal solder pads exhibit low-frequency steady-state signals in the frequency domain, while noise is often accompanied by high-frequency edge abrupt changes. Therefore, this invention introduces adaptive threshold segmentation as a first-stage filter, and combines the area and perimeter of the region to construct an initial screening threshold for geometric shape, thereby extracting a set of candidate regions that comprehensively reflects the material's reflective properties and physical geometric boundaries, providing a clean feature base for subsequent precision measurements.
[0024] Specifically, images of the PCB board surface are acquired using an industrial camera and preprocessed to extract candidate pad regions and their geometric grayscale features, including: An industrial camera installed directly above the sorting station captures real-time images of the PCB board surface from a vertical perspective. Gaussian filtering is used to remove random noise from the PCB board surface image, resulting in a pre-processed grayscale image, denoted as the PCB board grayscale image. The Otsu's method is used to automatically calculate the segmentation threshold, binarizing the PCB board grayscale image and extracting the highlight portions representing metal pads. Connected component analysis is used to mark all independent candidate pad regions. All candidate pad regions are traversed, and the total number of pixels within a single candidate pad region is calculated, denoted as the candidate pad region area. The length of the candidate pad region boundary contour is calculated, denoted as the candidate pad region perimeter. The arithmetic mean of the grayscale values of all pixels within the candidate pad region is calculated, denoted as the candidate pad region grayscale value. Simultaneously, non-candidate pad regions in the PCB board grayscale image are defined as background regions, and the average grayscale value of the background region is calculated, denoted as the PCB board background grayscale mean.
[0025] Thus, the candidate pad area, candidate pad perimeter, candidate pad grayscale value, and PCB board background grayscale value of each candidate pad region were obtained.
[0026] S2: Calculate the feature saliency of each candidate pad region based on the difference between the grayscale value of each candidate pad region and the average grayscale value of the PCB board background; screen effective positioning feature points based on the feature saliency, and calculate the weighted centroid coordinates of the PCB board; obtain the effective distance standard deviation and effective average saliency based on the distance relationship between the effective positioning feature points and the weighted centroid coordinates of the PCB board; calculate the consistency coefficient of the PCB board based on the spatial distribution of the effective positioning feature points.
[0027] It's important to note that in precision electronic assembly scenarios, the quality of the positioning feature points directly determines the success rate of the capture. A perfect solder pad feature is characterized by extremely high Weber contrast and a near-circular geometric contour; conversely, a spurious feature caused by solder paste printing spikes or solder pad defects is characterized by high contrast but extremely poor roundness. If these two signals are entered into the positioning algorithm without distinction, the system will be unable to accurately calculate the true pose of the board. From a geometric optics perspective, distortion of the shape factor often indicates defects in the manufacturing process, such as over-etching or solder resist deviation, and its negative impact on positioning accuracy is far greater than that of simple brightness fluctuations. Therefore, the roundness criterion needs to be used as a non-linear penalty weight to exponentially modulate the grayscale-based contrast signal, thereby extracting a feature saliency index that comprehensively reflects the optical saliency and geometric integrity of the feature point, ensuring that high-scoring feature points strictly correspond to the true physical positioning benchmark.
[0028] It should be noted that the feature saliency expression integrates the classic Weber contrast calculation method for visual saliency detection, the circularity criterion commonly used in shape feature extraction in image processing, and the exponential penalty function conventionally used in nonlinear weight modulation. This expression, through single-value quantization, simultaneously integrates the optical sharpness and geometric integrity of the pads, accurately distinguishing standard valid pads from reflective noise and distortion pseudo-features. This provides a high-quality set of feature points for subsequent positioning calculations, improving the positioning accuracy of PCB components from the source, and possesses a clear technical approach.
[0029] Specifically, based on the difference between the grayscale value of each candidate pad region and the average grayscale value of the PCB board background, the feature saliency of the candidate pad region is calculated, including: Feature significance satisfies the following expression: ; In the formula, Indicates the first The saliency of the features of each candidate pad region; For the first Gray values of candidate pad regions; The average grayscale value of the PCB board background; For the first Perimeter of each candidate pad region; For the first The area of each candidate pad region; Pi is a constant. It is the first minimum positive number; It is the second smallest positive number; Represents an exponential function with the natural constant as the base; This represents the absolute value function.
[0030] In the formula, the fractional term This value characterizes the Weber contrast of the candidate pad region relative to the background. A higher value indicates a more pronounced highlight feature and less interference from shadows. The exponential term contains... It is a roundness criterion; for a perfectly round pad, If the absolute value of this term is 0, the value of the exponential function is 1. If the solder pad imaging is elliptical or has edge burrs due to board warping or shooting angle, the absolute value of this term increases, causing the value of the exponential function to decay rapidly. The function nonlinearly maps shape errors to weighting coefficients; the feature significance comprehensively reflects the first... The reliability of a region as a localization feature point is determined by the fact that only regions with both high contrast and high geometric regularity can achieve high feature saliency.
[0031] For example, for a clear and standard circular pad, , ,but For a pad that is affected by reflective noise and has a distorted shape, , ,but It is evident that this formula effectively suppresses low-quality features. The above calculation results... Round to two decimal places. Round to three decimal places. The first and second smallest positive numbers are taken as 0.001.
[0032] It should be noted that, Figure 2 The diagram shows the detailed differentiation of pad quality based on feature saliency, illustrating the calculated feature saliency results for standard circular pads and distorted interference pads. For standard circular pads, the feature saliency under the corresponding parameter combination is approximately 0.748; for distorted interference pads, the feature saliency under the corresponding parameter combination is approximately 0.407. The feature saliency of the standard pad is significantly higher than that of the distorted interference pad. This demonstrates that this calculation method combines the geometric regularity and optical clarity of the pads, allowing higher-quality pads to achieve higher saliency values, thus distinguishing pads in different states.
[0033] At this point, the feature saliency of the candidate pad region has been obtained.
[0034] It's important to note that in multi-feature point collaborative localization, the centroid stability of the feature point group is a core indicator. An ideal, uniformly distributed feature group is characterized by balanced contributions from each point and a stable centroid position. Conversely, a feature group affected by local shading or edge wear exhibits drift in the positions of some key points. If a simple arithmetic average is used, the centroid will be incorrectly pulled towards the noise direction. Without weighted checks to address this phenomenon, the robotic arm will obtain an incorrect grasping center. From a statistical mechanics perspective, high-quality feature points should have a greater impact on centroid calculation. Therefore, feature saliency needs to be used as a quality weight to perform weighted averaging on coordinate calculations, and the distribution distance and standard deviation need to be calculated. This extracts a weighted centroid coordinate that comprehensively reflects the overall geometric distribution of the plate, ensuring the grasping position is anchored at the physical center with the highest probability density.
[0035] Preferably, effective positioning feature points are selected based on the feature saliency, and the weighted centroid coordinates of the PCB board are calculated. Based on the distance relationship between the effective positioning feature points and the weighted centroid coordinates of the PCB board, the effective distance standard deviation and effective average saliency are obtained, including: The feature saliency of all candidate pad regions is sorted in ascending order. The difference between two adjacent feature saliencies is calculated, and the position with the largest difference is used as the split point. The region before the split point is the low saliency region, and the region after the split point is defined as the effective positioning feature point. The coordinates of the region center of all effective positioning feature points are obtained. Using feature saliency as weight, the coordinates of the region center of all effective positioning feature points are weighted and averaged to obtain the weighted centroid coordinates of the PCB board. The Euclidean distance from each effective positioning feature point to the weighted centroid coordinates of the PCB board is calculated and denoted as the effective distribution distance. The arithmetic mean of all distribution distances is calculated and denoted as the effective average distribution distance. The standard deviation of all effective distribution distances is calculated and denoted as the effective distance standard deviation. At the same time, the mean of the feature saliency of all effective positioning feature points is calculated and denoted as the effective average saliency.
[0036] Thus, the effective distance standard deviation and the effective mean significance were obtained.
[0037] It should be noted that board warping is a common process deviation in the production of flexible circuit boards or thin PCBs. A board with good flatness is characterized by a high degree of statistical concentration in the distances from feature points to the centroid. Conversely, a board that has undergone thermal deformation is characterized by nonlinear centripetal or centrifugal shifts in feature points in certain areas, leading to a significant increase in the dispersion of the distance distribution. Relying solely on centroid coordinates is insufficient to identify the board's orientation distortion. From a topological geometry perspective, rigid body transformations should maintain the invariance of point-to-distance relationships, but warping disrupts this consistency. Therefore, a consistency coefficient model needs to be constructed to integrate the saliency of feature points with their distance distribution deviations, thereby extracting a consistency index that comprehensively reflects the flatness of the board surface and the topological rationality of the feature distribution, serving as a basis for determining whether the board has undergone severe deformation.
[0038] Preferably, the consistency coefficient of the PCB board is calculated based on the spatial distribution of the effective positioning feature points, including: Obtain the total number of valid localization feature points.
[0039] The consistency coefficient satisfies the following expression: ; In the formula, Represents the consistency coefficient; This represents the total number of effectively located feature points. For the first The saliency of each effective localization feature point; The effective average significance; For the first Effective distribution distance of each effective localization feature point; For effective average distribution distance; and These are the third and fourth smallest positive numbers; This represents the absolute value function.
[0040] In the formula, It measures the quality of an individual feature point relative to the overall average level and is used to weight feature points by quality. It is the reciprocal form of a distance weight, when near When this term approaches infinity, it indicates that in most standard PCB designs, critical pads typically exhibit a regular symmetrical or annular distribution, with a statistically concentrated tendency in their distance from the centroid. If severe warping occurs on the board, it can cause a non-linear shift in the projection position of some pads on the image, resulting in a greater distribution distance. Abnormal deviation from the average distribution distance This leads to a sharp drop in the value; It is the weighted average topological response of all feature points. The larger the value, the more the distribution of feature points on the surface of the plate conforms to the ideal planar geometry, and the smaller the warping deformation.
[0041] For example, if the PCB board is flat and the feature points are regularly distributed, the denominator of each term will be extremely small, resulting in a high consistency coefficient. Larger values, for example If the PCB board is twisted, the feature points will be scattered, resulting in a large number of... keep away If the denominator increases, the consistency coefficient will increase. The value decreased significantly, for example The third and fourth smallest positive numbers are both 0.001.
[0042] It should be noted that, Figure 3 The diagram showing the correlation between the consistency coefficient and flatness of sheet metal parts illustrates the difference in feature point distribution distance and consistency coefficient between flat and tortuous sheet metal parts. The feature point distribution distance of flat sheet metal parts fluctuates slightly around the average distance, resulting in a consistency coefficient greater than 10. In contrast, the feature point distribution distance of tortuous sheet metal parts deviates significantly from the average distance, resulting in a consistency coefficient less than 2. This difference indicates that the consistency coefficient index can accurately reflect the actual flatness of sheet metal parts through the concentration of feature point distribution, helping to identify whether deformation has occurred.
[0043] Thus, a consistency coefficient was obtained that comprehensively reflects the surface flatness of the plate and the rationality of the characteristic distribution topology.
[0044] S3: Combining the statistical characteristics of the consistency coefficient and the feature significance, calculate a confidence score to comprehensively describe the image clarity, board flatness, and feature distribution rationality; based on the magnitude of the confidence score, generate a sorting instruction that includes passing or rejection; for PCB boards that generate a passing instruction, calculate the rotation angle based on the effective positioning feature points.
[0045] It's important to note that in the final stage of sorting decision-making, single-dimensional indicators often suffer from survivorship bias. A defective but generally usable board may have a large number of feature points but slightly lower individual scores; conversely, a defective product with only a few high-scoring features but missing features in most areas may exhibit local brilliance but global sparsity. To address this, automated systems require a comprehensive evaluation standard. From a systems engineering perspective, reliability stems from the product of quantitative redundancy and qualitative uniformity. Therefore, it's necessary to calculate the logarithmic gain of the sum of feature saliency and the consistency coefficient, along with its dispersion, to extract a confidence score that comprehensively reflects the overall locatability and process robustness of the board, ensuring that the final sorting instructions are based on sufficient data confidence intervals.
[0046] It should be noted that this expression is a multi-dimensional comprehensive confidence score expression for PCB board sorting decisions. Its construction follows the well-known construction logic of multi-factor decision models and the principle of statistical dispersion assessment. Its core solution addresses the technical problem of existing technologies that rely solely on a single matching score for sorting judgment, failing to comprehensively assess board locationability and grasping reliability, leading to high false positive and false negative rates. The expression integrates conventional construction methods for multi-dimensional comprehensive scoring models, numerical gain compression techniques using logarithmic functions, and statistical methods for calculating the coefficient of variation used in dispersion assessment.
[0047] Specifically, combining the statistical characteristics of the consistency coefficient and the feature significance, a confidence score is calculated to comprehensively describe image sharpness, board flatness, and the reasonableness of feature distribution, including: The confidence score satisfies the following expression: ; In the formula, Indicates the confidence score; It is the sum of the feature saliences of all valid localization feature points; The consistency coefficient; The effective distance standard deviation; For effective average distribution distance; It is the natural logarithm function; It is the fifth smallest positive number.
[0048] In the formula, This represents the total amount of effective information in the image. The more feature points there are and the clearer they are, the larger this item will be, ensuring that there is a base score only when enough high-quality pads are identified. The gain is applied to the base score using a consistency coefficient; the flatter the board, the greater the gain. As a denominator, it plays a smoothing and suppression role. The coefficient of variation reflects the relative dispersion of feature point distribution. For some specially designed PCBs, the pads themselves are extremely unevenly distributed. Even if the consistency coefficient value is high, the excessive relative dispersion will appropriately reduce the score of blind confidence and prevent misjudgment of irregular boards. The confidence score finally outputs an evaluation score that comprehensively considers image clarity, board flatness and the rationality of feature distribution.
[0049] Thus, a confidence score was obtained to describe the image sharpness, board flatness, and the reasonableness of feature distribution.
[0050] It's important to note that at the execution terminal of a high-speed production line, decision-making binarization is a prerequisite for physical actions. A component in a critical state is characterized by a confidence score fluctuating around a threshold. Simultaneously, clearly defined good and defective products are distributed at opposite ends of the score range. To address this phenomenon, a clear digital boundary must be established. From a control theory perspective, setting the threshold represents a trade-off between the false negative rate and the false positive rate. Therefore, the confidence score needs to be mapped to a discrete pass / reject instruction space to extract a deterministic sorting signal that can directly drive the PLC or robot controller, ensuring the continuity of the production cycle and the baseline control of product quality.
[0051] Preferably, based on the confidence score, a sorting instruction containing either pass or reject is generated, including: Obtain the system's preset confidence threshold; compare the calculated confidence score with the confidence threshold; if the confidence score is greater than the confidence threshold, the PCB board is determined to be accurately positionable and its flatness is qualified, and a pass instruction is generated; if the confidence score is less than or equal to the confidence threshold, the board is determined to have severe warping, contamination, or abnormal lighting, and a rejection instruction is generated.
[0052] It should be noted that the confidence threshold is usually in the range of 5-10. This invention selects 6.8 as the confidence threshold. The core is to adapt to the scoring distribution pattern. This value leaves enough buffer space to accommodate slight data fluctuations in production and avoid misjudgment and omission. At the same time, it can accommodate the design differences of irregularly shaped plates and balance sorting accuracy and process stability. It is a suitable choice that takes into account both practicality and reliability.
[0053] At this point, the calculated confidence score is compared with the preset sorting threshold, and sorting instructions containing pass or reject are generated.
[0054] It should be noted that the precise grasping of a robotic arm depends not only on position but also on posture. A grasping action with accurate position but angular deviation results in a reduced contact area between the nozzle and the component, making it prone to dropping. Simultaneously, precise posture alignment maximizes vacuum suction force. To address this phenomenon, simple centroid coordinates are insufficient to describe the planar motion of a rigid body. From an analytical geometry perspective, the principal axis direction of the feature point cloud represents the physical major axis or design reference axis of the plate. Therefore, this invention introduces principal component analysis to orthogonally transform the feature point set, thereby extracting a rotation angle parameter that comprehensively reflects the rotational posture of the plate on the conveyor belt. This parameter is then packaged and sent with the weighted centroid coordinates to achieve precise three-degree-of-freedom positioning in a six-degree-of-freedom space.
[0055] Preferably, for the PCB board component generated by the instruction, the rotation angle is calculated based on the effective positioning feature points, including: The weighted centroid coordinates of the PCB board are used as the gripping center of the board; the principal component analysis method is used to calculate the principal axis direction of the board based on the regional center coordinate distribution of all effective positioning feature points, thereby obtaining the rotation angle; the weighted centroid coordinates and rotation angle of the PCB board are sent to the downstream robotic arm through the communication interface.
[0056] At this point, the rotation angle has been calculated.
[0057] S4: Based on the hand-eye calibration matrix pre-stored in the system, convert the weighted centroid coordinates and rotation angle of the PCB board into the physical coordinates of the robotic arm and send instructions; mark the confidence score and the sorting instructions on the PCB board surface image in the form of labels, generate a visualization result image and store it.
[0058] It's important to note that in the collaborative operation of machine vision and industrial robots, the unification of coordinate systems is fundamental to physical execution. A precise centroid calculated in the image pixel coordinate system is characterized by its unit being pixels and its origin located at an image corner. Meanwhile, the robotic arm's motion control relies on the base coordinate system, typically measured in millimeters. Given this, directly transmitting raw pixel data would prevent the robotic arm from resolving the target position, potentially leading to collisions. From a robot kinematics perspective, the vision system is the eye, and the robotic arm is the hand; a rigorously calibrated transformation matrix is essential between them. Therefore, hand-eye calibration parameters are needed to map the weighted centroid coordinates and rotation angles of the PCB board components to the physical space coordinate system, and to construct standard industrial communication messages. This allows for the extraction of a motion command that can drive a servo motor for precise execution, achieving the final closed loop from visual perception to physical sorting.
[0059] Specifically, based on the pre-stored hand-eye calibration matrix, the weighted centroid coordinates and rotation angles of the PCB board are converted into physical coordinates for the robotic arm, and instructions are sent, including: The system calls the pre-stored hand-eye calibration matrix; substitutes the weighted centroid coordinates and rotation angle of the PCB board into the hand-eye calibration matrix to calculate the physical grasping coordinates and target posture angle in the robot arm base coordinate system; constructs control instructions containing physical grasping coordinates, target posture angle and action type; sends the control instructions to the robot arm controller through the industrial communication interface, drives the robot arm to move to the target position to grasp the PCB board, and places it in the corresponding qualified or waste material box according to the sorting instructions.
[0060] At this point, control commands containing physical grab coordinates, target attitude angles, and motion types have been obtained.
[0061] It's important to note that in the Industrial Internet of Things (IIoT) architecture, sorting is not only the end point of physical operations but also the starting point of data assets. A complete production record is characterized by full-chain traceability information, including original images, intermediate algorithm parameters, and final execution results. Furthermore, visualized data presentation helps engineers quickly diagnose production line anomalies. To address this, simply retaining simple log text would result in the loss of crucial on-site image information. From a practical application perspective of image processing, rendering abstract mathematical calculation results back into an intuitive image space is fundamental to achieving human-machine interaction and continuous process improvement. Therefore, this invention aims to construct a method for image data persistence and visualization, thereby extracting a digital archive that intuitively reflects the system's operational logic and historical state, providing a high-value dataset for subsequent big data analysis and model iteration.
[0062] Preferably, the confidence score and the sorting instructions are labeled on the PCB board surface image, a visualization result image is generated and stored, including: The grayscale image of the PCB board is used as the base image, and the recognition box of the effective positioning feature points is superimposed on the base image. The calculated weighted centroid position of the PCB board and the directional arrow representing the rotation angle are drawn on the base image. The confidence score and sorting instructions calculated in this case are labeled on the image to generate a visualization result image containing complete decision information. The visualization result image and the original data packet are stored in the system database to complete this sorting cycle.
[0063] It should be noted that, Figure 4 This diagram illustrates the PCB board sorting decision results based on confidence scores. It includes the confidence score value for each board and the final sorting instruction generation. For qualified boards, all confidence scores are higher than the system's preset sorting threshold, and the system generates a pass instruction. For defective boards, all confidence scores are lower than the preset sorting threshold, and the system generates a reject instruction. This clear correlation demonstrates that this method effectively distinguishes between qualified and defective boards by comparing confidence scores with thresholds, thus improving sorting reliability.
[0064] This completes the sorting and positioning of the PCB boards.
[0065] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.
Claims
1. A PCB board sorting and positioning method based on machine vision, characterized in that, include: The PCB board surface image is acquired by an industrial camera and preprocessed to extract candidate pad areas and their geometric grayscale features. Based on the difference between the grayscale value of each candidate pad region and the average grayscale value of the PCB board background, the feature saliency of the candidate pad region is calculated; effective positioning feature points are screened based on the feature saliency, and the weighted centroid coordinates of the PCB board are calculated; based on the distance relationship between the effective positioning feature points and the weighted centroid coordinates of the PCB board, the effective distance standard deviation and effective average saliency are obtained; based on the spatial distribution of the effective positioning feature points, the consistency coefficient of the PCB board is calculated. Combining the statistical characteristics of the consistency coefficient and the feature significance, a confidence score is calculated to comprehensively describe the image clarity, board flatness, and feature distribution rationality; based on the magnitude of the confidence score, a sorting instruction containing either pass or rejection is generated; for PCB boards that generate a pass instruction, the rotation angle is calculated based on the effective positioning feature points; Based on the hand-eye calibration matrix pre-stored in the system, the weighted centroid coordinates and rotation angles of the PCB board are converted into physical coordinates of the robotic arm, and instructions are sent; the confidence score and the sorting instructions are labeled on the surface image of the PCB board, a visualization result image is generated and stored.
2. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The extraction of candidate pad regions and their geometric grayscale features includes: Real-time images of the PCB board surface are captured, and Gaussian filtering is used to remove random noise from the PCB board surface image to obtain a grayscale image of the PCB board. The segmentation threshold is automatically calculated using the Otsu's method, and the grayscale image of the PCB board is binarized to obtain candidate pad regions. All candidate pad regions are traversed, and the area and perimeter of each candidate pad region are calculated. The arithmetic mean of the grayscale values of all pixels within the candidate pad region is calculated and recorded as the grayscale value of the candidate pad region. At the same time, non-candidate pad regions in the grayscale image of the PCB board are defined as background regions, and the mean grayscale value of the PCB board background is calculated.
3. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The significance of the feature satisfies the following expression: ; In the formula, Indicates the first The saliency of the features of each candidate pad region; For the first Gray values of candidate pad regions; The average grayscale value of the PCB board background; For the first Perimeter of each candidate pad region; For the first The area of each candidate pad region; Pi is a constant. It is the first minimum positive number; It is the second smallest positive number; Represents an exponential function with the natural constant as its base; This represents the absolute value function.
4. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, Obtaining the effective distance standard deviation and effective mean significance includes: Sort all candidate pad regions by feature saliency in ascending order, calculate the difference between two adjacent feature saliencies, and use the position with the largest difference as the split point. Define the region after the split point as a valid positioning feature point. Obtain the region center coordinates of all valid positioning feature points. Using feature saliency as weight, calculate the weighted average of the region center coordinates of all valid positioning feature points to obtain the weighted centroid coordinates of the PCB board. Calculate the effective distribution distance from each valid positioning feature point to the weighted centroid coordinates of the PCB board. Calculate the effective average distribution distance of all distribution distances. Calculate the standard deviation of the effective distance and the effective average saliency.
5. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The consistency coefficient satisfies the following expression: ; In the formula, Represents the consistency coefficient; This represents the total number of effectively located feature points. For the first The saliency of each effective localization feature point; The effective average significance; For the first Effective distribution distance of each effective localization feature point; For effective average distribution distance; and These are the third and fourth smallest positive numbers; This represents the absolute value function.
6. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The confidence score satisfies the following expression: ; In the formula, Indicates the confidence score; It is the sum of the feature saliences of all valid localization feature points; The consistency coefficient; The effective distance standard deviation; For effective average distribution distance; It is the natural logarithm function; It is the fifth smallest positive number.
7. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The generation includes sorting instructions that specify pass or reject, including: Obtain the system's preset confidence threshold; compare the calculated confidence score with the confidence threshold; if the confidence score is greater than the confidence threshold, the PCB board is determined to be accurately positionable and its flatness is qualified, and a pass instruction is generated; if the confidence score is less than or equal to the confidence threshold, the board is determined to have severe warping, contamination, or abnormal lighting, and a rejection instruction is generated.
8. The PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The calculation of the rotation angle includes: The weighted centroid coordinates of the PCB board are used as the gripping center of the board; the principal component analysis method is used to calculate the principal axis direction of the board based on the regional center coordinate distribution of all effective positioning feature points, thereby obtaining the rotation angle; the weighted centroid coordinates and rotation angle of the PCB board are sent to the downstream robotic arm through the communication interface.
9. A PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The system converts the weighted centroid coordinates and rotation angles of the PCB board into physical coordinates for the robotic arm based on the pre-stored hand-eye calibration matrix, and sends commands, including: The system calls the pre-stored hand-eye calibration matrix; substitutes the weighted centroid coordinates and rotation angle of the PCB board into the hand-eye calibration matrix to calculate the physical grasping coordinates and target posture angle in the robot arm base coordinate system; constructs control instructions containing physical grasping coordinates, target posture angle and action type; sends the control instructions to the robot arm controller through the industrial communication interface, drives the robot arm to move to the target position to grasp the PCB board, and places it in the corresponding qualified or waste material box according to the sorting instructions.
10. A PCB board sorting and positioning method based on machine vision according to claim 1, characterized in that, The process of generating and storing the visualization result includes: The grayscale image of the PCB board is used as the base image, and the recognition box of the effective positioning feature points is superimposed on the base image. The calculated weighted centroid position of the PCB board and the directional arrow representing the rotation angle are drawn on the base image. The confidence score and sorting instructions calculated in this case are labeled on the image to generate a visualization result image containing complete decision information. The visualization result image and the original data packet are stored in the system database to complete this sorting cycle.