PCB identifying and grabbing method and system based on machine vision
The edge detection method optimized by adaptive Gaussian filtering and whale swarm algorithm solves the edge detection error problem of the traditional Canny algorithm under uneven lighting and pad reflection, realizes accurate identification and grasping of PCB boards, and improves production efficiency.
Patent Information
- Application Number
- CN202510736013.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-09-16
AI Technical Summary
In the existing technology, the traditional Canny algorithm is easily affected by uneven lighting and PCB pad reflections in PCB board image edge detection, resulting in the generation of incorrect edge contours. The robot cannot correctly calculate the center of mass and identify mark points, resulting in grasping errors and collisions.
Adaptive Gaussian filtering and anisotropic diffusion filtering based on the whale swarm algorithm are used, combined with the OpenCV vision library to optimize the edge detection process and generate accurate template images for robot grasping.
The accuracy and completeness of edge detection are improved, ensuring that the robot can correctly identify the center of mass and mark points of the PCB board, avoiding grasping errors and collisions, and improving the automation efficiency of PCB board production.
Smart Images

Figure CN120655591A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of PCB board processing, and in particular relates to a PCB board identification and grasping method and system based on machine vision. Background Art
[0002] In the loading system of the PCB automated production line, the vision system cooperates with the robot to automatically identify and grab the PCB board position on the conveyor belt, realize the automation of the PCB loading process, and improve the production efficiency of PCB boards.
[0003] In the PCB loading system, the workflow of the robot grabbing the PCB board is: PCB board position recognition → hand-eye calibration → grab point planning → motion trajectory planning → grabbing. PCB board position recognition involves capturing a PCB board image with a camera and generating a PCB board edge profile using an edge detection algorithm. This provides a basis for the robot to subsequently determine the grasping position based on the PCB board profile. In the prior art, the traditional Canny algorithm is often used to obtain the edge profile features of the target PCB board, perform fitting calculations on the acquired edge profile features, and ultimately output a template image to provide the robot with a basis for the target PCB board's position, posture, and grasping strategy. However, the Gaussian filter step of the traditional Canny algorithm is easily affected by uneven lighting and PCB pad reflections during edge detection of the PCB board image. The Gaussian filter of the Canny operator has insufficient ability to suppress low-frequency lighting changes, causing the light-dark boundary to be identified as a true edge. The true edge of the dark area is smoothed by the Gaussian filter, and the true edge of the PCB board image is lost, resulting in an erroneous edge profile of the PCB board image. This prevents the robot from correctly calculating the center of mass of the PCB board and identifying mark points. This can cause the PCB board to tilt and lose its center of gravity when the robot grasps the PCB board, causing it to fall, and the robot to collide with other PCB boards when placing the PCB board.
[0004] In view of this, the present invention proposes a PCB board recognition and grasping method and system based on machine vision to solve the above technical problems. Summary of the Invention
[0005] The present invention aims to provide a method and system for identifying and grasping PCB boards based on machine vision, so as to solve the technical problem in the prior art that the traditional Canny algorithm used to calculate the edge contour of the PCB board image is easily affected by uneven lighting on the PCB board and the reflection of the PCB pad, resulting in the generation of incorrect edge contours of the PCB board image, which causes the robot to be unable to correctly calculate the center of mass of the PCB board and cannot correctly identify the mark points.
[0006] The present invention solves the above technical problems through the following technical solutions, and is a PCB board recognition and grasping method based on machine vision, comprising the following steps:
[0007] S1, obtaining the original image I0 of the target PCB board on the conveyor belt;
[0008] S2, performing adaptive Gaussian filtering on the original image I0 to obtain a first smoothed image I1;
[0009] S3, filtering the first smoothed image I1 using anisotropic diffusion filtering controlled by a whale swarm algorithm to obtain a second smoothed image I2;
[0010] S4, using a Gaussian filter Canny algorithm to calculate the second smoothed image I2 to obtain a contour image I3, wherein the Gaussian filter Canny algorithm includes gradient calculation, non-maximum suppression, hysteresis threshold segmentation, and edge connection;
[0011] S5. Using the OpenCV visual library to obtain the affine transformation matrix of the contour image I3, and using the affine transformation matrix to transform the contour image I3 to obtain a template image I4 with an angle of 0;
[0012] S6. Calculate the pose data of the template image I4 on the conveyor belt, and use the robot to grab the target PCB board based on the pose data.
[0013] Preferably, in the above step S3, filtering the first smoothed image I1 by using anisotropic diffusion filtering controlled by a whale swarm algorithm to obtain a second smoothed image I2 includes:
[0014] S3.1. Initialize the whale population X and set the maximum number of iterations T max and edge threshold ε, the whale population X includes X anisotropic diffusion maps x with different diffusion coefficients c(s) i ;
[0015] S3.2. Calculate the anisotropic diffusion map x within the whale population X i The fitness F it (x i ), with max(F it (x i )) is the objective function, and the optimal individual anisotropic diffusion map is obtained For X anisotropic diffusion maps x i Perform simulated predation to obtain the global optimal individual anisotropic diffusion map
[0016] S3.3, iterate step S3.2 until the number of iterations reaches T max or F it (x i )≥ε, and the calculation is stopped to obtain the best fitness. The optimal solution anisotropic diffusion map Anisotropic diffusion plot is the second smoothed image I2.
[0017] Preferably, in the above step S2, performing adaptive Gaussian filtering on the original image I0 to obtain the first smoothed image I1 includes:
[0018] Grayscale the original image I0 of the target PCB board to obtain a grayscale image I'0;
[0019] Divide the grayscale image I'0 to obtain the edge area I d and smooth region I s ;
[0020] According to formula (1), the standard deviation σ of the adaptive Gaussian filter is obtained:
[0021]
[0022] Where, σ min Represents the edge area I d The minimum standard deviation, σ max Smooth area I s The maximum standard deviation, σ g represents the gradient sensitivity parameter, G(x,y) represents the gradient amplitude of the pixel at the xth row and yth column of the grayscale image I'0, and σ(x,y) represents the local standard deviation of the pixel at the xth row and yth column of the grayscale image I'0;
[0023] According to formula (1), the adaptive two-dimensional Gaussian kernel K is obtained, and the calculation formula is:
[0024]
[0025] Where (u, v) represents the relative coordinates of the Gaussian kernel, K(x, y)(u, v) represents the adaptive two-dimensional Gaussian kernel corresponding to the pixel point in the x-th row and y-th column of the grayscale image I, and r represents the radius of the Gaussian kernel;
[0026] Use the adaptive two-dimensional Gaussian kernel K to perform local convolution calculation on the grayscale image I to obtain the preliminary Gaussian filtered image I filtered , the calculation formula is:
[0027]
[0028] Where, I local (u, v) represents the local area of K(x, y)·K(x, y) intercepted with the pixel (x, y) of the grayscale image I as the center, I filtered (x,y) represents the preliminary Gaussian filtered image of pixel (x,y);
[0029] Take the preliminary Gaussian filter image I filtered Instead of the grayscale image I'0, formula (1), formula (2) and formula (3) are iteratively calculated to obtain the first smoothed image I1.
[0030] Preferably, in step S3.1, the anisotropic diffusion map x i The calculation process is:
[0031] According to formula (4), the anisotropic diffusion map x of the first smoothed image I1 is obtained i :
[0032] x i =I 1(t+1) (x,y)=I 1(t) (x,y)+Δt·▽·(c(s)▽I 1(t) (x,y)) (4)
[0033] Where Δt is the time step, ▽ represents the divergence operator, and I 1(t) (x, y) represents the pixel value (x, y) of the first smoothed image I1 at time t, I 1(t+1) (x,y) represents the time t+1;
[0034] In step S2.2, the anisotropic diffusion map x i The fitness F it (x i ) is calculated as:
[0035] F it (x i )=ω1PSNR(x i )+ω2SSIM(x i )+ω3EPI(x i )-ω4Time(x i ) (5)
[0036] In the formula, PSNR(x i ) represents the anisotropic diffusion map x i Peak signal-to-noise ratio, SSIM(x i ) represents the anisotropic diffusion map x i The structural similarity index, EPI(x i ) represents the anisotropic diffusion map x i The edge retention index, Time(x i ) represents the algorithm operation time, ω1, ω2, ω3 and ω4 represent weight factors respectively.
[0037] Preferably, in step S6, calculating the pose data of the template image I4 on the conveyor belt includes:
[0038] Use OpenCV vision library to extract the centroid or mark point outline of template image I4 and determine the centroid image coordinates O of template image I4. Z (x,y) or the image coordinates of the mark point O m (x,y);
[0039] Calibrate the camera to determine the relationship between the image coordinate system and the world coordinate system;
[0040] According to the image coordinate system and the world coordinate system, determine the actual coordinate O' of the center of mass on the conveyor belt Z (x,y) or the actual coordinates of the mark point on the conveyor belt O' m (x,y);
[0041] According to the speed of the conveyor belt, determine the real-time coordinates of the center of mass O' Z(t) (x,y) or real-time coordinates of the mark point O' m(t) (x,y);
[0042] According to formula (6), the motion displacement X of the robot when tracking the center of mass or mark point is obtained:
[0043]
[0044] Where x1 represents the centroid coordinate O' when the template image I4 is obtained Z =(x,y) or real-time coordinates of the mark point O' m (x,y), v represents the speed of the conveyor belt, x t Indicates O' Z(t) (x,y) or O' m(t) (x,y), B represents the lead offset.
[0045] A machine vision-based PCB board recognition and grasping system includes: a conveyor belt, a linear array camera, a fixed bracket, a vibrating loading tray, a robot, a light source, a soft baffle, an encoder, a PCB tray, and a control unit. The fixed bracket and the soft baffle are respectively installed on the conveyor belt, the linear array camera and the light source are respectively installed on the fixed bracket, and the conveyor belt, the linear array camera, the vibrating loading tray, the robot, the conveyor belt, and the linear array camera are respectively connected to the control unit.
[0046] Preferably, the control unit includes a PLC industrial computer and a GPU server.
[0047] Preferably, the robot includes a motion unit and an adsorption device.
[0048] Compared with the existing technology, the present invention has the following beneficial effects:
[0049] First, the original image I0 of the target PCB board is filtered by adaptive Gaussian filtering. The Gaussian noise suppression effect of the original image I0 of the target PCB board is improved by adaptively adjusting the Gaussian kernel. A small Gaussian kernel is selected for weak edges to avoid the loss of true edges. After obtaining the first smoothed image I1, the first smoothed image I1 is filtered by anisotropic diffusion filtering controlled by a whale swarm algorithm. Adaptive illumination directional edge diffusion is used to retain weak edges in dark areas and suppress noise in bright areas, thereby improving the edge distinction and edge preservation capabilities, ensuring the integrity and accuracy of the contour of the subsequently generated template image I4. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 The figure is a flow chart of the PCB board recognition and grasping method based on machine vision of the present invention.
[0051] Figure 2 The figure is a structural diagram of the PCB board recognition and grasping system based on machine vision of the present invention.
[0052] Figure 3 It is the original image of the target PCB board of the present invention.
[0053] Figure 4 This is the outline image of the target PCB board processed by the method of the present invention.
[0054] Figure 5 It is a template image processed by the method of the present invention.
[0055] In the figure: 1 - motion unit, 2 - adsorption device, 3 - conveyor belt, 4 - fixed bracket, 5 - photoelectric sensor, 6 - soft baffle, 7 - vibration loading tray, 8 - PCB tray. DETAILED DESCRIPTION
[0056] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings, but it should be understood that the protection scope of the invention is not limited by the specific embodiments.
[0057] refer to Figure 1 ,The PCB board recognition and grasping method based on machine vision includes the following steps:
[0058] S1, obtain the original image I0 of the target PCB board on the conveyor belt;
[0059] S2, performing adaptive Gaussian filtering on the original image I0 of the target PCB board to obtain a first smoothed image I1;
[0060] The specific process includes:
[0061] Grayscale the original image I0 of the target PCB board to obtain a grayscale image I'0;
[0062] Divide the grayscale image I'0 to obtain the edge area I d and smooth region I s ;
[0063] According to formula (1), the standard deviation σ of the adaptive Gaussian filter is obtained:
[0064]
[0065] Where, σ min Represents the edge area I d The minimum standard deviation, σ max Smooth area I s The maximum standard deviation, σ g represents the gradient sensitivity parameter, G(x,y) represents the gradient amplitude of the pixel at the xth row and yth column of the grayscale image I'0, and σ(x,y) represents the local standard deviation of the pixel at the xth row and yth column of the grayscale image I'0;
[0066] In specific implementation, the gradient amplitude G(x,y) of the grayscale image I'0 can be calculated by the Sobel operator, σ min It can be 0.3-1.5, σ max 1-4 are acceptable.
[0067] According to formula (1), the adaptive two-dimensional Gaussian kernel K is obtained, and the calculation formula is:
[0068]
[0069] Where (u, v) represents the relative coordinates of the Gaussian kernel, K(x, y)(u, v) represents the adaptive two-dimensional Gaussian kernel corresponding to the pixel point in the x-th row and y-th column of the grayscale image I, and r represents the radius of the Gaussian kernel;
[0070] Use the adaptive two-dimensional Gaussian kernel K to perform local convolution calculation on the grayscale image I to obtain the preliminary Gaussian filtered image I filtered , the calculation formula is:
[0071]
[0072] Where, I local (u, v) represents the local area of K(x, y)·K(x, y) intercepted with the pixel (x, y) of the grayscale image I as the center, I filtered (x,y) represents the preliminary Gaussian filtered image of pixel (x,y);
[0073] Take the preliminary Gaussian filter image I filtered Instead of the grayscale image I'0, formula (1), formula (2) and formula (3) are iteratively calculated to obtain the first smoothed image I1.
[0074] In this embodiment, the adaptive Gaussian filter dynamically adjusts the two-dimensional Gaussian kernel K according to the light intensity. A smaller K value (K is 0.5-1) is used for the dark area of the grayscale image I'0 to reduce over-smoothing and retain weak edges. A higher K value (K 1.5-2) is used for the bright area of the grayscale image I'0 to improve the suppression of Gaussian noise in the image. For the edge area of the grayscale image I'0, a smaller K value (K is 0.3-0.6) is maintained to avoid edge blurring caused by over-smoothing.
[0075] S3, filtering the first smoothed image I1 using anisotropic diffusion filtering controlled by a whale swarm algorithm to obtain a second smoothed image I2;
[0076] The first smoothed image I1 is filtered using anisotropic diffusion filtering controlled by a whale swarm algorithm to obtain a second smoothed image I2, including:
[0077] S3.1. Initialize the whale population X and set the maximum number of iterations T max and edge threshold ε, the whale population X consists of X anisotropic diffusion maps x with different diffusion coefficients c(s) i ;
[0078] In step S3.1, the anisotropic diffusion map x i The calculation process is:
[0079] According to formula (4), the anisotropic diffusion map x of the first smoothed image I1 is obtained i :
[0080] x i =I 1(t+1) (x,y)=I 1(t) (x,y)+Δt·▽·(c(s)▽I 1(t) (x,y)) (4)
[0081] Where Δt is the time step, ▽ represents the divergence operator, and I 1(t) (x, y) represents the pixel value (x, y) of the first smoothed image I1 at time t, I 1(t+1) (x,y) represents the time t+1;
[0082] In step S3.2, the anisotropic diffusion map x i The fitness F it (x i ) is calculated as:
[0083] F it (x i )=ω1PSNR(x i )+ω2SSIM(xi )+ω3EPI(x i )-ω4Time(x i ) (5)
[0084] In the formula, PSNR(x i ) represents the anisotropic diffusion map x i Peak signal-to-noise ratio, SSIM(x i ) represents the anisotropic diffusion map x i The structural similarity index, EPI(x i ) represents the anisotropic diffusion map x i The edge retention index, Time(x i ) represents the algorithm operation time, ω1, ω2, ω3 and ω4 represent weight factors respectively.
[0085] S3.2. Calculate the anisotropic diffusion map x within the whale population X i The fitness F it (x i ), with max(F it (x i )) is the objective function, and the optimal individual anisotropic diffusion map is obtained For X anisotropic diffusion maps x i Perform simulated predation to obtain the global optimal individual anisotropic diffusion map
[0086] S3.3, iterate step S3.2 until the number of iterations reaches T max or F it (x i )≥ε, and the calculation is stopped to obtain the best fitness. The optimal solution anisotropic diffusion map Anisotropic diffusion plot is the second smoothed image I2.
[0087] In specific implementation, the X anisotropic diffusion maps x in step S3.2 are i The process of simulated predation includes: surrounding prey, attacking with bubble net, and randomly searching for prey.
[0088] In this embodiment, the first smoothed image I1 is filtered using an anisotropic diffusion filter controlled by a whale swarm algorithm. Based on the characteristics of the first smoothed image I1, which have high gradient magnitudes and clear directionality, and low gradient magnitudes, slow gradient changes, and chaotic gradient directions in illumination change regions, high-precision detection of the true edges of the first smoothed image I1 is achieved, reducing false detections. The anisotropic diffusion filter controlled by the whale swarm algorithm can dynamically adjust the diffusion coefficient c(s) of the anisotropic diffusion filter based on the gradient magnitude of the first smoothed image I1, performing directional noise reduction in non-edge directions in bright regions of the first smoothed image I1, and lowering the diffusion coefficient suppression threshold in weak edge regions of the dark regions of the first smoothed image I1, thereby enhancing edge continuity and adapting to different lighting scenarios.
[0089] S4, using the Gaussian filter Canny algorithm to calculate the second smoothed image I2 to obtain the contour image I3, the Gaussian filter Canny algorithm includes gradient calculation, non-maximum suppression, hysteresis threshold segmentation, and edge connection;
[0090] In this embodiment, the target PCB board original image I0 is as follows: Figure 3 As shown, the outline image I3 of the target PCB board is as follows Figure 4 As shown, from Figure 4 It can be seen that after processing the original image I0 of the target PCB board, the method of the present invention can effectively retain the edge contour features of the original image I0 and realize the edge contour detection of the mark point of the PCB board. This facilitates the subsequent extraction of the correct center of mass of the template image I4 by the OpenCV vision library and the robot to grasp the PCB board according to the edge contour of the mark point. This avoids the technical problems of the robot grasping the PCB board incorrectly, causing the PCB board to tilt and the center of gravity to be unstable, resulting in the PCB board falling, and the robot colliding with other PCB boards when placing the PCB board.
[0091] S5. Using the OpenCV visual library to obtain the affine transformation matrix of the contour image I3, and using the affine transformation matrix to transform the contour image I3 to obtain a template image I4 with an angle of 0;
[0092] In this embodiment, the generated template image I4 is as follows: Figure 5 As shown;
[0093] S6, calculating the pose data of the template image I4 on the conveyor belt, and using the robot to grab the target PCB board according to the pose data;
[0094] Calculating the pose data of the template image I4 on the conveyor belt includes:
[0095] Use OpenCV vision library to extract the centroid or mark point outline of template image I4 and determine the centroid image coordinates O of template image I4.Z (x,y) and the image coordinates of the mark point O m (x,y);
[0096] Calibrate the camera to determine the relationship between the image coordinate system and the world coordinate system;
[0097] According to the image coordinate system and the world coordinate system, determine the actual coordinate O' of the center of mass on the conveyor belt Z (x,y) or the actual coordinates of the mark point on the conveyor belt O' m (x,y);
[0098] According to the speed of the conveyor belt, determine the real-time coordinates of the center of mass O' Z(t) (x,y) or real-time coordinates of the mark point O' m(t) (x,y);
[0099] According to formula (6), the motion displacement X of the robot when tracking the center of mass or mark point is obtained:
[0100]
[0101] Where x1 represents the centroid coordinate O' when the template image I4 is obtained Z =(x,y) or real-time coordinates of the mark point O' m (x,y), v represents the speed of the conveyor belt, x t Indicates O' Z(t) (x,y) or O' m(t) (x,y), B represents the lead offset.
[0102] refer to Figure 2 Based on the above embodiments, the present invention also discloses a PCB board recognition and grasping system based on machine vision, including: a conveyor belt 3, a linear array camera, a fixed bracket 4, a photoelectric sensor 5, a soft baffle 6, a vibrating loading tray 7, a robot, a light source, an encoder, a PCB tray 8 and a control unit. The robot includes a motion unit 1 and an adsorption device 2, and the control unit includes a PLC industrial computer and a GPU server.
[0103] The fixed bracket 4 and the soft baffle 6 are respectively fixed above the conveyor belt 3, the line array camera and the light source are respectively installed on the fixed bracket 4, the conveyor belt 3, the photoelectric sensor 5, the line array camera, the vibrating loading tray 7, the robot, the conveyor belt 3 and the line array camera are respectively connected to the control unit. The vibrating loading tray 7 is used to convey the PCB board to the conveyor belt 3, the line array camera is used to scan the PCB board line by line to generate the original image I0 of the target PCB board, the light source is used to provide fill light for the PCB board when the line array camera collects the PCB board image, the photoelectric sensor 5 is used to detect the PCB board on the conveyor belt 3 to trigger the line array camera to scan the target PCB board, the encoder is used to collect the speed of the conveyor belt 3, the soft baffle 6 is used to level the PCB board on the conveyor belt to prevent the PCB boards from piling up during image collection, thereby achieving a stable image collection effect, the adsorption device 2 is used to adsorb the PCB board, the GPU server is used to execute the method steps in steps S2-S6 of the present invention, and the PLC industrial computer is used to read the posture data of the template image I4 on the conveyor belt 3 output by the GPU server, and then control the robot to grab the PCB board.
[0104] The foregoing descriptions of specific exemplary embodiments of the present invention are for purposes of illustration and description. These descriptions are not intended to limit the invention to the precise forms disclosed, and obviously, many modifications and variations are possible in light of the above teachings. The exemplary embodiments are chosen and described to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to make and utilize various exemplary embodiments of the invention, as well as various alternatives and variations. It is intended that the scope of the invention be defined by the claims and their equivalents.
Claims
1. A PCB board recognition and grasping method based on machine vision, characterized in that: The steps include: S1, obtaining the original image I0 of the target PCB board on the conveyor belt; S2, performing adaptive Gaussian filtering on the original image I0 to obtain a first smoothed image I1; S3, filtering the first smoothed image I1 using anisotropic diffusion filtering controlled by a whale swarm algorithm to obtain a second smoothed image I2; S4, using a Gaussian filter Canny algorithm to calculate the second smoothed image I2 to obtain a contour image I3, wherein the Gaussian filter Canny algorithm includes gradient calculation, non-maximum suppression, hysteresis threshold segmentation and edge connection; S5. Using the OpenCV visual library to obtain the affine transformation matrix of the contour image I3, and using the affine transformation matrix to transform the contour image I3 to obtain a template image I4 with an angle of 0; S6. Calculate the pose data of the template image I4 on the conveyor belt, and use the robot to grab the target PCB board based on the pose data.
2. The PCB board recognition and grasping method based on machine vision according to claim 1 is characterized in that: In step S3, filtering the first smoothed image I1 using anisotropic diffusion filtering controlled by a whale swarm algorithm to obtain a second smoothed image I2 includes: S3.
1. Initialize the whale population X and set the maximum number of iterations T max and edge threshold ε, the whale population X includes X anisotropic diffusion maps x with different diffusion coefficients c(s) i ; S3.
2. Calculate the anisotropic diffusion map x within the whale population X i The fitness F it (x i ), with max(F it (x i )) is the objective function, and the optimal individual anisotropic diffusion map is obtained For X anisotropic diffusion maps x i Perform simulated predation to obtain the global optimal individual anisotropic diffusion map S3.3, iterate step S3.2 until the number of iterations reaches T max or F it (x i )≥ε, and the calculation is stopped to obtain the best fitness. The optimal solution anisotropic diffusion map Anisotropic diffusion plot is the second smoothed image I2.
3. The PCB board recognition and grasping method based on machine vision according to claim 1 is characterized in that: In step S2, performing adaptive Gaussian filtering on the original image I0 to obtain a first smoothed image I1 includes: Grayscale the original image I0 of the target PCB board to obtain a grayscale image I'0; Divide the grayscale image I'0 to obtain the edge area I d and smooth region I s ; According to formula (1), the standard deviation σ of the adaptive Gaussian filter is obtained: Where σ min Represents the edge area I d The minimum standard deviation, σ max Smooth area I s The maximum standard deviation, σ g represents the gradient sensitivity parameter, G(x,y) represents the gradient amplitude of the pixel at the xth row and yth column of the grayscale image I'0, and σ(x,y) represents the local standard deviation of the pixel at the xth row and yth column of the grayscale image I'0; According to formula (1), the adaptive two-dimensional Gaussian kernel K is obtained, and the calculation formula is: Where (u, v) represents the relative coordinates of the Gaussian kernel, K(x, y)(u, v) represents the adaptive two-dimensional Gaussian kernel corresponding to the pixel point in the x-th row and y-th column of the grayscale image I, and r represents the radius of the Gaussian kernel; Use the adaptive two-dimensional Gaussian kernel K to perform local convolution calculation on the grayscale image I to obtain the preliminary Gaussian filtered image I filtered , the calculation formula is: Where, I local (u, v) represents the local area of K(x, y)·K(x, y) intercepted with the pixel (x, y) of the grayscale image I as the center, I filtered (x,y) represents the preliminary Gaussian filtered image of pixel (x,y); Take the preliminary Gaussian filter image I filtered Instead of the grayscale image I'0, formula (1), formula (2) and formula (3) are iteratively calculated to obtain the first smoothed image I1.
4. The PCB board recognition and grasping method based on machine vision according to claim 2 is characterized in that: In the step S3.1, the anisotropic diffusion map x i The calculation process is: According to formula (4), the anisotropic diffusion map x of the first smoothed image I1 is obtained i : x i =I 1(t+1) (x,y)=I 1(t) (x,y)+Δt·▽·(c(s)▽I 1(t) (x,y)) (4) Where Δt is the time step, ▽ represents the divergence operator, and I 1(t) (x, y) represents the pixel value (x, y) of the first smoothed image I1 at time t, I 1(t+1) (x,y) represents the time t+1; In step S3.2, the anisotropic diffusion map x i The fitness F it (x i ) is calculated as: F it (x i )=ω1PSNR(x i )+ω2SSIM(x i )+ω3EPI(x i )-ω4Time(x i ) (5) In the formula, PSNR(x i ) represents the anisotropic diffusion map x i Peak signal-to-noise ratio, SSIM(x i ) represents the anisotropic diffusion map x i The structural similarity index, EPI(x i ) represents the anisotropic diffusion map x i Edge retention index, Time(x i ) represents the algorithm operation time, ω1, ω2, ω3 and ω4 represent weight factors respectively.
5. The PCB board recognition and grasping method based on machine vision according to claim 1 is characterized in that: In step S5, the pose data of the template image I4 on the conveyor belt is calculated, including: Use OpenCV vision library to extract the centroid or mark point outline of template image I4 and determine the centroid image coordinates O of template image I4. Z (x,y) or the image coordinates of the mark point O m (x,y); Calibrate the camera to determine the relationship between the image coordinate system and the world coordinate system; According to the image coordinate system and the world coordinate system, determine the actual coordinate O' of the center of mass on the conveyor belt Z (x,y) or the actual coordinates of the mark point on the conveyor belt O' m (x,y); According to the speed of the conveyor belt, determine the real-time coordinates of the center of mass O' Z(t) (x,y) or real-time coordinates of the mark point O' m(t) (x,y); According to formula (6), the motion displacement X of the robot when tracking the center of mass or mark point is obtained: Where x1 represents the centroid coordinate O' when the template image I4 is obtained Z =(x,y) or real-time coordinates of the mark point O' m (x,y), v represents the speed of the conveyor belt, x t Indicates O' Z(t) (x,y) or O' m(t) (x,y), B represents the lead offset.
6. A PCB board recognition and grasping system based on machine vision, using the method according to any one of claims 1 to 5, characterized in that: include: A conveyor belt, a linear array camera, a fixed bracket, a vibrating loading tray, a robot, a light source, a soft baffle, an encoder, a PCB tray and a control unit, wherein the fixed bracket and the soft baffle are respectively mounted on the conveyor belt, the linear array camera and the light source are respectively mounted on the fixed bracket, and the conveyor belt, the linear array camera, the vibrating loading tray, the robot, the conveyor belt and the linear array camera are respectively connected to the control unit.
7. The machine vision-based PCB board recognition and grasping system according to claim 6, characterized in that: The control unit includes a PLC industrial computer and a GPU server.
8. The machine vision-based PCB board recognition and grasping system according to claim 6, characterized in that: The robot comprises a motion unit and a suction device.