A kind of pcb board surface inspecting method based on the overproof algorithm of profile
Technical field
The present invention relates to field of image processings, and in particular to a kind of pcb board Surface testing side based on the overproof algorithm of profile
Method.
Background technique
In the defects detection of the route of the pcb board based on machine vision, mainly takes calculated with behind interception area at present
Connected domain number and area carry out short circuit, and open circuit is damaged, the defect recognition of copper ashes.Not only time-consuming and laborious in this way but also precision is low, it is adopting
Other interference during the image of collection caused by the factors such as mechanical shaking polishing in plan area, connected domain number and face
Product changes, and be easy to cause erroneous detection.
Most detection PCB line defcts are sentenced using the method for the number for calculating connected region in the region of interception at present
Disconnected defect part is short circuit or open circuit, judges copper ashes and damage zone using corresponding position conductive region size is compared
Domain.First interception area size selection actual production detection in can not be accurately held, when detecting between limited feelings
Under condition, there can not be sufficient time accurate interception area, in zoning when number, since line edges gray scale is gradual change
, there can be the total number of tiny area influence area after binarization threshold, and then influence the judgement of defect.
Summary of the invention
In view of the deficiencies of the prior art, the present invention provides a kind of pcb board surface inspecting method based on the overproof algorithm of profile,
To solve technical problem described in background technology.
To achieve the above object, the present invention adopts the following technical scheme:
A kind of pcb board surface inspecting method based on the overproof algorithm of profile, which is characterized in that comprising the following specific steps
S1 obtains PCB bare board Prototype drawing, is cut into the small image of the identical specific dimensions of several sizes, divided
The object that standard picture preferentially be used to be matched;
Acquired image is handled i.e. denoising by S2, the algorithm of automatic threshold segmentation divides bare board copper face to accurate
It cuts out, then binary image, that is, line conductor area gray value is 255, and the gray value of background area is 0, obtains binary map i.e.
Test chart is cut into the small image of test that the identical specific dimensions of several sizes arrive, and the small image of the test being cut into is used for priority match
Prototype drawing;
S3 uses the matched method of shape template to test small image and go to match the corresponding small figure of standard as template and aligns;
Obtained test image and corresponding standard picture are sought edge sub-pixel edge respectively, and seek sub- picture by S4
The ranks coordinate at plain edge, then seeks the normal direction of each coordinate points in edge with specific method;
S5 seeks the edge contour for testing small figure and the small figure of corresponding standard, the standard that will have been aligned in step S3 respectively
Small figure and the corresponding small figure of test are placed under same image coordinate system, with the overproof algorithm of profile i.e. preferentially in test map contour coordinate points
Normal direction on corresponding step-length number to the interior profile point for going for standard drawing.
Further, the specific steps in the step S4 include:
S401 will be obtained testing small image and the small image of corresponding standard sought edge sub-pixel edge respectively, and seeks
The ranks coordinate of sub-pixel edge is stored in array in order by the ranks coordinate sought in the way of migration profile, row
Coordinate and column coordinate, which should correspond to, to be stored in different arrays;
S402, the ranks coordinate that the profile ranks coordinate required by step 4.1 will be acquired in the way of migration profile
Number, such as 1,2,3,4......n, have been connected with the profile coordinate points of number 3 with straight line according to by the profile coordinate points of number 1
Come, number 4 and number 6 are connected with straight line, and connection is gone down in this manner, if finally there are remaining coordinate points, no
By remaining how many be all that n-th of coordinate points is connected with straight line with the n-th -2 coordinate points, and seek being connected this
The slope of a little line segments, and then seek these line segment normal angles;The range of normal angles is [- π, π], by obtained normal angle
Degree is numbered in order according to as the direction for seeking ranks coordinate migration profile;Such as 3,6,9.......3m, n;
S403 answers normal angles striked in step 402 according to the sequence and corresponding profile point coordinate pair of number
Get up, the normal angles as numbered the profile point for being 1,2,3 are the normal angles that normal angles number is No. 3, number 4,5,6
Profile point normal angles be normal angles number be No. 6 normal angles, successively go in this way;Each profile coordinate
Point has the normal angles corresponding to oneself.
Further, the specific steps in the step S5 include:
S501 seeks the edge contour for testing small figure and the small figure of corresponding standard, the mark that will have been aligned in step S3 respectively
Quasi- small figure and the corresponding small figure of test are placed under same image coordinate system;
S502, according to the profile point and corresponding normal angles for preferentially seeking testing small figure in step S402 according to test
The sequence of small map contour migration seek profile point number be 1 coordinate point forward normal direction step-length be 0 coordinate points coordinate and this
Gray value in a coordinate points looks for the gray value of 8 neighborhoods of this coordinate points if gray scale is 0;If in this coordinate points
Gray value be 255, then have found the profile point on the small figure of template and find out their distance D0, if distance D0 be less than regulation
Normal distance value Dmix when, then this profile point tested on small figure is not defect point;If the coordinate that profile point number is 1
The gray value of 8 neighborhoods of the coordinate points that point forward normal direction step-length is 0 is all 0, then continues to find toward in next step-length;If surveyed
Try 8 neighborhoods of the coordinate points that coordinate point forward normal direction step-length that small map contour point number is 1 is 0 gray value it is promising 255 when, say
Then the bright profile point for having found the small figure of the template aligned finds out the coordinate points and test for testing that small map contour point number is 1
The gray value of 8 neighborhoods of the coordinate points that the coordinate point forward normal direction step-length that small map contour point number is 1 is 0 be 255 coordinates away from
From D1, D2......;If their minimum range is greater than defined normal distance value Dmix, then this on small figure is tested
A profile point is defect point, otherwise is not defect point;If the profile point i.e. gray value for having found the small figure of corresponding templates is 255
Point does not just continually look in the step-length of normal direction;It is then continually looked in the step-length of normal direction conversely, not finding defect point;
S503, if there are no find on pixel and its within 8 neighborhoods within the step-length number of defined positive normal direction
It is anti-that the coordinate points that gray value is 255 then number the coordinate points for being 1 in the small map contour point of test according to the method and step of step S502
The profile point that Prototype drawing is found within to normal direction step-length number, no longer finds in normal direction, such as if the profile point for finding Prototype drawing
Their distance of fruit is greater than defined distance, then this profile point tested on small figure is defect point;If defined reversed
Small figure is then tested there are no the coordinate points that find gray value be 255 on pixel and its within 8 neighborhoods within the step-length number of normal direction
On this profile point be defect point;
S504 is looked for according to the method and step of step S502 and step S503 along the direction for testing small map contour migration
Profile point number is the profile point on the outlines points such as 2,3,4.......n on the small image of template of normal orientation, if corresponding
When testing the distance of small image outline point and the small image outline point of template greater than defined normal distance value Dmix, then small figure is tested
On this profile point be defect point, otherwise not be defect point;If all do not had in the test positive and negative normal direction of small image outline point
Find the small image outline point of point i.e. template that pixel value is 255;At this point, testing small image outline point (sub-pixel) also is defect
Point;
S505 looks for profile point if the pixel value for testing small image is all 0 or 255 in normal direction in turn
It is walked i.e. in the normal direction in the profile point of the small image of template according to the method for step S502 and step S503 and step S504
The profile point of the corresponding small image of test is looked under rapid and then finds the defect point tested on small image;
S506, bare board or big defect if it is big copper face find defect point in normal orientation along profile dot interlace;If it is
The bare board of small copper face or small defect then find defect point in normal orientation point by point along profile;
S507, if looking on pcb board if the big defect of copper face the defined normal distance value in the normal orientation of profile point
Dmix wants setting appropriate larger, and normal direction step-length number is also appropriate to want larger;It is on the contrary then opposite.
Further, if having found test in the defined step-length number of the normal orientation for the profile point for testing small image
Profile point on small image and distance is greater than type of the defined maximum Dmax apart from the defect point then looked for and is between them
The defects of copper face is damaged, and copper face welds more, copper ashes;If on the both forward and reverse directions of the normal orientation for the profile point for testing small image
The type for the defect point that the profile point on the small image of template is then looked for all is not had found in defined step-length number and its in 8 neighborhoods
For copper face open circuit;In defined step-length number on the both forward and reverse directions in the normal direction in the profile point of the small image of template and its
The type that the defect point that the profile point tested on small image is then looked for all is not had found in 8 neighborhoods is the defects of copper face is short-circuit.
A kind of beneficial effect of pcb board surface inspecting method based on the overproof algorithm of profile provided by the invention is:
(1) present invention is according to the PCB image of acquisition, and on the basis of consideration machine error, optical aberrations etc., automatic aligning is pre-
The pcb board image and standard form image of processing obtain short circuit, open circuit, damaged, copper with the overproof algorithm operation of profile in turn
The defects of slag;
(2) defect on pcb board can be looked on 360 degree of directions of pcb board copper face profile using the overproof algorithm of this profile,
And the not limitation of chamfered shape, and open circuit, short circuit, breakage, copper face scuffing, copper ashes etc. can be found on pcb board almost
All pcb board defects;Moreover, the not limitation of defect size;This method is combined than traditional using image opening and closing operation
Method scheduling algorithm look for the method for pcb board defect more accurate, the precision for finding defect has reached pixel scale, and applicable surface is more
Extensively, defect type on nearly all pcb board can be found out.
Detailed description of the invention
Fig. 1 is flow diagram of the present invention;
Fig. 2 is the template image of Gerber file generated of the present invention;
Fig. 3 is the present invention in the display normal direction tested on small image;
Fig. 4 is the present invention in the defect point found tested on small image.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Whole description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Ability
Domain ordinary person every other embodiment obtained without making creative work, belongs to protection of the invention
Range.
A kind of embodiment: pcb board surface inspecting method based on the overproof algorithm of profile.
Pcb file is converted Gerber file by S1, then, is gone out Gerber document analysis using GerbMagic software
To be converted into BMP format-pattern;In this way, the bianry image i.e. standard picture of pcb bare board standard circuit has just been obtained, then by it
It is cut into the small image of the identical specific dimensions of several sizes, divided standard picture is preferentially used to the object being matched;
Acquired image is handled i.e. denoising by S2, the algorithm of automatic threshold segmentation divides bare board copper face to accurate
It cuts out, then binary image, that is, line conductor area gray value is 255, and the gray value of background area is 0, obtains binary map i.e.
Test chart is cut into the small image of test that the identical specific dimensions of several sizes arrive, and the small image of the test being cut into is used for priority match
Prototype drawing;
S3 uses the matched method of shape template to test small image and go to match the corresponding small figure of standard as template and aligns;
Obtained test image and corresponding standard picture are sought edge sub-pixel edge respectively, and seek sub- picture by S4
The ranks coordinate at plain edge, then seeks the normal direction of each coordinate points in edge with specific method;
S5 seeks the edge contour for testing small figure and the small figure of corresponding standard, the standard that will have been aligned in step S3 respectively
Small figure and the corresponding small figure of test are placed under same image coordinate system, with the overproof algorithm of profile i.e. preferentially in test map contour coordinate points
Normal direction on corresponding step-length number to the interior profile point for going for standard drawing.
Further, the specific steps in the step S4 include:
S401 will be obtained testing small image and the small image of corresponding standard sought edge sub-pixel edge respectively, and seeks
The ranks coordinate of sub-pixel edge is stored in array in order by the ranks coordinate sought in the way of migration profile, row
Coordinate and column coordinate, which should correspond to, to be stored in different arrays;
S402, the ranks coordinate that the profile ranks coordinate required by step 4.1 will be acquired in the way of migration profile
Number, such as 1,2,3,4......n, have been connected with the profile coordinate points of number 3 with straight line according to by the profile coordinate points of number 1
Come, number 4 and number 6 are connected with straight line, and connection is gone down in this manner, if finally there are remaining coordinate points, no
By remaining how many be all that n-th of coordinate points is connected with straight line with the n-th -2 coordinate points, and seek being connected this
The slope of a little line segments, and then seek these line segment normal angles;The range of normal angles is [- π, π], by obtained normal angle
Degree is numbered in order according to as the direction for seeking ranks coordinate migration profile;Such as 3,6,9.......3m, n;
S403 answers normal angles striked in step 402 according to the sequence and corresponding profile point coordinate pair of number
Get up, the normal angles as numbered the profile point for being 1,2,3 are the normal angles that normal angles number is No. 3, number 4,5,6
Profile point normal angles be normal angles number be No. 6 normal angles, successively go in this way;Each profile coordinate
Point has the normal angles corresponding to oneself.
Further, the specific steps in the step S5 include:
S501 seeks the edge contour for testing small figure and the small figure of corresponding standard, the mark that will have been aligned in step S3 respectively
Quasi- small figure and the corresponding small figure of test are placed under same image coordinate system;
S502, according to the profile point and corresponding normal angles for preferentially seeking testing small figure in step S402 according to test
The sequence of small map contour migration seek profile point number be 1 coordinate point forward normal direction step-length be 0 coordinate points coordinate and this
Gray value in a coordinate points looks for the gray value of 8 neighborhoods of this coordinate points if gray scale is 0;If in this coordinate points
Gray value be 255, then have found the profile point on the small figure of template and find out their distance D0, if distance D0 be less than regulation
Normal distance value Dmix when, then this profile point tested on small figure is not defect point;If the coordinate that profile point number is 1
The gray value of 8 neighborhoods of the coordinate points that point forward normal direction step-length is 0 is all 0, then continues to find toward in next step-length;If surveyed
Try 8 neighborhoods of the coordinate points that coordinate point forward normal direction step-length that small map contour point number is 1 is 0 gray value it is promising 255 when, say
Then the bright profile point for having found the small figure of the template aligned finds out the coordinate points and test for testing that small map contour point number is 1
The gray value of 8 neighborhoods of the coordinate points that the coordinate point forward normal direction step-length that small map contour point number is 1 is 0 be 255 coordinates away from
From D1, D2......;If their minimum range is greater than defined normal distance value Dmix, then this on small figure is tested
A profile point is defect point, otherwise is not defect point;If the profile point i.e. gray value for having found the small figure of corresponding templates is 255
Point does not just continually look in the step-length of normal direction;It is then continually looked in the step-length of normal direction conversely, not finding defect point;
S503, if there are no find on pixel and its within 8 neighborhoods within the step-length number of defined positive normal direction
It is anti-that the coordinate points that gray value is 255 then number the coordinate points for being 1 in the small map contour point of test according to the method and step of step S502
The profile point that Prototype drawing is found within to normal direction step-length number, no longer finds in normal direction, such as if the profile point for finding Prototype drawing
Their distance of fruit is greater than defined distance, then this profile point tested on small figure is defect point;If defined reversed
Small figure is then tested there are no the coordinate points that find gray value be 255 on pixel and its within 8 neighborhoods within the step-length number of normal direction
On this profile point be defect point;
S504 is looked for according to the method and step of step S502 and step S503 along the direction for testing small map contour migration
Profile point number is the outline point on the outlines points such as 2,3,4.......n on the small image of template of normal orientation, if corresponding
When testing the distance of small image outline point and the small image outline point of template greater than defined normal distance value Dmix, then small figure is tested
On this profile point be defect point, otherwise not be defect point;If all do not had in the test positive and negative normal direction of small image outline point
Find the small image outline point of point i.e. template that pixel value is 255;At this point, testing small image outline point (sub-pixel) also is defect
Point;
S505 looks for profile point if the pixel value for testing small image is all 0 or 255 in normal direction in turn
It is walked i.e. in the normal direction in the profile point of the small image of template according to the method for step S502 and step S503 and step S504
The profile point of the corresponding small image of test is looked under rapid and then finds the defect point tested on small image;
S506, bare board or big defect if it is big copper face find defect point in normal orientation along profile dot interlace;If it is
The bare board of small copper face or small defect then find defect point in normal orientation point by point along profile;
S507, if looking on pcb board if the big defect of copper face the defined normal distance value in the normal orientation of profile point
Dmix wants setting appropriate larger, and normal direction step-length number is also appropriate to want larger;It is on the contrary then opposite.
Further, if having found test in the defined step-length number of the normal orientation for the profile point for testing small image
Profile point on small image and distance is greater than type of the defined maximum Dmax apart from the defect point then looked for and is between them
The defects of copper face is damaged, and copper face welds more, copper ashes;If on the both forward and reverse directions of the normal orientation for the profile point for testing small image
The type for the defect point that the profile point on the small image of template is then looked for all is not had found in defined step-length number and its in 8 neighborhoods
For copper face open circuit;In defined step-length number on the both forward and reverse directions in the normal direction in the profile point of the small image of template and its
The type that the defect point that the profile point tested on small image is then looked for all is not had found in 8 neighborhoods is the defects of copper face is short-circuit.
The above is presently preferred embodiments of the present invention, but the present invention should not be limited to embodiment and attached drawing institute public affairs
The content opened both falls within protection of the present invention so all do not depart from the lower equivalent or modification completed of spirit disclosed in this invention
Range.