A kind of TR elements positioning of view-based access control model and defect inspection method
Technical field
The present invention relates to the recognition methods of vision positioning and defects detection, the TR elements of more particularly to a kind of view-based access control model are determined
Position and defect inspection method.
Background technology
With the development of electronic industry, requirement of the market to electronic product is more and more harsher, not only to reach miniaturization, light
Quantify, be thinned, even more to reach automation in assembling production process.Therefore surface installation technique (SMT) arises at the historic moment simultaneously
Fast development, and the equipment of wherein core the most is exactly chip mounter.One chip mounter quality of measurement is most important three indexs:
The scope of component, placement speed and placement accuracy can be pasted.And between this, image recognition algorithm and flow are acknowledged as patch
The key of piece machine vision system, the effective range of element recognizer, which directly affects chip mounter, can paste the scope of component, its
Accuracy and speed also directly govern placement speed and placement accuracy.
Nowadays the chip mounter of China is just at the early-stage, far apart with foreign level, and the visual identity of slice component is calculated
Patent in terms of method is few again, for TR elements, is even more the complete vision positioning of neither one and detection algorithm at present
Deliver, this is very unfavorable for the development of China's electronic industry.
It is concentrated mainly on now for the vision research of surface mount elements among vision positioning and Symbol recognition, for paster member
The defects detection of part is main or is measured by manual precision instrument, and this not only wastes practice, wastes manpower, have also been introduced
More human errors, precision is very low.
Also there are many problems in the research of the vision positioning of nowadays surface mount elements, most of algorithms all have precision
It is low, poor real, the problems such as result of calculation is to light sensitive.
The content of the invention
The invention aims to solve to have in the vision research now for surface mount elements human error, precision it is low,
Poor real and result of calculation are to light sensitive problem, and a kind of TR elements positioning of the view-based access control model proposed and defects detection
Method.
Above-mentioned goal of the invention is achieved through the following technical solutions:
Step 1: checking selected area image brightness;Stop checking and returning phase if image appearance is too light or too dark
Answer error code;If bright spot number and the ratio always counted step 2 is gone to if interval [0.01,0.90];Wherein, selected region
Pixel value is considered bright spot for 255 pixel in image, and selected areas image all pixels point number is designated as total points;When bright
Count with the ratio always counted and to think that area image is too dark less than 0.01, when bright spot number and the ratio always counted are recognized more than 0.90
It is too bright for area image;
Step 2: carrying out two in the image of [0.01,0.90] to bright spot number in selected areas image and the ratio always counted
Value, obtains binary image;Wherein, binary image includes being manually entered the binaryzation that fixed threshold binarization method is obtained
Image and the binary image obtained using the maximum method of inter-class variance;
Step 3: carrying out external boundary extraction to the binary image obtained in step 2 using the maximum method of inter-class variance
Operation, obtain the external boundary point set of binary image, be stored in two-dimensional points container 1;Wherein, the operation that external boundary is extracted is adopted
Extraction operator is a kind of quick Contour extraction operator in 4 field, wherein, the description of the quick Contour extraction operator operator in 4 fields
It is as follows:
P is pixel to be determined, and the position in its 4 field is respectively P1, P2, P3 and P4;When having in P1, P2, P3 and P4
One when being background pixel point, judges P as boundary pixel point, is traveled through with the quick Contour extraction operator in 4 fields and use inter-class variance
The binary image that maximum method is obtained just obtains the i.e. binary image of border point set image of accurate single pixel width
External boundary point set.
Screened Step 4: the external boundary point set in the two-dimensional points container 1 obtained to step 3 carries out gray value inspection
Border point set afterwards, and the border point set after screening is pressed into a two-dimensional points container 2, it is designated as efficiency frontier point set;
Wherein, described step three China and foreign countries border point set carries out the specific of the border point set after gray value inspection is screened
Process is:
(1) any one external boundary point set that step 3 is obtained is taken, if the points that external boundary point set is included are more than 10, is entered
Row step (2);
(2) if the external boundary point set in step (1) has the external boundary point set for including or having nesting, it will include or embedding
Connected region all pixels point pixel value between the external boundary point set of set is set to 255;If the external boundary point set in step (1) does not have
Have and include or nested external boundary point set then border point set will include inside all pixels point pixel value and be set to 255 in addition;
(3) pixel value is drawn in an empty gray level image for 255 pixel, is designated as this external boundary point set
Bianry image;
(4) pixel value is the number of 255 pixel in calculation procedure (3), is designated as s1;It will be manually entered in step 2 solid
The bianry image for determining this external boundary point set of binary image that threshold binarization method obtains with being obtained in step (2) enters
Row step-by-step and computing, obtain a new bianry image, calculate the pixel number that pixel value in new bianry image is 255,
It is designated as s2;
(5) calculate s1/s2 value and s1/s2 values are less than to the border point set corresponding to 0.5 and delete;Repeat (1)~(5) straight
All external boundary point sets are obtained in step 3 to taking, and all external boundary point sets stayed are pressed into a two-dimensional points appearance
In device, that is, obtain effective border point set;
Step 5: the minimum enclosed rectangle of all efficiency frontier point sets is found, the minimum of all efficiency frontier point sets is outer
Rectangle is connect as the rough minimum enclosed rectangle of element, and by the anglec of rotation of the minimum enclosed rectangle of all efficiency frontier point sets
As the rough anglec of rotation α of TR elements, the centre coordinate of the minimum enclosed rectangle of all efficiency frontier point sets is used as TR elements
Rough centre coordinate (x0,y0);
The method that the minimum enclosed rectangle of all efficiency frontier point sets of described searching is used is the rotation after a kind of optimization
Turn goal method, concretely comprised the following steps referred to herein as dual-axis rotation method:
(1) horizontal spindle of all efficiency frontier point sets is found:Each row i of all efficiency frontier point sets is scanned successively,
Find the starting point coordinate (x of each row efficient boundary point collectioni1,yi1) and terminal point coordinate (xi2,yi2), so as to calculate target in the i-th row
Centre coordinate (x 'i,y′i):
It regard the centre coordinate of each row of all efficiency frontier point sets as one group of data (x 'i,y′i), utilize least square method
Fitting a straight line is carried out, obtains representing the linear equation y=k of the horizontal spindle initial position of all efficiency frontier point sets1x+b1;
Wherein, i=1,2 ..., N;k1For slope, b1For intercept;
(2) vertical major of all efficiency frontier point sets is found:Every a line j of all efficiency frontier point sets is scanned successively,
Find the starting point coordinate (x of each row bound point setj1,yj1) and terminal point coordinate (xj2,yj2), so as to calculate in jth row in target
Heart coordinate (x 'j,y′j):
It regard the centre coordinate of each row of this border point set as one group of data (x 'j,y′j), carried out using least square method straight
Line is fitted, and obtains representing the linear equation x=k of the vertical major initial position of all efficiency frontier point sets2y+b2;
Wherein, j=1,2 ..., M;k2For slope, b2For intercept;
(3) the initial minimum enclosed rectangle of all efficiency frontier point sets, referred to as initial minimum enclosed rectangle are asked for:Keep
The horizontal spindle direction of all efficiency frontier point sets is constant, finds and linear equation y=k1x+b1It is parallel, and and efficient boundary point
Two tangent straight line y=k of collection1x+b11And y=k1x+b12
Take i.e. k ' vertical with the horizontal spindle of efficiency frontier point set1=-1/k1And cross (x0,y0) vertical line y=k '1x+y0-
k′1x0, find vertical line and two tangent straight line y=k ' of efficiency frontier point set1x+b′11With y=k '1x+b′12;
According to four straight line y=k1x+b11, y=k1x+b12, y=k '1x+b′11With y=k '1x+b′12Intersection point just obtain
Four summits of initial minimum enclosed rectangle;
Wherein, y=k1x+b11For the coboundary of initial minimum enclosed rectangle;Y=k1x+b12For initial minimum enclosed rectangle
Lower boundary, y=k '1x+b′11For the left margin of initial minimum enclosed rectangle;Y=k '1x+b′12For initial minimum enclosed rectangle
Right margin;
(4) demand perfection body efficiency frontier point set minimum enclosed rectangle:Around the horizontal spindle and entirety of all efficiency frontier point sets
The intersection point rotation of the vertical major of efficiency frontier point set, anglec of rotation interval is taken as:From the level master of all efficiency frontier point sets
Axle initial position starts, and gradually rotated acute angle gamma is overlapped to efficiency frontier point set vertical major initial position, in the anglec of rotation
With △ θ=1 ° it is rotation steps each time in degree is interval, asking for postrotational entirety each time according to the method in step (3) has
Imitate the minimum enclosed rectangle of border point set;And calculate the minimum enclosed rectangle area for all efficiency frontier point sets for rotating the t times
Mt, draw out MtLine chart is observed;T=1,2 ..., [γ];[γ] is γ integer part;
(5) if the area M that step (4) is obtainedtMore than area M1,M2,...,Mt-11.1 times of middle minimum value, or effectively
The position slope rotated to of boundary point collection horizontal spindle is more than or equal to the slope of efficiency frontier point set vertical major;Then reach
End condition, reach end condition terminate after, by the rotation steps in step (4) be changed into △ θ=0.1 ° repeat step (4)~
(5) △ θ≤0.001 °, to the last and untill meeting above end condition;
Step 6: obtaining the centre coordinate (x for each efficiency frontier point set that step 4 is obtainedi,yi), i=1,2 ...,
N;Wherein, the centre coordinate (x of each efficiency frontier point seti,yi) be specially:
When point (x, y) is on efficiency frontier point set, f (x, y)=1;Otherwise f (x, y)=0;I=1,2 ..., N;N is represented
There is N number of border point set;
Step 7: the efficiency frontier point set that step 4 is obtained is divided into TR member upper efficiency frontier point sets and TR according to α
Two groups of element lower portions efficiency frontier point set;
Step 8: TR member upper efficiency frontiers point set, bottom efficiency frontier point set and step 6 that step 7 is obtained
The center of each obtained efficiency frontier point set carries out affine transformation according to the rough anglec of rotation α of element and become a full member;Simultaneously will
Rough centre coordinate (x0,y0) become a full member as (x '0,y′0);
Step 9: being detected to TR component types;If TR component types are standard TR types, continue step 10;It is no
Then, stop and return to corresponding error code;
Step 10: by the TR member upper efficiency frontier point sets and bottom efficiency frontier point set of step 7 according to belonging to pin
Relation classify obtaining the efficiency frontier point set of the first subseries, and the efficiency frontier point set of the first subseries is compiled
Number;
Step 11: the efficiency frontier point set of the first subseries obtained to step 10 carries out the foot and root of same pin
The classification of portion's efficiency frontier point set, determines the relation of pin-foot-root;And set up in three containers, three containers
One conventional pin efficiency frontier point set of container storage and conventional pin efficiency frontier point set numbering, second container storage are conventional
Pin foot efficiency frontier point set and conventional pin foot efficiency frontier point set numbering, it is effective that the 3rd container deposits special pin
Border point set and special pin efficiency frontier point set numbering;
Step 12: asking for the center point set of conventional pin efficiency frontier point set in first container in step 11 respectively
Center point set with conventional pin foot efficiency frontier point set in second container is:
The center point set of the conventional pin efficiency frontier point set in top is stored in the conventional pin central point container in top;
The center point set of the conventional pin foot efficiency frontier point set in top is stored in the conventional pin foot central point in top
In container;
The center point set of the conventional pin efficiency frontier point set in bottom is stored in the conventional pin central point container in bottom;
The center point set of the conventional pin foot efficiency frontier point set in bottom is stored in the conventional pin foot central point in bottom
In container;
Step 13: to the center point set and conventional pin foot efficiency frontier point set of conventional pin efficiency frontier point set
Center point set carries out least square fitting linear operating, obtains four straight lines, remembers that the conventional pin of TR element lower portions is effective respectively
The conventional pin efficiency frontier point set fitting a straight line Line_ of border point set fitting a straight line Line_downpin, TR member upper
Uppin, TR element lower portions routine pin foot efficiency frontier point set fitting a straight line Line_downfoot and TR member upper are conventional
Pin foot efficiency frontier point set fitting a straight line Line_upfoot;
Step 14: the efficiency frontier point set in three containers obtained according to step 11 determines that TR member uppers are effective
Pin average length hpin_up, the effective pin average length h of TR element lower portionspin_down, the effective pin foot of TR member uppers be averaged
Length hfoot_up, the effective pin foot average length h of TR element lower portionsfoot_down, the effective pin number s of TR member upperspin_up
With the effective pin number s of TR element lower portionspin_down;
Step 15: what the efficiency frontier point set and step 13 in three containers obtained according to step 11 were obtained
The top accurate mean breadth w of effective pin foot that four straight lines ask for TR elementsfoot_up, TR elements bottom effective pin essence
True mean breadth wpin_down, TR elements the accurate spacing p of the effective pin in toppin_up, TR elements the effective pin in bottom it is accurate between
Away from ppin_down, TR element true center coordinates (xa,ya), the accurate anglec of rotation α of TR elementsa, TR element strict widths wbodyAnd TR
Element precise length hbody;
Step 16: checking the defect of TR component pins:
(1) check whether TR component pins bend:Each minimum enclosed rectangle obtained in step 5 is rotated
The inspection of angle, the minimum enclosed rectangle anglec of rotation of i-th of pin of note is βi, when | αa-βi| TR component pins are thought when≤5
Normally, do not bend;When | αa-βi|>Think that i-th of pin anglec of rotation is excessive when 5, be bending pin;
(2) check whether TR component pins are symmetrical:Ask for TR member uppers routine pin border point set in step 11
Central point collection center G0, the conventional pin border point set of TR element lower portions central point collection center G1, the special pin edge of TR member uppers
The central point collection center G of boundary's point set2With the center G of the center point set of the special pin border point set of TR element lower portions3;Judge G0、
G1、G2And G3This four points arrived TR element true centers (xa,ya) and parallel to the vertical of the accurate minimum enclosed rectangle of TR elements
The distance of the straight line of main shaft, as distance respectively less than wbodyThink that symmetry meets the requirements when/20, otherwise return to symmetry and do not meet
It is required that error code;Complete the recognition methods of a kind of TR elements vision positioning and defects detection.
Invention effect
The present invention is even more in operation while the vision positioning of chip TR elements and defects of vision detection function is realized
The high level of a comparison is reached in speed and repeatable accuracy.Shown according to retest result, the present invention is to selected example
Average out to 20ms the time required to calculating once, the repeatable accuracys of identical lower 100 retests of external condition also reaches ±
In 0.001mm, it is seen that a kind of positioning of the TR elements of this view-based access control model and defect inspection method no matter precision, real-time, stability
It is all very high such as Figure 19.
Brief description of the drawings
Fig. 1 is selected 8 single channel area images that embodiment one is proposed;
Fig. 2 is the binary image figure of fixed threshold 150 that embodiment one is proposed
Fig. 3 is the Otsu binary images that embodiment one is proposed
Fig. 4 is the quick Boundary Extraction operator schematic diagram in 4 fields that embodiment one is proposed;
Fig. 5 is that the element found according to pin fitting a straight line the fitting minimum enclosed rectangle that embodiment ten is proposed shows
It is intended to;
Fig. 6 is the boundary image after the gray value that embodiment one is proposed is checked;
Fig. 7 is the element minimum enclosed rectangle schematic diagram that embodiment one is proposed;
Fig. 8 is the border point set and its centre coordinate schematic diagram after the gray value that embodiment one is proposed is checked;
Fig. 9 be embodiment one propose efficiency frontier point set packet after upper and lower part border point set and its
Center schematic diagram;
Figure 10 be embodiment one propose become a full member after border point set and its center schematic diagram;
Figure 11 is excessive back boundary point set and its center schematic diagram of becoming a full member of the anglec of rotation that embodiment one is proposed;
Figure 12 is the TR component pins-foot-root relation and numbering schematic diagram that embodiment one is proposed;
Wherein, 0 is pin 0, and the coordinate in the corresponding x-axis direction of pin 0 is (x1,x2), the coordinate in the corresponding x-axis direction of pin 1 is (x3,x4);
Border point set is foot or the profile of root;
Figure 13 be embodiment five propose become a full member after upper bound point set and its center schematic diagram;
Figure 14 be embodiment five propose become a full member after lower limits point set and its center schematic diagram;
Figure 15 is the border point set of the proposition of embodiment five according to the affiliated classification results schematic diagram of pin;Wherein, 0,
1,2 be the numbering of pin belonging to boundary point collection correspondence;
Figure 16 is the G that embodiment one is proposed0And G1Illustrate with the accurate minimum enclosed rectangle vertical major position of element
Figure;
Figure 17 is Line_downpin the and Line_uppin schematic diagrames that embodiment one is proposed;
Figure 18 is Line_downfoot the and Line_upfoot schematic diagrames that embodiment one is proposed;
Figure 19 is the TR element vision positioning design sketch that embodiment one is proposed.
Embodiment
Embodiment one:A kind of TR elements positioning of view-based access control model of present embodiment and defect inspection method, tool
Body is prepared according to following steps:
Step 1: checking selected area image (Fig. 1) brightness;Stop checking and returning if image appearance is too light or too dark
Return corresponding error code;If bright spot number and the ratio always counted step 2 is gone to if interval [0.01,0.90];Wherein, it is selected
Pixel value is considered bright spot for 255 pixel in area image, and selected areas image all pixels point number is designated as total points;
When bright spot number with the ratio always counted thinks that area image is too dark less than 0.01, when bright spot number and the ratio always counted are more than 0.90
Then think that area image is too bright;
Step 2: carrying out two in the image of [0.01,0.90] to bright spot number in selected areas image and the ratio always counted
Value, obtains binary image such as Fig. 2 and Fig. 3;Wherein, binary image is obtained including being manually entered fixed threshold binarization method
To binary image and the binary image that is obtained using the maximum method (Otsu methods or Da-Jin algorithm) of inter-class variance;
Step 3: carrying out outside to the binary image (Fig. 3) obtained in step 2 using the maximum method of inter-class variance
The operation that boundary is extracted, obtains the external boundary point set of binary image (Fig. 3), is stored in two-dimensional points container 1;Wherein, external boundary
The extraction operator that the operation of extraction is used is a kind of quick Contour extraction operator in 4 field such as Fig. 4 (advantages:Relative to conventional one
Rank differential operator such as Sobel operators, Prewitt operators etc. operand can be greatly reduced, so that algorithm speed also can be faster),
Wherein, 4 fields quick Contour extraction operator operators is described as follows:
P is pixel to be determined, and the position in its 4 field is respectively P1, P2, P3 and P4;When having in P1, P2, P3 and P4
One be background pixel point when, P is judged as boundary pixel point, otherwise P is not boundary pixel point, with the quick Contour extraction in 4 fields
Binary image Fig. 3 that operator traversal is obtained using the maximum method of inter-class variance just obtains the border of accurate single pixel width
Point set image is the external boundary point set of binary image;
Screened Step 4: the external boundary point set in the two-dimensional points container 1 obtained to step 3 carries out gray value inspection
Border point set afterwards, and the border point set after screening is pressed into a two-dimensional points container 2, it is designated as efficiency frontier point set;
Wherein, described step three China and foreign countries border point set carries out the specific of the border point set after gray value inspection is screened
Process is:
(1) any one external boundary point set that step 3 is obtained is taken, if the points that external boundary point set is included are more than 10, is entered
Row step (2), if the points that border point set is included directly remove this border point set less than or equal to 10;
(2) if the external boundary point set in step (1) has the external boundary point set for including or having nesting, it will include or embedding
Connected region all pixels point pixel value between the external boundary point set of set is set to 255;If the external boundary point set in step (1) does not have
Have and include or nested external boundary point set then border point set will include inside all pixels point pixel value and be set to 255 in addition;
(3) pixel value is drawn in an empty gray level image for 255 pixel, is designated as this external boundary point set
Bianry image;
(4) pixel value is the number of 255 pixel in calculation procedure (3), is designated as s1;It will be manually entered in step 2 solid
The bianry image for determining this external boundary point set of binary image that threshold binarization method obtains with being obtained in step (2) enters
Row step-by-step and computing, obtain a new bianry image, calculate the pixel number that pixel value in new bianry image is 255,
It is designated as s2;
(5) calculate s1/s2 value and s1/s2 values are less than to the border point set corresponding to 0.5 and delete;Repeat (1)~(5) straight
All external boundary point sets are obtained in step 3 to taking, and all external boundary point sets stayed are pressed into a two-dimensional points appearance
In device, that is, obtain effective border point set, such as Fig. 6;
Step (1)~(5) main purpose is that two categories below border point set is handled:One class is step 2 otsu two-values
The excess edge point set that change process threshold value is produced when too low is, it is necessary to remove such border point set;It is another kind of be it is some exist include,
Nest relation border point set is, it is necessary to which whether clearly such border point set is effective;
Step 5: the minimum enclosed rectangle of all efficiency frontier point sets is found, the minimum of all efficiency frontier point sets is outer
Rectangle is connect as rough minimum enclosed rectangle such as Fig. 7 of element, and by the rotation of the minimum enclosed rectangle of all efficiency frontier point sets
Gyration is used as the rough anglec of rotation α of TR elements, the centre coordinate conduct of the minimum enclosed rectangle of all efficiency frontier point sets
Rough centre coordinate (the x of TR elements0,y0);
The method that the minimum enclosed rectangle of all efficiency frontier point sets of described searching is used is the rotation after a kind of optimization
Turn goal method, referred to herein as dual-axis rotation method, (advantage:The method is compared with conventional target rotary process and summit Chain-Code-Method
The affine transformation of required progress greatly reduces, and the angular range of rotation is also substantially reduced, and then speed is also just faster, also more
Accurately;) concretely comprise the following steps:
(1) horizontal spindle of all efficiency frontier point sets is found:Each row i of all efficiency frontier point sets is scanned successively,
Find the starting point coordinate (x of each row efficient boundary point collectioni1,yi1) and terminal point coordinate (xi2,yi2), so as to calculate target in the i-th row
Centre coordinate (x 'i,y′i):
It regard the centre coordinate of each row of all efficiency frontier point sets as one group of data (x 'i,y′i), utilize least square method
Fitting a straight line is carried out, obtains representing the linear equation y=k of the horizontal spindle initial position of all efficiency frontier point sets1x+b1;
Wherein, i=1,2 ..., N;k1For slope, b1For intercept;
(2) vertical major of all efficiency frontier point sets is found:Similarly, each of all efficiency frontier point sets is scanned successively
Row j, finds the starting point coordinate (x of each row bound point setj1,yj1) and terminal point coordinate (xj2,yj2), so as to calculate target in jth row
Centre coordinate (x 'j,y′j):
It regard the centre coordinate of each row of this border point set as one group of data (x 'j,y′j), carried out using least square method straight
Line is fitted, and obtains representing the linear equation x=k of the vertical major initial position of all efficiency frontier point sets2y+b2;
Wherein, j=1,2 ..., M;k2For slope, b2For intercept;
(3) the initial minimum enclosed rectangle of all efficiency frontier point sets, referred to as initial minimum enclosed rectangle are asked for:Keep
The horizontal spindle direction of all efficiency frontier point sets is constant, finds and linear equation y=k1x+b1It is parallel, and and efficient boundary point
Two tangent straight line y=k of collection1x+b11And y=k1x+b12
Take i.e. k ' vertical with the horizontal spindle of efficiency frontier point set1=-1/k1And cross (x0,y0) vertical line y=k '1x+y0-
k′1x0, find vertical line and two tangent straight line y=k ' of efficiency frontier point set1x+b′11With y=k '1x+b′12;
According to four straight line y=k1x+b11, y=k1x+b12, y=k '1x+b′11With y=k '1x+b′12Intersection point just obtain
Four summits of initial minimum enclosed rectangle, initial minimum enclosed rectangle center and initial minimum enclosed rectangle deflection angle information
It can be obtained by this four summits;
Wherein, y=k1x+b11For the coboundary of initial minimum enclosed rectangle;Y=k1x+b12For initial minimum enclosed rectangle
Lower boundary, y=k '1x+b′11For the left margin of initial minimum enclosed rectangle;Y=k '1x+b′12For initial minimum enclosed rectangle
Right margin;
(4) demand perfection body efficiency frontier point set minimum enclosed rectangle:Around the horizontal spindle and entirety of all efficiency frontier point sets
The intersection point rotation of the vertical major of efficiency frontier point set, anglec of rotation interval is taken as:From the level master of all efficiency frontier point sets
Axle initial position starts, and gradually rotated acute angle gamma is overlapped to efficiency frontier point set vertical major initial position, in the anglec of rotation
With △ θ=1 ° it is rotation steps each time in degree is interval, asking for postrotational entirety each time according to the method in step (3) has
Imitate the minimum enclosed rectangle of border point set;And calculate the minimum enclosed rectangle area for all efficiency frontier point sets for rotating the t times
Mt, draw out MtLine chart is observed;T=1,2 ..., [γ];[γ] is γ integer part;
(5) if the area M that step (4) is obtainedtMore than area M1,M2,...,Mt-11.1 times of middle minimum value, or effectively
The position slope rotated to of boundary point collection horizontal spindle is more than or equal to the slope of efficiency frontier point set vertical major;Then reach
End condition, reach end condition terminate after, by the rotation steps in step (4) be changed into △ θ=0.1 ° repeat step (4)~
(5) △ θ≤0.001 °, to the last and untill meeting above end condition;
Step 6: obtaining the centre coordinate (x for each efficiency frontier point set that step 4 is obtainedi,yi), i=1,2 ...,
N, as shown in Figure 8;Wherein, the centre coordinate (x of each efficiency frontier point seti,yi) be specially:
When point (x, y) is on efficiency frontier point set, f (x, y)=1;Otherwise f (x, y)=0;I=1,2 ..., N;N is represented
There is N number of border point set;
Step 7: the efficiency frontier point set that step 4 is obtained is divided into TR member upper efficiency frontier point sets and TR according to α
Two groups of element lower portions efficiency frontier point set, such as Fig. 9;
Step 8: TR member upper efficiency frontiers point set, bottom efficiency frontier point set and step 6 that step 7 is obtained
The center of each obtained efficiency frontier point set carries out affine transformation according to the rough anglec of rotation α of element and become a full member i.e. Fig. 9 turns
Image such as Figure 10 after just, and record the corresponding relation for each front and rear efficiency frontier point set of becoming a full member;Rough center is sat simultaneously
Mark (x0,y0) become a full member as (x '0,y′0);
Step 9: to prevent the TR elements anglec of rotation from, close to 90 degree situation such as Figure 11, being detected to TR component types;
If TR component types are standard TR types, continue step 10;Otherwise, stop and return to corresponding error code;
Step 10: by the TR member upper efficiency frontier point sets and bottom efficiency frontier point set of step 7 according to belonging to pin
Relation classify obtaining the efficiency frontier point set of the first subseries, and the efficiency frontier point set of the first subseries is compiled
Number, the pin numbering mode of numbering as described in Figure 12;
Step 11: the efficiency frontier point set of the first subseries obtained to step 10 carries out the foot and root of same pin
The classification of portion's efficiency frontier point set, determines that the relation of pin-foot-root is as shown in figure 12;And set up three containers, three
The conventional pin efficiency frontier point set of first container storage and conventional pin efficiency frontier point set numbering, second appearance in individual container
The conventional pin foot efficiency frontier point set of device storage and conventional pin foot efficiency frontier point set numbering, the 3rd container storage are special
Different pin efficiency frontier point set and special pin efficiency frontier point set numbering;
Step 12: asking for the center point set of conventional pin efficiency frontier point set in first container in step 11 respectively
With the center point set of conventional pin foot efficiency frontier point set in second container, i.e.,:
The center point set of the conventional pin efficiency frontier point set in top is stored in the conventional pin central point container in top;
The center point set of the conventional pin foot efficiency frontier point set in top is stored in the conventional pin foot central point in top
In container;
The center point set of the conventional pin efficiency frontier point set in bottom is stored in the conventional pin central point container in bottom;
The center point set of the conventional pin foot efficiency frontier point set in bottom is stored in the conventional pin foot central point in bottom
In container;
Step 13: to the center point set and conventional pin foot efficiency frontier point set of conventional pin efficiency frontier point set
Center point set carries out least square fitting linear operating, obtains four straight lines (most four), remembers that TR element lower portions are normal respectively
Advise the conventional pin efficiency frontier point set fitting a straight line of pin efficiency frontier point set fitting a straight line Line_downpin, TR member upper
On Line_uppin, TR element lower portions routine pin foot efficiency frontier point set fitting a straight line Line_downfoot and TR element
Portion routine pin foot efficiency frontier point set fitting a straight line Line_upfoot, Figure 17 are Line_downpin, Line_uppin,
Figure 18 is Line_downfoot, Line_upfoot;
Step 14: the efficiency frontier point set in three containers obtained according to step 11 determines that TR member uppers are effective
Pin average length hpin_up, the effective pin average length h of TR element lower portionspin_down, the effective pin foot of TR member uppers be averaged
Length hfoot_up, the effective pin foot average length h of TR element lower portionsfoot_down, the effective pin number s of TR member upperspin_up
With the effective pin number s of TR element lower portionspin_down;
Step 15: what the efficiency frontier point set and step 13 in three containers obtained according to step 11 were obtained
The top accurate mean breadth w of effective pin foot that four straight lines ask for TR elementsfoot_up, TR elements bottom effective pin essence
True mean breadth wpin_down, TR elements the accurate spacing p of the effective pin in toppin_up, TR elements the effective pin in bottom it is accurate between
Away from ppin_down, TR element true center coordinates (xa,ya), the accurate anglec of rotation α of TR elementsa, TR element strict widths wbodyAnd TR
Element precise length hbody;So far the precise information everywhere of TR elements has been obtained, the vision positioning of TR elements is completed;
Step 16: checking the defect of TR component pins:
(1) check whether TR component pins bend:Each minimum enclosed rectangle obtained in step 5 is rotated
The inspection of angle, the minimum enclosed rectangle anglec of rotation of i-th of pin of note is βi, when | αa-βi| TR component pins are thought when≤5
Normally, do not bend;When | αa-βi|>Think that i-th of pin anglec of rotation is excessive when 5, be bending pin;
(2) check whether TR component pins are symmetrical:Ask for TR member uppers routine pin border point set in step 11
Central point collection center G0, the conventional pin border point set of TR element lower portions central point collection center G1, the special pin edge of TR member uppers
The central point collection center G of boundary's point set2With the center G of the center point set of the special pin border point set of TR element lower portions3;Judge G0、
G1、G2And G3This four points arrived TR element true centers (xa,ya) and parallel to the vertical of the accurate minimum enclosed rectangle of TR elements
The straight line of main shaft such as Figure 16 distance, as distance respectively less than wbodyThink that symmetry meets the requirements, and otherwise returns to symmetry when/20
Undesirable error code;Complete the recognition methods of a kind of TR elements vision positioning and defects detection.
Present embodiment effect:
Present embodiment even more exists while the vision positioning of chip TR elements and defects of vision detection function is realized
The high level of a comparison is reached in the speed of service and repeatable accuracy.Shown according to retest result, present embodiment is to institute
Average out to 20ms the time required to choosing example calculation once, the repeatable accuracy of identical lower 100 retests of external condition also reaches
Into ± 0.001mm, it is seen that a kind of positioning of the TR elements of this view-based access control model and defect inspection method no matter precision, real-time, surely
It is qualitative all very high such as Figure 19.
Embodiment two:Present embodiment from unlike embodiment one:To selected areas in step 2
Bright spot number and the ratio always counted are [0.01,0.90 image carries out binaryzation, obtains binary image implementation method in image
It is specially comprising two kinds:
The first is to be manually entered fixed threshold binarization method, and the pixel point value that will be more than or equal to input threshold value is all fixed
For 255,0 will be set to less than the pixel point value of input threshold value, obtain being manually entered the two-value that fixed threshold binarization method is obtained
Image such as Fig. 2;
Second is the maximum method (Otsu methods or Da-Jin algorithm) of inter-class variance, is obtained using the maximum side of inter-class variance
The bianry image that method is obtained such as Fig. 3;
The method for being manually entered the obtained binary image of fixed threshold binarization method and using inter-class variance maximum is obtained
The binary image arrived.Other steps and parameter are identical with embodiment one.
Embodiment three:Present embodiment from unlike embodiment one or two:Will according to α in step 7
The efficiency frontier point set that step 4 is obtained is divided into TR member upper efficiency frontier point sets and TR element lower portions efficiency frontiers point set two
Group sorting technique be:
(1) if the rough anglec of rotation α of element that step 5 is obtained stops when outside positive and negative 30 degree, and the anglec of rotation is exported
Excessive error code, if α is in the range of positive and negative 30 degree, carries out step (2);
(2) obtain pointing to the unit vector of TR element lower portions efficiency frontier point sets by the rough anglec of rotation α of TR elements
(3) with the rough center (x of TR elements0,y0) it is initial point, point to each the efficiency frontier point set obtained in step 6
Centre coordinate (xi,yi) obtain Vector Groups
By unit vectorWith Vector GroupsIn each vector make dot productWork as s<0 judges corresponding i-th
Efficiency frontier point set is TR member upper efficiency frontier point sets;s>0 judges that corresponding i-th of border point set is that TR element lower portions have
Imitate border point set;S=0 judges that center selection is wrong, stops and returns to corresponding error code.Other steps and parameter and specific reality
Apply mode one or two identical.
Embodiment four:Unlike one of present embodiment and embodiment one to three:It is right in step 9
The method that TR component types are detected is:
(1) all effective edges after asking for each efficient boundary point collection center point set after becoming a full member in step 8 and becoming a full member
The minimum enclosed rectangle of boundary's point set;
(2) the bottom efficient boundary point after asking for the central point of the top efficiency frontier point set after becoming a full member in (1) and becoming a full member
The central point of collection;
(3) with (x '0,y′0) centered on, with 1/8 of minimum enclosed rectangle length in (1) for x-axis direction length value, with (1)
The 1/8 of middle minimum enclosed rectangle width is y directions length value, makees a rectangle, is designated as detecting rectangle;
(4) center of the bottom efficiency frontier point set after checking the central point of (2) middle and upper part efficiency frontier point set and becoming a full member
Whether point is all in the detection rectangle that step (3) is obtained, and if thinking if, normally i.e. TR elements are standard TR types to TR elements, after
Continuous next step;Think that the anglec of rotation is excessive if if not, stop and return to corresponding error code.Other steps and parameter with it is specific
One of embodiment one to three is identical.
Embodiment five:Unlike one of present embodiment and embodiment one to four:It is right in step 10
The side that the TR member upper efficiency frontier point sets and bottom efficiency frontier point set of step 7 are classified according to pin belonging relation
Method is specially:
(1) image is designated as TR member uppers image such as figure after TR member uppers efficiency frontier point set in step 8 is become a full member
13, and image is designated as TR element lower portions image such as Figure 14 after TR element lower portions efficiency frontier point sets are become a full member;
(2) TR member uppers image and TR element lower portions image are scanned along the x-axis direction respectively, are sequentially output TR members
The corresponding x-axis coordinate { xup of pixel that part upper image pixel value is changed1,xup2,…,xupnAnd TR element lower portions images
The corresponding x-axis coordinate { xdown of pixel that pixel value is changed1,xdown2,…,xdownn};
(3) interval in x-axis direction where the x-axis coordinate in step (2) determines pin, so that according to efficient boundary point
The interval of x-axis direction where the x coordinate at collection center determines the corresponding pin of efficient boundary point collection, and efficiency frontier point set is pressed
Mode according to pin numbering in Figure 12 is numbered, sorted efficiency frontier point set such as Figure 15, that is, has obtained the first subseries
Efficiency frontier point set;Wherein, the interval in x-axis direction is [xup where i-th of pin of TR member uppers2i-1,xup2i], TR members
The interval in x-axis direction is [xdown where the pin of i-th of part bottom2i-1,xdown2i].Other steps and parameter and specific implementation
One of mode one to four is identical.
Embodiment six:Unlike one of present embodiment and embodiment one to five:In step 11
The foot of same pin is carried out to the efficiency frontier point set of the subseries of step 10 first and root efficiency frontier point set is classified, it is determined that
The relation specific practice as shown in figure 12 of pin-foot-root is:
(1) there is the efficiency frontier point set of a certain numbering among the efficiency frontier point set for the first subseries that step 10 is obtained
Number be 1 when, then it is assumed that the efficiency frontier point set of this numbering is a special pin efficiency frontier point set, by special pin
Efficiency frontier point set and special pin efficiency frontier point set numbering are stored among the 3rd container;
(3) there is the efficiency frontier point set of a certain numbering among the efficiency frontier point set for the first subseries that step 10 is obtained
Number when being more than 1, then it is assumed that it is a conventional pin that this numbering is corresponding, first carries out the efficiency frontier point set of this numbering
The sequence of area, filters out two maximum efficiency frontier point sets of area;Then two maximum efficiency frontier point sets of area are this
The conventional pin foot efficiency frontier point set of one numbering and the conventional pin root efficiency frontier point set of this numbering, according to same
The conventional pin foot efficient boundary point collection center y-axis coordinate in the top of numbering is less than the conventional pin root efficiency frontier point set in top
Center y-axis coordinate and the foot efficient boundary point collection center y-axis coordinate of lower leg are more than root efficient boundary point collection center y-axis
Coordinate come judge this numbering conventional pin foot border point set and this numbering conventional pin root border point set as scheme
12;Conventional pin foot efficiency frontier point set and conventional pin foot efficiency frontier point set numbering second container of deposit are worked as
In, the conventional pin foot of same numbering and root efficiency frontier point set and this numbering are stored among first container, from
And determine the relation of pin-foot-root.Other steps and parameter are identical with one of embodiment one to five.
Embodiment seven:Unlike one of present embodiment and embodiment one to six:In step 12
Ask for respectively normal in the center point set and second container of conventional pin efficiency frontier point set in first container in step 11
Rule pin foot efficiency frontier point set center point set specific practice be:
(1) each conventional pin foot efficiency frontier point set among second container that step 11 is obtained is asked for
Center;
(2) each conventional pin foot and root efficiency frontier among the first container that step 11 is obtained are asked for
The center of point set;The way of thinking for asking for boundary point collection center is shown in step 6.Other steps and parameter and embodiment one
It is identical to one of six.
Embodiment eight:Unlike one of present embodiment and embodiment one to seven:In step 13
The center point set of center point set and conventional pin foot efficiency frontier point set to conventional pin efficiency frontier point set carries out minimum
Square law fitting a straight line is operated, and wherein least square fitting straight line is specially:
P1,P2,…,PNCentered on point set N number of discrete point, remember i-th of discrete point Pi=(xi,yi), fitting a straight line expression
Formula y=ax+b, utilizes least square method, the quadratic sum of deviationMinimum, that is, solve
By a after arrangement, b separation is obtained
Wherein, center point set is the center point set or conventional pin foot efficient boundary point of conventional pin efficiency frontier point set
The center point set of collection.Other steps and parameter are identical with one of embodiment one to seven.
Embodiment nine:Unlike one of present embodiment and embodiment one to eight:In step 14
Efficiency frontier point set in three containers obtained according to step 11 determines the effective pin average length of TR member uppers
hpin_up, the effective pin average length h of TR element lower portionspin_down, the effective pin foot average length h of TR member uppersfoot_up、
The effective pin foot average length h of TR element lower portionsfoot_down, the effective pin number s of TR member upperspin_upWith TR element lower portions
Effective pin number spin_downSpecific practice is:
(1) each conventional pin efficiency frontier of first container storage is asked for using the dual-axis rotation method in step 5
The minimum enclosed rectangle of the minimum enclosed rectangle of point set and each special pin efficiency frontier point set of the 3rd container storage;
(2) ask for second container using the dual-axis rotation method in step 5 and deposit conventional pin foot efficiency frontier point set
Minimum enclosed rectangle;
(3) top for TR elements of (ignoring the special pin of TR member uppers) if conventional pin is arranged at the top of TR elements is normal
Rule pin is effective pin;If TR elements think there is conventional pin in bottom, (ignoring the special pin of TR element lower portions) TR
The conventional pin of the bottom of element is effective pin;
When TR member uppers only have special pin, then it is assumed that special pin is that the special pin of TR member uppers is effective
Pin;It is the effective pin in bottom that special pin is thought when bottom only special pin;
(4) length value for asking for the minimum enclosed rectangle of the efficiency frontier point set of the effective pin of TR member uppers is averaged
Value, it is determined as hpin_up;Similarly obtain the length value of the minimum enclosed rectangle of the efficiency frontier point set of the effective pin of TR element lower portions
Average value hpin_down;The conventional effectively length value of the minimum enclosed rectangle of the efficiency frontier point set of pin foot of TR member uppers
Average value hfoot_up;The conventional effectively length value of the minimum enclosed rectangle of the efficiency frontier point set of pin foot of TR element lower portions
Average value hfoot_down;The minimum enclosed rectangle number of the efficiency frontier point set of the effective pin of TR member uppers is spin_up;TR members
The minimum enclosed rectangle number of the efficiency frontier point set of the effective pin in part bottom is spin_down.Other steps and parameter and specific reality
Apply one of mode one to eight identical.
Embodiment ten:Unlike one of present embodiment and embodiment one to nine:In step 15
Four straight lines that efficiency frontier point set and step 13 in three containers obtained according to step 11 are obtained ask for TR members
The top accurate mean breadth w of effective pin foot of partfoot_up, TR elements the accurate mean breadth of the effective pin in bottom
wpin_down, TR elements the accurate spacing p of the effective pin in toppin_up, TR elements the accurate spacing p of the effective pin in bottompin_down、
TR element true center coordinates (xa,ya), the accurate anglec of rotation α of TR elementsa, TR element strict widths wbodyIt is accurate with TR elements
Length hbodySpecific practice is as follows:
1) when fitting a straight line Line_downpin and Line_uppin are not present in step 13, with step 14
The average value for calculating the minimum enclosed rectangle width of effective pin of TR member uppers is used as the effective pin foot of TR member uppers
Accurate mean breadth wfoot_up=wpin_up;With the minimum enclosed rectangle for effective pin that TR element lower portions are calculated in step 14
The average value of width is used as the accurate mean breadth w of the effective pin foot of TR element lower portionsfoot_down=wpin_down;wpin_upFor TR members
The accurate mean breadth of the effective pin in part top;wpin_downFor the accurate mean breadth of the effective pin of TR element lower portions;
2) in the presence of fitting a straight line Line_downpin or Line_uppin in step 13, obtain Line_uppin with
The intersection point point set P of TR member uppers routine pin foot border point setup={ (x1,y1),(x2,y2),…,(x2N,y2N) and
Line_downpin and the conventional pin foot border point set of TR element lower portions intersection point point set Pdown={ (x1,y1),(x2,
y2),…,(x2M,y2M)};
(1) makeAs the width of i-th of pin foot of TR member uppers, ask for
All effective pin widths average values of TR member uppers are used as the accurate mean breadth w of the effective pin foot of TR member uppersfoot_up,
The accurate mean breadth w of the effective pin of TR member upperspin_up=wfoot_up;Wherein, i=1,2 ..., N;
(2) makeAs the width of i-th of pin foot of TR element lower portions, ask for
All effective pin widths average values of TR element lower portions are used as the bottom accurate mean breadth w of effective pin footfoot_down, simultaneously
The accurate mean breadth w of the effective pin of TR element lower portionspin_down=wfoot_down;I=1,2 ..., M
(3) makeIt is used as TR members
I-th of part top and the spacing of i+1 pin, ask for dI~i+1Average value is used as the accurate average headway of the effective pin in top
ppin_up;I=1,2 ..., N
OrderIt is used as TR elements
I-th of bottom and the spacing of i+1 pin, ask for dI~i+1Between average value is accurately averaged as the effective pin of TR element lower portions
Away from ppin_down;I=1,2 ..., M;
3) when fitting a straight line Line_downpin and Line_uppin are not present in step 13, i.e. TR member uppers
When there was only special pin with TR element lower portions, it is believed that element central accurate coordinates (xa,ya)=(x0,y0), TR elements accurately rotate
Angle [alpha]aThe strict width w of=α, TR elementbodyEqual to the rough minimum extraneous rectangle width of TR elements in step 5;TR elements
Precise length hbodyEqual to the rough minimum enclosed rectangle length of TR elements in step 5;
4) when fitting a straight line Line_downpin or Line_uppin only exist one in step 13, by this straight line
Slope obtain its anglec of rotation α1, it is believed that the accurate anglec of rotation of TR elementsAnd according to αaDo all effective
The minimum enclosed rectangle of border point set is the Accurate Curve-fitting minimum enclosed rectangle of TR elements, minimum outer with the Accurate Curve-fitting of TR elements
The center for connecing rectangle is the true center (x of TR elementsa,ya), the width using the Accurate Curve-fitting minimum enclosed rectangle of TR elements is TR
The strict width w of elementbody;Using the length of the Accurate Curve-fitting minimum enclosed rectangle of TR elements as the length h of TR elementsbody;
5) when in step 13 fitting a straight line Line_downpin and Line_uppin it is equal in the presence of, by Line_downpin
Slope anglec of rotation α1, by Line_uppin slope anglec of rotation α2, the accurate anglec of rotation of TR elements
According to anglec of rotation αaDo the minimum enclosed rectangle of all efficiency frontier point sets, the minimum of all efficiency frontier point sets
Boundary rectangle is Accurate Curve-fitting minimum enclosed rectangle such as Fig. 5 of TR elements, in the Accurate Curve-fitting minimum enclosed rectangle of TR elements
The heart is the true center (x of elementa,ya),Using the width of the Accurate Curve-fitting minimum enclosed rectangle of TR elements as the accurate width of TR elements
Spend wbody;Using the length of the Accurate Curve-fitting minimum enclosed rectangle of TR elements as the precise length h of TR elementsbody.Other steps and ginseng
Number is identical with one of embodiment one to nine.