A visual recognition method for three-pack steel mesh
By pre-processing and edge fitting of the three-pack steel mesh images and calculating the gap direction, the problems of inefficient production capacity and efficiency in robot mounting are solved, and more accurate positioning and more efficient mounting process are achieved.
Patent Information
- Application Number
- CN202011613441.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2040-12-30
AI Technical Summary
In the prior art, the production capacity and efficiency of mounting PCB board circuits using robots and fixtures is low, the positioning is not accurate enough, and the identification of slow speed is slow.
The visual recognition method of the three-pack steel mesh is adopted, including pre-processing the image of the three-pack steel mesh, and coarsely positioning the center through the actual area of the smallest external rectangle, extracting the effective edge points and fitting the straight line, and according to the pre-set theoretical offset value Perform translation and calculate the edge endpoints and notch directions of the two packets on the lower side to improve positioning accuracy.
Through this method, the accuracy of the mounting position is improved, and the production capacity and efficiency of the mounting are improved.
Smart Images

Figure CN112861610B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to a visual recognition method for a three-pack steel mesh. Background Art
[0002] Nowadays, electronic technology is developing rapidly, and the complexity and integration of PCB board circuits are gradually increasing. SMD components account for the majority of the total number of components on the circuit board. The production capacity of mounting using robots and fixtures is relatively low, and the positioning is not accurate enough.
[0003] SUMMARY OF THE INVENTION
[0004] In order to overcome the shortcomings of the prior art, the present invention provides a visual recognition method for a three-pack steel mesh to solve the technical problems of low production capacity, low efficiency, inaccurate positioning and slow recognition speed when mounting using a robot and a fixture.
[0005] The technical solution adopted by the present invention to solve the technical problem is: to provide a visual recognition method of a three-pack steel mesh, comprising the following steps:
[0006] S1: preprocessing the three-pack steel mesh image;
[0007] S2: roughly locate the center of the three-pack steel mesh according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image outline;
[0008] S3: According to the effective steel mesh edge area determined by the three-pack steel mesh position, extract the effective edge points and fit the straight line;
[0009] S4: Transversely translate the fitting straight line according to a preset theoretical offset value;
[0010] S5: On the translated straight line, calculate the edge endpoints of the two lower packages according to the gradient;
[0011] S6: Calculate the centers of the two lower packages according to the edge endpoints of the two lower packages, and calculate the angle of the straight line after translation;
[0012] S7: Calculate the notch direction corresponding to the three-pack steel mesh image.
[0013] Specifically, the three-pack steel mesh image is preprocessed, and the steps include:
[0014] After obtaining the three-pack steel mesh image, the three-pack steel mesh image is binarized using the OTSU algorithm automatic threshold;
[0015] Opening operation is used to filter out interference points of the three-pack steel mesh image;
[0016] The closing operation is used to fill the internal holes of the steel mesh and eliminate the jagged edges of the steel mesh.
[0017] Preferably, after preprocessing the three-pack steel mesh image, before roughly locating the center of the three-pack steel mesh according to the minimum circumscribed rectangle of the three-pack steel mesh image contour, the step further includes:
[0018] Extract the image contour of the three-pack steel mesh;
[0019] The longest side of the minimum circumscribed rectangle of the three-pack steel mesh image outline is rl;
[0020] The short side of the minimum circumscribed rectangle of the three-pack steel mesh image outline is rw;
[0021] And calculate the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image outline ra=rl×rw.
[0022] Specifically, the center of the three-pack steel mesh is roughly located according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image contour, and the steps include:
[0023] The first score is obtained according to the actual long side and the theoretical long side of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, score1=1-|1-rl / tl|;
[0024] Obtain the first score according to the actual short side and the theoretical short side of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, score2 = 1-|1-rw / tw|;
[0025] The third score is obtained according to the actual area and theoretical area of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, score3 = 1-|1-ra / ta|;
[0026] The first score, the second score and the third score obtained according to the minimum circumscribed rectangle of the three-pack steel mesh image contour are used to obtain an average score score=(score1+score2+score3) / 3.
[0027] Preferably, when the score is ≥ 0.6, the rectangle with the highest score is the target rectangle. Let the left center of the target rectangle be lec, the top center be tec, the right center bec, and the bottom center bec. According to the theoretical long side tl, the theoretical short side tw, the theoretical area is ta = tl × tw.
[0028] Preferably, the Y coordinate of the lower right rectangle of the three-pack steel mesh is y2=bec.y-to, and the Y coordinate of the upper side is y1=y2-rl / 3. Iterate all points p of contour1 i ,satisfy Then add it to the sequence seq1, where the offset from the center of the packet to the right is to, and the center of the bottom is bec.
[0029] Preferably, after the iteration is completed, a least squares straight line fitting is performed on seq1 to obtain a first straight line.
[0030] Preferably, the straight line is translated according to the set offset value to to obtain a second straight line.
[0031] Preferably, for all points on the second straight line, Start by searching upward and downward respectively, and stop when the first gradient equals 255, that is, point e1, e2 is obtained, and the coordinates of the center of the steel mesh are The angle is the angle of the second line minus 90 degrees.
[0032] Preferably, the projection from the upper end to the lower end of the minimum circumscribed rectangle is calculated in the Y direction, and the first-order derivative is calculated to obtain the Y coordinates of the two inflection points as y3 and y4. Then the Y coordinate of the gap is exist Scan the image from left to right within the range. When the gradient value is -255, the gap is on the right, and when the gradient value is 255, the gap is on the left.
[0033] The beneficial effects of the present invention are as follows: through S1: preprocessing the three-pack steel mesh image; S2: roughly locating the center of the three-pack steel mesh according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image contour; S3: extracting effective edge points and fitting a straight line according to the effective steel mesh edge area determined by the three-pack steel mesh position; S4: lateral translation of the fitted straight line according to a preset theoretical offset value; S5: on the translated straight line, calculating the edge endpoints of the two lower packages according to the gradient; S6: calculating the centers of the two lower packages according to the edge endpoints of the two lower packages, and calculating the angle of the straight line after translation; S7: calculating the notch direction corresponding to the three-pack steel mesh image, so as to facilitate positioning through the centers of the two lower right packages, so that the mounting position is more accurate, thereby improving the mounting capacity and improving the mounting efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 The present invention is a flow chart of a visual identification method of a three-pack steel mesh.
[0035] Figure 2 It is a schematic diagram of the effect of the visual identification method of three-pack steel mesh.
[0036] Figure 3 It is another schematic diagram of the effect of the visual identification method of the three-pack steel mesh.
[0037] Figure 4 It is another schematic diagram of the effect of the visual identification method of the three-pack steel mesh.
[0038] Figure 5 It is another schematic diagram of the effect of the visual identification method of the three-pack steel mesh.
[0039] Figure 6 It is another schematic diagram of the effect of the visual identification method of the three-pack steel mesh.
[0040] Figure 7 It is another schematic diagram of the effect of the visual identification method of the three-pack steel mesh.
[0041] Figure 8 It is another schematic diagram of the effect of the visual identification method of the three-pack steel mesh. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0043] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments:
[0044] Embodiment 1:
[0045] Figure 1 The implementation process of a visual recognition method of a three-pack steel mesh provided by the first embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0046] In step S101, the three-pack steel mesh image is preprocessed;
[0047] Specifically, the three-pack steel mesh image is preprocessed, and the steps include:
[0048] After obtaining the three-pack steel mesh image, the three-pack steel mesh image is binarized using the OTSU algorithm automatic threshold;
[0049] Opening operation is used to filter out interference points of the three-pack steel mesh image;
[0050] The closing operation is used to fill the internal holes of the steel mesh and eliminate the jagged edges of the steel mesh.
[0051] In step S102, the center of the three-pack steel mesh is roughly located according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image contour;
[0052] Preferably, after preprocessing the three-pack steel mesh image, before roughly locating the center of the three-pack steel mesh according to the minimum circumscribed rectangle of the three-pack steel mesh image contour, the step further includes:
[0053] Extract the image contour of the three-pack steel mesh;
[0054] The longest side of the minimum circumscribed rectangle of the three-pack steel mesh image outline is rl;
[0055] The short side of the minimum circumscribed rectangle of the three-pack steel mesh image outline is rw;
[0056] And calculate the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image outline ra=rl×rw.
[0057] Specifically, the center of the three-pack steel mesh is roughly located according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image contour, and the steps include:
[0058] The first score is obtained according to the actual long side and the theoretical long side of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, score1=1-|1-rl / tl|;
[0059] Obtain the first score according to the actual short side and the theoretical short side of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, score2 = 1-|1-rw / tw|;
[0060] The third score is obtained according to the actual area and theoretical area of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, score3 = 1-|1-ra / ta|;
[0061] The first score, the second score and the third score obtained according to the minimum circumscribed rectangle of the three-pack steel mesh image contour are used to obtain an average score score=(score1+score2+score3) / 3.
[0062] Preferably, when the score is ≥ 0.6, the rectangle with the highest score is the target rectangle. Let the left center of the target rectangle be lec, the top center be tec, the right center bec, and the bottom center bec. According to the theoretical long side tl, the theoretical short side tw, the theoretical area is ta = tl × tw.
[0063] In step S103, according to the effective steel mesh edge area determined by the three-pack steel mesh position, the effective edge points are extracted and a straight line is fitted;
[0064] In step S104, the fitting straight line is laterally translated according to a preset theoretical offset value;
[0065] Preferably, the Y coordinate of the lower right rectangle of the three-pack steel mesh is y2=bec.y-to, and the Y coordinate of the upper side is y1=y2-rl / 3. Iterate all points p of contour1 i ,satisfy Then add it to the sequence seq1, where the offset from the center of the packet to the right is to, and the center of the bottom is bec.
[0066] Preferably, after the iteration is completed, a least squares straight line fitting is performed on seq1 to obtain a first straight line.
[0067] Preferably, the straight line is translated according to the set offset value to to obtain a second straight line.
[0068] In step S105, on the translated straight line, the edge endpoints of the two lower packets are calculated according to the gradient;
[0069] In step S106, the centers of the two lower packages are calculated according to the edge endpoints of the two lower packages, and the angle of the straight line after translation is calculated;
[0070] Preferably, for all points on the second straight line, Start by searching upward and downward respectively, and stop when the first gradient equals 255, that is, point e1, e2 is obtained, and the coordinates of the center of the steel mesh are The angle is the angle of the second line minus 90 degrees.
[0071] In step S107, the notch direction corresponding to the three-pack steel mesh image is calculated.
[0072] Preferably, the projection from the upper end to the lower end of the minimum circumscribed rectangle is calculated in the Y direction, and the first-order derivative is calculated to obtain the Y coordinates of the two inflection points as y3 and y4. Then the Y coordinate of the gap is exist Scan the image from left to right within the range. When the gradient value is -255, the gap is on the right, and when the gradient value is 255, the gap is on the left.
[0073] A person skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, such as ROM / RAM, disk, CD-ROM, etc.
[0074] Embodiment 2:
[0075] Figures 2 to 8 A schematic flow chart of a method for visually identifying a three-pack steel mesh is shown. For ease of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0076] Step 1): Pre-treatment
[0077] like Figure 2 , Figure 3 As shown, the image is first binarized using Otsu automatic thresholding. There may be some interference points in the image, which are first filtered out using an open operation, and then a closed operation is used to fill the holes inside the steel mesh and eliminate the jagged edges of the steel mesh.
[0078] Step 2): Roughly locate the target center and angle
[0079] like Figure 4As shown, image contour extraction, calculation of the minimum bounding rectangle, assuming that the long side of the detected minimum bounding rectangle is rl, the short side is rw, and the area ra = rl × rw. According to the theoretical long side tl, the theoretical short side tw, and the theoretical area ta = tl × tw, the score of each rectangle is:
[0080] score1=1-|1-rl / tl|
[0081] score2=1-|1-rw / tw|
[0082] score3=1-|1-ra / ta|
[0083] score=(score1+score2+score3) / 3
[0084] The rectangles with score ≥ 0.6 are sorted from high to low. The rectangle with the highest score is the target rectangle, which is set as box1. The center of its left side is set as lec, the center of its top side is set as tec, the center of its right side is set as rec, and the center of its bottom side is set as bec. The corresponding contour is the target contour, which is set as contour1.
[0085] Step 3): Calculate the center line
[0086] like Figure 4 , 5 As shown in Figure 6, since the right edge of the steel mesh is not a straight line, it is necessary to extract the edge points of the straight line part of the right edge during fitting, such as Figure 4 As shown in the lower right rectangle, its lower Y coordinate is y2 = bec.y-to, and its upper Y coordinate is y1 = y2-rl / 3. Iterate all points p of contour1. i , if satisfied
[0087]
[0088] Then add it to the sequence seq1. After the iteration is completed, the least squares straight line is fitted to seq1 to obtain the straight line l1. The result is as follows Figure 5 As shown in the figure, the straight line is translated according to the set offset value to to obtain the straight line l2.
[0089] Step 4): Find the endpoints, calculate the center, and calculate the angle
[0090] like Figure 7 As shown, for all points on the straight line l2, the Y coordinate is Start by searching upward and downward respectively, and stop when the first gradient equals 255, that is, point e1, e2 is obtained, and the coordinates of the center of the steel mesh are The angle is the angle of l2 minus 90 degrees (calculated from the shorter side).
[0091] From the upper end to the lower end of the minimum circumscribed rectangle, calculate the projection in the Y direction, calculate the first-order derivative, and get the Y coordinates of the two inflection points as y3 and y4. Then the Y coordinate of the gap is exist
[0092] Scan the image from left to right within the range. If the gradient value is -255, the gap is on the right side. If the gradient value is 25, the gap is on the left side.
[0093] Those skilled in the art will appreciate that the units and algorithm steps of the embodiments described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware or in a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0094] Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. The above is only a specific implementation of the present invention, but the protection scope of the present invention is not limited thereto. Any person familiar with the technical field can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A visual recognition method for three-pack steel mesh, characterized in that: The following steps are involved: S1: preprocess the three-pack steel mesh image; S2: roughly locate the center of the three-pack steel mesh according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image outline; After preprocessing the three-pack steel mesh image, before roughly locating the center of the three-pack steel mesh according to the minimum circumscribed rectangle of the three-pack steel mesh image contour, the step further includes: Extract the image contour of the three-pack steel mesh; The longest side of the minimum circumscribed rectangle of the three-pack steel mesh image outline is ; The short side of the minimum circumscribed rectangle of the three-pack steel mesh image outline is ; And calculate the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image outline ; The center of the three-pack steel mesh is roughly located according to the actual area of the minimum circumscribed rectangle of the three-pack steel mesh image contour, and the steps include: The first score is obtained according to the actual long side and theoretical long side of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, ; The first score is obtained based on the actual short side and theoretical short side of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, ; The third score is obtained based on the actual area and theoretical area of the minimum circumscribed rectangle of the three-pack steel mesh image contour, that is, ; The average score is obtained by obtaining the first score, the second score and the third score based on the minimum circumscribed rectangle of the three-pack steel mesh image contour ; when The rectangle with the highest score is the target rectangle, and the left center of the target rectangle is , the upper center is , the right center is , the center below is , according to the theory, the long side is , the theoretical short side is , the theoretical area is ; The Y coordinate of the lower right rectangle of the three-pack steel mesh is , the upper Y coordinate is , iteration All points ,satisfy Add to sequence , where the offset from the center of the package to the right is: , the center below is ;Will The rectangles are sorted from high to low by scores, and the rectangle with the highest score is the target rectangle, set ;and The corresponding contour is the target contour, set ; After the iteration, Perform the least squares straight line fitting to obtain the first straight line; According to the set offset value Translate the straight line to obtain the second straight line; For all points on the second straight line, Start by searching upward and downward, and stop when you encounter the first gradient equal to 255. , the center coordinates of the steel mesh are , the angle is the angle of the second straight line minus 90 degrees; From the upper end to the lower end of the minimum circumscribed rectangle, calculate the projection in the Y direction, calculate the first-order derivative, and get the Y coordinates of the two inflection points: , then the Y coordinate of the gap is ,exist Scan the image from left to right within the range. When the gradient value is -255, the gap is on the right, and when the gradient value is 255, the gap is on the left. S3: According to the effective steel mesh edge area determined by the three-pack steel mesh position, extract the effective edge points and fit the straight line; S4: Transversely translate the fitting straight line according to a preset theoretical offset value; S5: On the translated straight line, calculate the edge endpoints of the two lower packages according to the gradient; S6: Calculate the centers of the two lower packages according to the edge endpoints of the two lower packages, and calculate the angle of the straight line after translation; S7: Calculate the notch direction corresponding to the three-pack steel mesh image.
2. The visual recognition method of a three-clad steel mesh according to claim 1 is characterized in that: Preprocessing the three-pack steel mesh image includes: After obtaining the three-pack steel mesh image, the three-pack steel mesh image is binarized using the OTSU algorithm automatic threshold; Opening operation is used to filter out interference points of the three-pack steel mesh image; The closing operation is used to fill the internal holes of the steel mesh and eliminate the jagged edges of the steel mesh.
Citation Information
Patent Citations
Visual inspection method for chip electronic component position error based on edge fitting
CN101839690A
Method for achieving rapid counterpoint of PCB and steel mesh in printing machine
CN103287073A