Rapid detection method for rectangular elements of AOI equipment based on run-length coding affine transformation
Through the method based on run-length coding affine transformation, the detection process of rectangular components is simplified, the detection efficiency is improved, the problem of low detection efficiency in the existing technology is solved, and faster detection speed and more efficient automated monitoring are achieved.
Patent Information
- Application Number
- CN202411014252.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-10-15
AI Technical Summary
The existing defect detection technology has low detection efficiency for rectangular components, especially the algorithms using template matching and affine transformation plus feature matching are complex, which affects the high-speed operation of AOI equipment.
The method based on run-length coding affine transformation is used to determine whether the workpiece to be tested passes the inspection by photographing the template image, generating the template coordinate system, collecting the image to be tested, calculating the affine transformation matrix, cropping the image, performing position correction and calculating the coincidence rate.
It achieves faster and more efficient matching detection, optimizes the affine transformation steps, increases detection speed, shortens detection time, improves automated monitoring efficiency, and doubles the detection speed compared to conventional solutions.
Smart Images

Figure CN118777315A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of defect detection, and in particular to a method for quickly detecting rectangular components of an AOI device based on run-length encoding affine transformation. Background Art
[0002] Defect detection technology is one of the basic technologies of modern industry and is widely used in many fields such as manufacturing, medical treatment, food safety, aerospace, etc. Traditional defect detection technology mainly relies on manual visual inspection and simple mechanical equipment. This method is not only inefficient, but also easily interfered by human factors, resulting in missed detection or false detection. With the rapid development of computer vision, some professional defect detection equipment has received more and more attention.
[0003] AOI optical automatic inspection equipment is a typical defect detection equipment, which plays a vital role in the batch inspection process of workpieces. For defect detection of rectangular components such as resistors and chips on circuit boards (missing parts, wrong parts, leaking solder, and bridging), the conventional practice is to correct them first and then match them. For example, Patent Document 1 (CN117274024A) mentions the use of a combined rectangle recognition based on template matching for detection, and Patent Document 2 (CN117274219A) uses a template matching and positioning method device for defect detection. Another approach is to use affine transformation for image correction, and then match them through feature matching algorithms such as (SIFT, SURF, ORB, etc.). For example, Patent Document 3 (CN115689873A) uses radial transformation and ORB matching algorithm for matching.
[0004] However, for rectangular workpieces, whether using template matching or radial transformation plus feature matching, the algorithm is relatively complex, which affects the efficiency of uniform batch part testing and is not conducive to the high-speed operation of the AOI marking machine inspection line. Summary of the invention
[0005] This patent proposes a method for quickly detecting rectangular components of AOI equipment based on run-length encoding affine transformation. The method for quickly detecting rectangular components of AOI equipment based on run-length encoding affine transformation includes the following steps:
[0006] Step 1, photograph the template image of the workpiece to be measured, and generate a template coordinate system based on the coordinates of the marking points;
[0007] Step 2, using a camera to capture an image of the workpiece to be measured, intercepting the ROI area, and generating a coordinate system to be measured based on the marking points;
[0008] Step 3, generating an affine transformation matrix based on the template coordinate system and the coordinate system to be measured;
[0009] Step 4, cropping the workpiece in the image to be inspected according to the position of the workpiece in the template image to obtain the workpiece image;
[0010] Step 5, obtaining a position-corrected image through affine transformation based on the workpiece image;
[0011] Step 6, calculating the overlap rate by the output area and the standard area;
[0012] Step 7: Determine whether the workpiece has passed the test based on the overlap rate.
[0013] Furthermore, in step 3, the following steps are also included:
[0014] Step 31, calculating the forward transformation matrix Hom2D from the workpiece to be detected to the template workpiece based on the coordinates of multiple marking points in the image of the workpiece to be detected and the coordinates of the corresponding marking points in the template image;
[0015] Step 32, invert the forward transformation matrix Hom2D to obtain the inverse matrix Hom2DInv.
[0016] Furthermore, in step 5, the following steps are also included:
[0017] Step 51, taking the foreground area as the input area A, and creating a hash table LutInput corresponding to the minimum circumscribed rectangle of the input area A;
[0018] Step 52, generating a reverse region B based on the input region A, and traversing and calculating the reverse region B;
[0019] Step 53, traverse the reverse region B, compare the calculation result of the inverse matrix Hom2DInv with the hash table LutInput, and obtain the output region C.
[0020] Furthermore, in step 51, based on the vertices of the smallest regular rectangle circumscribing the input area A as the origin of the input area coordinate system, the coordinates (Col, Row) of each point in the smallest regular rectangle circumscribing the input area A in the original image coordinate system are generated through the correspondence between the original image coordinate system and the input area coordinate system;
[0021] Convert the coordinates (Col, Row) of the smallest circumscribed rectangle of the input area A in the original image coordinate system to the index number Index of the hash table LutInput:
[0022] Index=Row i *width+Col i
[0023] Index represents the index number of the hash table LutInput, Row i Indicates the ordinate of point i in the smallest regular rectangle circumscribing the input area A. Width indicates the width of the input area coordinate system. Col iRepresents the horizontal coordinate of point i in the input area A;
[0024] The index number belonging to the input area A is assigned a value of 1, and the index number of the smallest regular rectangle circumscribing the input area A is assigned a value of 0.
[0025] Furthermore, in step 52, the minimum rectangular region where the output region C obtained after the input region A is forward transformed is the reverse region B;
[0026] The area traversal method is to start from the upper left point of the reverse area B, traverse from left to right and from top to bottom.
[0027] Furthermore, in step 53, a point (x i ,y i ) to the output point (Dstx) in input area A i ,Dsty i ) is calculated as follows:
[0028]
[0029] A 11 Represents the value of the first row and first column of the affine transformation matrix, A 12 Represents the value of the first row and second column of the affine transformation matrix, A 13 Represents the value of the first row and third column of the affine transformation matrix, A 21 Represents the value of the second row and first column of the affine transformation matrix, A 22 Represents the value of the second row and second column of the affine transformation matrix, A 23 Represents the value of the second row and third column of the affine transformation matrix;
[0030] The mapping method of the foreground point coordinates in the hash table LutInput that generates the minimum rectangular circumference of the input area A is:
[0031] Point In A = LutInput[(Dstx i -RectX)*width+(Dsty i -RectY)]
[0032] Where (RectX, RectY) is the coordinate of the upper left corner of the smallest regular rectangle circumscribing the input area A, (Col i ,Row i ) is the coordinate of point i in the smallest regular rectangle circumscribing the input area A, wudth represents the width of the input area coordinate system, and LutInput is the established hash table;
[0033] The output point (Dstx i ,Dstyi ) and the hash table LutInput for search, Point In A is the output point (Dstx i ,Dsty i ), the value corresponding to which is 1 indicates that the point is a foreground point, i.e., input area A; the value is 0 or does not exist, indicating that the point is a background point;
[0034] All points whose corresponding value is 1 in the reverse area B are selected as the output area C of the position-corrected image.
[0035] Furthermore, in step 5, the following steps are also included:
[0036] Step 54, the inverse matrix Hom2DInv is integer-scaled with a scaling factor of 2. 32 , the result is carried over by a 64-bit integer type;
[0037] Step 55, the region traversal method adopts column traversal using AVX512 instruction set, and row traversal using OpenMP multithreading;
[0038] Step 56, for each coordinate (Dstx i ,Dsty i ), which needs to be reshaped and reduced when used 2 32 .
[0039] Furthermore, in step 54, the inverse matrix Hom2DInv is integer-scaled to:
[0040]
[0041] Dst represents the point from the middle of area B (x i ,y i ) is mapped to obtain the midpoint of A (Dstx i ,Dsty i ), A 11 Represents the value of the first row and first column of the affine transformation matrix, A 12 Represents the value of the first row and second column of the affine transformation matrix, A 13 Represents the value of the first row and third column of the affine transformation matrix, A 21 Represents the value of the second row and first column of the affine transformation matrix, S 22 Represents the value of the second row and second column of the affine transformation matrix, A 23 Represents the value at the second row and third column of the affine transformation matrix.
[0042] Furthermore, in step 55, a single point (Dstx i ,Dsty i) occupies 128 bits in total, split loading (Dstx i ,Dsty i ) coordinates can process 8 points at a time; (Dstx i ,Dsty i ) is split by loop, then the loading calculation of the first group of points is:
[0043] Tmp x =A 11 x0+A 12 (y0-1)+A 13
[0044] Tmp y =A 21 x0+A 22 (y0-1)+A 23
[0045] Dstx0=Tmp x +A 12
[0046] Dsty0=Tmp y +A 22
[0047] (x 0, y0) represents the coordinates of a point in region B, and (Dstx0, Dsty0) represents the position of the point in region A obtained by inverse radial transformation;
[0048] Tmp x Indicates the intermediate variable for calculating column coordinates in the loop, Tmp y Represents the intermediate variable for calculating row coordinate values in the loop;
[0049] And so on:
[0050] Dstx i =Dstx i-1 +A 12
[0051] Dsty i =Dsty i-1 +A 22
[0052] Dstx i Indicates the column coordinate value in this cycle, Dstx i-1 Indicates the column coordinate value in the previous cycle, Dsty i Indicates the row coordinate value in this loop, Dsty i-1 Indicates the row coordinate value in the previous cycle;
[0053] In the instruction set:
[0054] X0=(Dstx0,Dstx1,Dstx2,Dstx3,Dstx4,Dstx5,Dstx6,Dstx7)
[0055] Y0=(Dsty0,Dsty1,Dsty2,Dsty3,Dsty4,Dsty5,Dsty6,Dsty7)
[0056] X0 represents the column coordinate value of 8 consecutive points in a set of coordinate calculations, and Y0 represents the row coordinate value of 8 consecutive points in the same set of coordinate calculations;
[0057] Subsequent loops only need to increment a constant:
[0058] X i =X i-1 +8*A 12 ,i>0
[0059] Y i =Y i-1 +8*A 22 ,i>0
[0060] X i Represents the column coordinate values of a group of consecutive points in the current loop, X i-1 Represents the column coordinate values of a group of consecutive points in the previous cycle, Y i Indicates the row coordinate values of a group of consecutive points in the current loop, Y i-1 Represents the row coordinate values of a group of consecutive points in the previous cycle;
[0061] In step 56, the plastic reduction 2 32 The result is stored in 32 bits as:
[0062] Row i =Dstx i >>32,Col i =Dsty i >>32
[0063] In the column-by-column loop, the processing of a row of data only requires loading from the main memory to the register once, and the remaining position operations are all performed in the register; for points with a number less than 8, non-instruction set operations are used.
[0064] Furthermore, in step 6, the overlap rate is the ratio of the intersection of the output area C and the standard area D to the area of the standard area D. The area of the standard area is the area of the template produced offline, and the intersection area is obtained by counting whether the index offset in the array LutOut is in the standard area D.
[0065] The beneficial effects achieved by the present invention are:
[0066] The present invention uses a simpler matching scheme in detection to achieve faster and more efficient matching, and on this basis, focuses on optimizing the core step of the operation, affine transformation, so that the detection speed is further improved.
[0067] The present invention performs the detection of missing and wrong parts in the form of overlap rate, so it is only necessary to set a reasonable overlap rate threshold to simultaneously perform the detection of missing and wrong parts.
[0068] The present invention greatly reduces the size of the detection image and effectively improves the detection speed through ROI area cropping and foreground selection. At the same time, through instruction set and multi-threading, it can greatly shorten the detection time and improve the efficiency of automatic monitoring. Compared with conventional detection schemes, the detection speed can be increased by one order of magnitude. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 A schematic flow chart of a method for rapid detection of rectangular components of an AOI device based on run-length encoding affine transformation provided by the present invention;
[0070] Figure 2 A schematic diagram of affine transformation in a method for rapid detection of rectangular components of an AOI device based on run-length encoding affine transformation provided by the present invention;
[0071] Figure 3 The effect diagram of missing parts in the method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation provided by the present invention;
[0072] Figure 4 This is an effect diagram of mismatched parts in a method for rapid detection of rectangular components of an AOI device based on run-length encoding affine transformation provided by the present invention. DETAILED DESCRIPTION
[0073] The present invention will be further described below in conjunction with specific embodiments, and the advantages and features of the present invention will become clearer as the description proceeds. However, these embodiments are exemplary only and do not constitute any limitation to the scope of the present invention. It should be understood by those skilled in the art that the details and forms of the technical solution of the present invention may be modified or replaced without departing from the spirit and scope of the present invention, but these modifications and replacements all fall within the scope of protection of the present invention.
[0074] As attached Figure 1 As shown, the AOI device rectangular component rapid detection method adopted by the present invention is a rapid detection method based on run-length encoding affine transformation, and the method comprises the following steps:
[0075] Step 1, photograph the template image of the workpiece to be tested, and generate a template coordinate system based on the coordinates of the mark points;
[0076] The mark is a positioning point set at a fixed position on the PCB board.
[0077] Step 2, using a camera to capture an image of the workpiece to be measured, intercepting the ROI area, and generating a coordinate system to be measured based on the mark points;
[0078] The camera uses visible light band and is an area array industrial camera that can communicate with the host computer.
[0079] The intercepted ROI area is the area where the workpiece is drawn at the standard part position when the offline template is made.
[0080] Step 3, generating an affine transformation matrix based on the template coordinate system and the coordinate system to be measured;
[0081] The specific steps include:
[0082] Step 31, based on the coordinates of the three mark points in the image of the workpiece to be tested and the coordinates of the three mark points in the template image, a forward transformation matrix Hom2D with a size of 3*3 from the workpiece to be tested to the template workpiece is calculated;
[0083] Step 32, invert the forward transformation matrix Hom2D to obtain the inverse matrix Hom2DInv.
[0084] The inverse matrix Hom2DInv is:
[0085]
[0086] A 11 Represents the value of the first row and first column of the affine transformation matrix, A 12 Represents the value of the first row and second column of the affine transformation matrix, A 13 Represents the value of the first row and third column of the affine transformation matrix, A 21 Represents the value of the second row and first column of the affine transformation matrix, A 22 A represents the value at the second row and second column of the affine transformation matrix, and A3 represents the value at the second row and third column of the affine transformation matrix.
[0087] Step 4, cropping the workpiece in the image to be inspected according to the position of the workpiece in the template image to obtain the workpiece image;
[0088] The ROI area is subjected to image binarization. The binarization threshold is the threshold set when the offline template is made. The image after binarization is divided into foreground area and background area, and run length encoding is used to represent the foreground area.
[0089] Step 5, obtaining a position-corrected image through affine transformation based on the workpiece image;
[0090] Step 51, taking the foreground area as the input area A, and creating a hash table LutInput corresponding to the minimum circumscribed rectangle of the input area A;
[0091] First, based on the vertices of the smallest circumscribed rectangle of input area A as the origin of the input area coordinate system, the coordinates (Col, Row) of each point in the smallest circumscribed rectangle of input area A in the original image coordinate system are generated through the correspondence between the original image coordinate system and the input area coordinate system.
[0092] Secondly, convert the coordinates (Col, Row) of the smallest rectangular circumscribed in the input area A in the original image coordinate system to the index number Index of the hash table LutInput:
[0093] Index=Row i *width+Col i
[0094] Index represents the index number of the hash table LutInput, Row i Indicates the ordinate of point i in the smallest regular rectangle circumscribing the input area A. Width indicates the width of the input area coordinate system. Col i Represents the horizontal coordinate of point i in the input area A.
[0095] The index number belonging to the input area A is assigned a value of 1, and the index number of the smallest regular rectangle circumscribing the input area A is assigned a value of 0.
[0096] Step 52, generating a reverse region B based on the input region A, and traversing and calculating the reverse region B;
[0097] The minimum rectangular area where the output area C obtained after the forward transformation of the input area A is located is the reverse area B, and the reverse area retrieval needs to traverse the reverse area B.
[0098] The area traversal method is to start from the upper left point of the reverse area B, traverse from left to right and from top to bottom.
[0099] Step 53, compare the traversal calculation result of the reverse area B with the hash table LutInput to obtain the output area C;
[0100] By retrieving the coordinate value in reverse, the calculation is performed using the points in the reverse region B and the inverse matrix Hom2DInv. The calculation formula is: Input point (x i ,y i ) to the output point (Dstx) in input area A i ,Dsty i ) is calculated as follows:
[0101]
[0102] Finally, the mapping method of the foreground point coordinates in the hash table LutInput that generates the minimum rectangular circumference of the input area A is:
[0103] Point In A = LutInput[(Dstx i -RectX)*width+(Dsty i -RectY)]
[0104] Where (RectX, RectY) is the coordinate of the upper left corner of the smallest regular rectangle circumscribing the input area A, (Col i ,Row i ) is the coordinate of point i in the smallest regular rectangle circumscribing the input area A, width represents the width of the input area coordinate system, and LutInput is the established hash table.
[0105] The output point (Dstx i ,Dsty i ) and the hash table LutInput for search, Point In A is the output point (Dstx i ,Dsty i ) The value corresponding to this point is 1, which means that the point is a foreground point, i.e., input area A. The value is 0 or does not exist, which means that the point is a background point.
[0106] All points whose corresponding value is 1 in the reverse area B are selected as the output area C of the position-corrected image.
[0107] Furthermore, in step 5, the following scheme can be used to improve the detection rate, which specifically includes the following steps:
[0108] Step 54, the inverse matrix Hom2DInv is integer-scaled with a scaling factor of 2. 32 , the result is carried over by a 64-bit integer type.
[0109]
[0110] Dst represents the point from the middle of area B (x i ,y i ) is mapped to obtain the midpoint of A (Dstx i ,Dty i )’s coordinate values.
[0111] Step 55, the region traversal method adopts column traversal using AVX512 instruction set, and row traversal using OpenMP multithreading;
[0112] Single point (Dtx i ,Dsty i) occupies 128 bits in total, split loading (Dstx i ,Dsty i ) coordinates can process 8 points at a time; (Dstx i ,Dsty i ) is split by loop, then the load calculation of the first group of points is:
[0113] Tmp x =A 11 x0+A 12 (y0-1)+A 13
[0114] Tmp y =A 21 x0+A 22 (y0-1)+A 23
[0115] Dstx0=Tmp x +A 12
[0116] Dsty0=Tmp y +Z 22
[0117] (A 0, y0) represents the coordinates of a point in region B, and (Dstx0, Dsty0) represents the position of the point in region A obtained after inverse radial transformation.
[0118] Tmp x Indicates the intermediate variable for calculating column coordinates in the loop, Tmp y Represents the intermediate variable for calculating row coordinate values in the loop;
[0119] And so on:
[0120] Dstx i =Dstx i-1 +A 12
[0121] Dsty i =Dsty i-1 +A 22
[0122] Dstx i Indicates the column coordinate value in this cycle, Dstx i-1 Indicates the column coordinate value in the previous cycle, Dsty i Indicates the row coordinate value in this loop, Dsty i-1 Indicates the row coordinate value in the previous cycle.
[0123] In the instruction set:
[0124] X0=(Dstx0,Dstx1,Dstx2,Dstx3,Dstx4,Dstx5,Dstx6,Dstx7)
[0125] Y0=(Dsty0,Dsty1,Dsty2,Dsty3,Dsty4,Dsty5,Dsty6,Dsty7)
[0126] X0 represents the column coordinate value of 8 consecutive points in a set of coordinate calculations, and Y0 represents the row coordinate value of 8 consecutive points in the same set of coordinate calculations;
[0127] Subsequent loops only need to increment a constant:
[0128] X i =X i-1 +8*A 12 ,i>0
[0129] Y i =Y i-1 +8*A 22 ,i>0
[0130] X i Represents the column coordinate values of a group of consecutive points in the current loop, X i-1 Represents the column coordinate values of a group of consecutive points in the previous cycle, Y i Indicates the row coordinate values of a group of consecutive points in the current loop, Y i-1 Represents the row coordinate values of a group of consecutive points in the previous cycle;
[0131] Step 56, for each coordinate (Dstx i ,Dsty i ), which needs to be reshaped and reduced when used 2 32 , the result is stored in 32 bits, that is:
[0132] Row i =Dstx i >>32,Col i =Dsty i >>32
[0133] In the column-by-column loop, the processing of a row of data only requires loading from the main memory to the register once, and the remaining position operations are all performed in the register; for points with a number less than 8, non-instruction set operations are used.
[0134] Step 6, calculating the overlap rate by the output area and the standard area;
[0135] The overlap rate is the ratio of the intersection of the output area C and the standard area D to the area of the standard area D. The area of the standard area is the area of the template made offline, and the intersection area is obtained by counting whether the index offset in the array LutOut is in the standard area D.
[0136] Step 7, determining the test result according to the overlap rate;
[0137] The overlap rate should be set according to the usage scenario, and the general setting range is between 60% and 100%.
[0138] As attached Figure 3-4 The following figure shows the actual detection effect of this solution. The highlight of this solution is that it greatly improves the detection speed while ensuring the detection effect. Figure 4 The following is a successful matching image. The expected results can be achieved by using the patented solution, template matching, and contour matching on a computer with an i7 7700 CPU. However, the entire detection process of the patented solution takes 0.9883ms, contour matching takes 4.6171ms, and template matching takes 6.6320ms. The matching speed of the patented solution in this scenario is much faster than that of conventional matching solutions.
[0139] The present invention is not limited to the above-mentioned specific implementation modes. A person skilled in the art may implement the present invention in various other specific implementation modes according to the embodiments and the disclosure of the drawings. Therefore, any design that adopts the design structure and concept of the present invention and makes some simple transformations or changes shall fall within the scope of protection of the present invention.
Claims
1. A method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation, characterized in that: The method for quickly detecting rectangular components of AOI equipment based on run-length encoding affine transformation comprises the following steps: Step 1, photograph the template image of the workpiece to be measured, and generate a template coordinate system based on the coordinates of the marking points; Step 2, using a camera to capture an image of the workpiece to be measured, intercepting the ROI area, and generating a coordinate system to be measured based on the marking points; Step 3, generating an affine transformation matrix based on the template coordinate system and the coordinate system to be measured; Step 4, cropping the workpiece in the image to be inspected according to the position of the workpiece in the template image to obtain the workpiece image; Step 5, obtaining a position-corrected image through affine transformation based on the workpiece image; Step 6, calculating the overlap rate by the output area and the standard area; Step 7: Determine whether the workpiece has passed the test based on the overlap rate.
2. According to claim 1, the method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation is characterized in that: In step 3, the following steps are also included: Step 31, calculating the forward transformation matrix Hom2D from the workpiece to be detected to the template workpiece based on the coordinates of multiple marking points in the image of the workpiece to be detected and the coordinates of the corresponding marking points in the template image; Step 32, invert the forward transformation matrix Hom2D to obtain the inverse matrix Hom2DInv.
3. According to claim 1, the method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation is characterized in that: In step 5, the following steps are also included: Step 51, taking the foreground area as the input area A, and creating a hash table LutInput corresponding to the minimum circumscribed rectangle of the input area A; Step 52, generating a reverse region B based on the input region A, and traversing and calculating the reverse region B; Step 53, traverse the reverse region B, compare the calculation result of the inverse matrix Hom2DInv with the hash table LutInput, and obtain the output region C.
4. According to claim 3, the method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation is characterized in that: In step 51, based on the vertices of the smallest regular rectangle circumscribing the input area A as the origin of the input area coordinate system, the coordinates (Col, Row) of each point in the smallest regular rectangle circumscribing the input area A in the original image coordinate system are generated through the correspondence between the original image coordinate system and the input area coordinate system; Convert the coordinates (Col, Row) of the smallest circumscribed rectangle of the input area A in the original image coordinate system to the index number Index of the hash table LutInput: Index=Row i *width+Col i Index represents the index number of the hash table LutInput, Row i Indicates the ordinate of point i in the smallest regular rectangle circumscribing the input area A. Width indicates the width of the input area coordinate system. Col i Represents the horizontal coordinate of point i in the input area A; The index number belonging to the input area A is assigned a value of 1, and the index number of the smallest regular rectangle circumscribing the input area A is assigned a value of 0.
5. According to claim 4, the method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation is characterized in that: In step 52, the minimum rectangular area where the output area C obtained after the input area A is forward transformed is the reverse area B; The area traversal method is to start from the upper left point of the reverse area B, traverse from left to right and from top to bottom.
6. The method for rapid detection of rectangular components of AOI equipment based on run length encoding affine transformation according to claim 5 is characterized in that: In step 53, a point (x i ,y i ) to the output point (Dstx) in input area A i ,Dsty i ) is calculated as follows: A 11 Represents the value of the first row and first column of the affine transformation matrix, A 12 Represents the value of the first row and second column of the affine transformation matrix, A 13 Represents the value of the first row and third column of the affine transformation matrix, A 21 Represents the value of the second row and first column of the affine transformation matrix, A 22 Represents the value of the second row and second column of the affine transformation matrix, A 23 Represents the value of the second row and third column of the affine transformation matrix; The mapping method of the foreground point coordinates in the hash table LutInput that generates the minimum rectangular circumference of the input area A is: PointInA=LutInput[(Dstx i -RectX)*width+(Dsty i -RectY)] Where (RectX, RectY(are the coordinates of the upper left corner of the smallest regular rectangle circumscribing the input area A, 9Col i ,Row i ) is the coordinate of point i in the smallest regular rectangle circumscribing the input area A, wudth represents the width of the input area coordinate system, and LutInput is the established hash table; The output point (Dstx i ,Dsty i ) and the hash table LutInput for search, PointInA is the output point (Dstx i ,Dsty i ), the value corresponding to which is 1 indicates that the point is a foreground point, i.e., input area A; the value is 0 or does not exist, indicating that the point is a background point; All points whose corresponding value is 1 in the reverse area B are selected as the output area C of the position-corrected image.
7. The method for rapid detection of rectangular components of AOI equipment based on run-length encoding affine transformation according to claim 3 is characterized in that: In step 5, the following steps are also included: Step 54, the inverse matrix Hom2DInv is integer-scaled with a scaling factor of 2. 32 , the result is carried over by a 64-bit integer type; Step 55, the region traversal method adopts column traversal using AVX512 instruction set, and row traversal using OpenMP multithreading; Step 56, for each coordinate (Dstx i ,Dsty i ), which needs to be reshaped and reduced when used 2 32 .
8. The method for rapid detection of rectangular components of AOI equipment based on run length encoding affine transformation according to claim 7 is characterized in that: In step 54, the inverse matrix Hom2DInv is integer-enlarged to: Dst represents the point from the middle of area B (x i ,y i ) is mapped to obtain the midpoint of A (Dstx i ,Dsty i ), A 11 Represents the value of the first row and first column of the affine transformation matrix, A 12 Represents the value of the first row and second column of the affine transformation matrix, A 13 Represents the value of the first row and third column of the affine transformation matrix, A 21 Represents the value of the second row and first column of the affine transformation matrix, A 22 Represents the value of the second row and second column of the affine transformation matrix, A 23 Represents the value at the second row and third column of the affine transformation matrix.
9. The method for rapid detection of rectangular components of AOI equipment based on run length encoding affine transformation according to claim 7 is characterized in that: In step 55, a single point (Dstx i ,Dsty i ) occupies 128 bits in total, split loading (Dstx i ,Dsty i ) coordinates can process 8 points at a time; Set (Dstx in dst i ,Dsty i (By loop splitting, the load calculation of the first group of points is: Tmp x =A 11 x0+A 12 (y0-1)+A 13 Tmp y =A 21 x0+A 22 (y0-1)+A 23 Dstx0=Tmp x +A 12 Dsty0=Tmp y +Z 22 (A 0, y0) represents the coordinates of a point in region B, and (Dstx0, Dsty0) represents the position of the point in region A obtained by inverse radial transformation; Tmp x Indicates the intermediate variable for calculating column coordinates in the loop, Tmp y Represents the intermediate variable for calculating row coordinate values in the loop; And so on: Dstx i =Dstx i-1 +A 12 Dsty i =Dsty i-1 +A 22 Dstx i Indicates the column coordinate value in this cycle, Dstx i-1 Indicates the column coordinate value in the previous cycle, Dsty i Indicates the row coordinate value in this loop, Dsty i-1 Indicates the row coordinate value in the previous cycle; In the instruction set: X0=(Dstx0,Dstx1,Dstx2,Dstx3,Dstx4,Dstx5,Dstx6,Dstx7) Y0=(Dsty0,Dsty1,Dsty2,Dsty3,Dsty4,Dsty5,Dsty6,Dsty7) X0 represents the column coordinate value of 8 consecutive points in a set of coordinate calculations, and Y0 represents the row coordinate value of 8 consecutive points in the same set of coordinate calculations; Subsequent loops only need to increment a constant: X i =X i-1 +8*A 12 ,i>0 AND i =And i-1 +8*A 22 ,i>0 X i Represents the column coordinate values of a group of consecutive points in the current loop, X i-1 Represents the column coordinate values of a group of consecutive points in the previous cycle, Y i Indicates the row coordinate values of a group of consecutive points in the current loop, Y i-1 Represents the row coordinate values of a group of consecutive points in the previous cycle; In step 56, the plastic reduction 2 32 The result is stored in 32 bits as: Row i =Dstx i >>32,Col i =Dsty i >>32 In the column-by-column loop, the processing of a row of data only requires loading from the main memory to the register once, and the remaining position operations are all performed in the register; for points with a number less than 8, non-instruction set operations are used.
10. The method for rapid detection of rectangular components of AOI equipment based on run length encoding affine transformation according to claim 1, characterized in that: In step 6, the overlap rate is the ratio of the intersection of the output area C and the standard area D to the area of the standard area D. The area of the standard area is the area of the template made offline, and the intersection area is obtained by counting whether the index offset in the array LutOut is in the standard area D.
