Summary of the invention
In view of this, the invention provides a kind of pcb board detection method, Apparatus and system, existing manual detection mode efficiency is low, loss is high, subjectivity is strong in order to solve, pcb board detects the problem of external interference of being subject to, its technical scheme is as follows:
A kind of pcb board detection method, comprising:
Obtain the PCB image of pcb board to be detected;
Alignment pre-service is carried out to described PCB image;
Pretreated PCB image is mated with the standard form be pre-created, when the match conditions are met, determines the region to be detected of described pretreated PCB image;
Extract the feature of components and parts in described region to be detected;
Utilize the support vector machines that training in advance is good to carry out Classification and Identification to the feature of described components and parts, judge whether described region to be detected exists appointment components and parts by Classification and Identification result.
Preferably, describedly alignment pre-service carried out to described PCB image comprise:
Background difference is utilized to obtain pcb board object described PCB image and the background image constructed in advance;
Described pcb board object binaryzation is obtained foreground object, and Morphological scale-space is carried out to described foreground object;
From the foreground object after carrying out Morphological scale-space, determine edge pixel, and utilize hough transform in conjunction with described edge pixel determination straight line;
Obtain described direct slope, and according to the slope image rotating of described straight line.
Preferably, pretreated PCB image is mated with described standard form, when the match conditions are met, determines that the region to be detected of described pretreated PCB image is specially:
Sequential similarity detection algorithm SSDA is utilized to determine the region to be detected of described pretreated PCB image.
Preferably, the components and parts feature extracting described region to be detected comprises:
Extract the color characteristic of the components and parts in described region to be detected, shape facility and textural characteristics.
Preferably, the shape facility of the components and parts in the described region to be detected of described extraction is specially:
8-neighborhood track algorithm is adopted to extract the profile of components and parts.
Preferably, the textural characteristics of the components and parts in the described region to be detected of described extraction is specially:
Gradation of image and gradient information are combined, from Gray Level-Gradient Co-occurrence Matrix, extracts the textural characteristics of components and parts.
A kind of pcb board pick-up unit, comprising: acquiring unit, pretreatment unit, matching unit, determining unit, extraction unit, taxon and identifying unit;
Described acquiring unit, for obtaining the PCB image of pcb board to be detected;
Described pretreatment unit, carries out alignment pre-service for the PCB image obtained described acquiring unit;
Described matching unit, mates with the standard form be pre-created for described pretreatment unit is carried out pretreated PCB image;
Described determining unit, for when the match conditions are met, determines the region to be detected of described pretreated PCB image;
Described extraction unit, for extracting the feature of components and parts in region to be detected that described determining unit determines;
Described taxon, for utilizing the good support vector machines of training in advance to carry out Classification and Identification to the feature of the components and parts that described extraction unit extracts, obtains Classification and Identification result;
By the Classification and Identification result of described taxon, described identifying unit, for judging whether described region to be detected exists appointment components and parts.
Preferably, described pretreatment unit comprises: first obtain subelement, the first image procossing subelement, determine subelement, second obtain subelement and the second image procossing subelement;
Described first obtains subelement, for utilizing Background difference to obtain described pcb board object described PCB image and the background image constructed in advance;
Described first image procossing subelement, carries out binaryzation for the pcb board object obtaining subelement acquisition to described first, obtains foreground object, carry out Morphological scale-space to described foreground object;
Describedly determining subelement, for determining edge pixel from the foreground object after described first image procossing subelement process, and utilizing hough transform in conjunction with described edge pixel determination straight line;
Described second obtains subelement, for obtaining the described direct slope that subelement is determined of determining;
Described second image procossing subelement, for obtaining the slope image rotating of the straight line that subelement obtains according to described second.
A kind of pcb board detection system, comprises above-mentioned pcb board pick-up unit.
Pcb board detection method provided by the invention, Apparatus and system, by the PCB image through the pretreated pcb board of alignment is mated with the standard form be pre-created, determine region to be detected, then the feature of components and parts in region to be detected is extracted, utilize the support vector machines that training in advance is good to carry out Classification and Identification to the feature of components and parts, judge whether region to be detected exists appointment components and parts by Classification and Identification result.Pcb board detection method provided by the invention, Apparatus and system can all position surveyed area, and can judge whether region to be detected exists appointment components and parts.Pcb board detection method provided by the invention, Apparatus and system realize simply, detection efficiency is high, false drop rate is low, solve the problem that traditional manual detection mode efficiency is low, loss is high, subjectivity is strong, pcb board detection is subject to external interference.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment one
The embodiment of the present invention one provides a kind of PCB detection method, and Fig. 1 is the schematic flow sheet of the method, and the method comprises:
S100: the PCB image obtaining pcb board to be detected.
S101: alignment pre-service is carried out to the PCB image obtained.
S102: pretreated PCB image mated with the standard form be pre-created, when the match conditions are met, determines the region to be detected of pretreated PCB image.
S103: the feature extracting components and parts in region to be detected.
S104: utilize the support vector machines that training in advance is good to carry out Classification and Identification to the feature of described components and parts, judge whether region to be detected exists appointment components and parts by Classification and Identification result.
The pcb board detection method that the embodiment of the present invention one provides, can all position surveyed area, and can judge whether region to be detected exists appointment components and parts.Detection method provided by the invention realizes simply, detection efficiency is high, false drop rate is low, solves the problem that traditional manual detection mode efficiency is low, loss is high, subjectivity is strong, pcb board detection is subject to external interference.
Embodiment two
Embodiments provide a kind of pcb board detection method, Fig. 2 is the schematic flow sheet of the method, and the method can comprise:
S200: the PCB image obtaining pcb board to be detected.
S201: alignment pre-service is carried out to PCB image.
When taking the PCB image of pcb board, because a variety of causes causes the pcb board taken all can there is certain inclination on image, sometimes angle of inclination may also can be larger, and the alignment pre-service of image is exactly make the edge of pcb board be in plumbness or horizontality as far as possible, namely consistent with the sample states of standard form.
In the present embodiment, step S201 can comprise:
S201a: utilize Background difference to obtain pcb board object PCB image and the background image constructed in advance.
Wherein, background image can construct in the following manner: in the position for placing pcb board, and shooting 10 images, then to 10 image averagings of shooting, obtain background image continuously.PCB image is poor in gray scale with the background image constructed by the way, pcb board object can be tried to achieve.
S201b: pcb board object binaryzation is obtained foreground object, and Morphological scale-space is carried out to foreground object.
Piece image generally includes: foreground object, background and noise, in the present embodiment, extracting foreground object by image being carried out binary conversion treatment, being specially: a threshold value T is set, the data of image are divided into the pixel group being greater than T and the pixel group being less than T, in the present embodiment, T=100 is set.After image binaryzation, foreground object extracts, but due to the impact of noise, dust etc., foreground object also exists a lot of flaw point, and Morphological scale-space is exactly to address this problem.The fundamental operation of bianry image Morphological scale-space has burn into expansion, opening operation, closed operation, hit with do not hit, skeletal extraction etc.
Corrosion is the most basic a kind of morphology operations, and object boundary point is eliminated in its effect, makes the process that border is internally shunk, can the object removal being less than structural element.Choose the structural element of different size like this, just can remove the object of different size.
The effect of expanding is just contrary with corrosion, and it expands binaryzation object boundary point, is merged in this object by all background dots with object contact, makes the process that border is externally expanded.If the distance between two objects is closer, then dilation operation may be communicated to together two objects, and expanding has effect very much to the cavity in object after filling up Iamge Segmentation.
Two-value morphological dilation can be converted into the logical operation of set with corrosion, and algorithm is simple, is suitable for parallel processing, and is easy to hardware implementing, be suitable for carrying out Iamge Segmentation, refinement, extraction skeleton, edge extracting, shape analysis to bianry image.
In the present embodiment, adopt the structure of 3 × 3, carry out twice expansion of twice burn into, realize the process to binaryzation pcb board object.
S201c: the prospect after carrying out Morphological scale-space determines edge pixel to picture, and utilize hough transform jointing edge pixel determination straight line.
In the present embodiment, consider the linear characteristic at pcb board edge, utilize this feature to realize image alignment pre-service.
S201d: obtain direct slope, and the slope image rotating of foundation straight line.
S202: pretreated PCB image is mated with the standard form be pre-created.
S203: judge whether Satisfying Matching Conditions, if so, then performs step S104 and subsequent step, otherwise, perform step S209.
S204: the region to be detected determining pretreated PCB image.
In the present embodiment, sequential similarity detection algorithm (Similarity SequentialDetection Algorithm can be passed through, SSDA) pretreated PCB image is mated with the standard form be pre-created, namely the location for the treatment of surveyed area is realized by SSDA, concrete: at the random unduplicated select progressively picture dot in each position through the pretreated image of alignment, the difference of pretreated image on this picture dot and accumulated standard template is alignd with process, setting threshold value is greater than if accumulative, then illustrate that this position is non-matching position, stop this computing, carry out the test of next position, until find best match position, best match position is region to be detected.
Introduce the ultimate principle of SSDA below:
SSDA sets the computing method of threshold value T according to the algorithm of adopted coupling related operation, when carrying out the coupling related operation of each search window, in the rational counting period, detects the correlated results of current gained and the comparison of SSDA threshold value T.
SSDA ∫ ∫ | f-t|dxdy is as coupling yardstick, and the non-similarity m (u, v) of the point (u, v) in image f (x, y) calculates with following formula:
Wherein, point (u, v) represents the upper left position of standard form.
If there is the pattern consistent with standard form at (u, v) place, then m (u, v) value is very little, and on the contrary, m (u, v) is then very large.Time particularly standard form and image are completely inconsistent, if each pixel in standard form increased down successively with the absolute value of the gray scale difference of image, itself and will sharply increase.Therefore, in the process making addition, if the part of gray scale difference has exceeded a certain setting threshold value, just thought that pattern consistent with standard form on this position does not exist, thus transferred to the calculating that m (u, v) is carried out in next position.Be all plus and minus calculation owing to comprising m (u, v) in interior calculating, and the most midway of this computing stops, and therefore significantly can shorten match time.In actual applications, in order to stop calculating, the position of Stochastic choice pixel the calculating of gray scale difference can be carried out.SSDA algorithmic procedure is as follows:
(1) absolute error is defined:
Wherein,
(2) a constant threshold value T is got
k.
(3) at subgraph S
i, jobject-point is chosen immediately in (m, n).Calculate its error amount with corresponding point in T, then difference of this error and other point added up, when cumulative r time more than T
k, then stop cumulative, and write down number of times r, the detection curved surface of definition SSDA is:
(4) using point large for I (i, j) value as match point total error just can be made more than T because this aspect needs to add up many times
k, the general candidate point needed is all on such point.
Counting yield can also be improved further to SSDA.Order of selecting for N-M+1 reference point can not advance in pointwise, namely standard form not necessarily every bit all move to, thick-thin uniform search's method combined can be adopted, namely first each M point search mates quality once, then asks coupling to each reference point having in the maximal matching subrange enclosed on weekly duty.Can not this strategy lose real match point, will depend on flatness and the unimodality of surperficial I (i, j).
At certain reference point (i, j) place, the M under standard form is covered
2the random fashion error of calculation that computation sequence can be used and i and j is irrelevant that individual point is right, also the mode adapting to picture material can be adopted, choose pseudo-random sequence by prominent feature in standard form, determine the sequencing of the error of calculation, to abandon those non-matching points early.
In the present embodiment, consider the complicacy of the diversity of PCB components and parts, components and parts texture, adopt the mode of pointwise coupling to search for most probable region to be detected.For threshold value T
k, each template is calculated by following formula:
S205: the feature extracting components and parts in region to be detected.Wherein, the feature of components and parts can comprise: the color characteristic of components and parts, shape facility and textural characteristics.
S206: utilize the support vector machines that training in advance is good to carry out Classification and Identification to the feature of components and parts, obtain Classification and Identification result.
In the present embodiment, need to choose sample training support vector machines in advance to realize the Classification and Identification of components and parts, need the components and parts detected to choose 25 width pictures to each.In order to improve the generalization ability of SVM, introduce as down conversion when Geometry rectification: (1) longitudinal stretching 1.1 times; (2) horizontal stretch 1.1 times; (3) yardstick amplifies 1.1 times; (4) yardstick is reduced into 95% of former figure; (5) left rotation and right rotation 5 degree.Through the combination of above-mentioned conversion, each components and parts picture can produce 48 different original samples, total 1200, sample, and after they carry out histogram equalization, random selecting 500 sample needs the sample of the components and parts detected as often kind.
After having chosen sample, need the feature from sample extraction components and parts, in the present embodiment, the feature extracting components and parts comprises: extract color characteristic, shape facility and textural characteristics.
Color distribution information spinner will concentrate in low order color moment, as first moment average color is described, that second moment describes color variance, third moment describes color is offset resistance, therefore, utilizes low-order moment just can the feature of approximate representation color distribution.Color moment is defined as respectively:
Wherein, M
1, M
2and M
3one, two, three rank color moments respectively, q
i, jthe color of expression pixel j is the probability of i, and N is the number of pixels in image.In RGB color space, each Color Channel differentiates three color moments, altogether forms the color feature vector of one 9 dimension, is expressed as F
color=[M
r1, M
r2, M
r3, M
g1, M
g2, M
g3, M
b1, M
b2, M
b3].
There is significant difference in different components and parts, in order to identify components and parts shape, adopts 8-neighborhood track algorithm to extract its profile in shape.Utilize area S, the girth P of profile acquisition components and parts, the long L of minimum external square and minimum external square wide W4 absolute value feature, calculate shape complexity S1=4 π S/P2, breadth length ratio S2=W/L, dispersion S3=P2/A, circularity S4=4 π S/L2 more respectively accordingly.4 dimension shape eigenvectors of components and parts can be expressed as F
shape=[S
1, S
2, S
3, S
4].
In order to be subject to the impact of image rotation when solving gray level co-occurrence matrixes statistical method texture feature extraction, the present embodiment synthetic image gray scale and gradient information, extract the textural characteristics of components and parts from Gray Level-Gradient Co-occurrence Matrix.If former gray level image is f (x, y), wherein, x=1,2 ... M, y=1,2 ... N, its gray level is L.Extract the gradient image g (x, y) of f (x, y) by gradient operator, its gray level is L
g, gradient image is carried out gray level discretize, and the gradient image after conversion is:
Definition set (x, y) | in f (x, y)=i, G (x, y)=j}, the number of element is
H
ij(i=0,1 ..., L-1; J=0,1 ..., L
g-1), to H
ijbe normalized, obtain:
By P
ijform Gray Level-Gradient Co-occurrence Matrix
, therefrom can extract 15 image texture characteristics, select 4 characteristic features the most effective: energy T1, correlativity T2, inertia T3 and entropy T4.Wherein, T1-T4 is calculated by following formula respectively:
Wherein, T
hfor gray average, T
tfor gradient mean value.Like this, 4 Balakrishnan Li Tezheng of image can be obtained, be expressed as F
texture=[T
1, T
2, T
3, T
4].
By the analysis to components and parts color, grey-level and shape-gradient co-occurrence matrix, altogether extraction obtains 17 dimensional features, is used for this proper vector carrying out training and the identification of SVM.
In the present embodiment, the feature extracting components and parts in region to be detected can adopt aforesaid way to extract.
Because existing SVM is a kind of typical binary classifier, namely it only solves the problem belonging to positive sample or negative sample, meeting difficulty when solving typical many classification problems such as circuit board defect, in order to solve this problem, in the present embodiment, utilizing multistage SVM to solve many classification problems.First design first order SVM, the normal or defective detection of this grade of SVM main realizing circuit plate, if testing result is normal, does not then need subsequent detection; If first order SVM detects that circuit board has problem, then design second level SVM, complete the classification of the first main components defect and other classification components and parts defect; By that analogy, until n-th grade of svm classifier goes out n class components and parts defect.Every one-level SVM finds out corresponding support vector after training, sets up its optimal separating hyper plane.Because said n level SVM performs according to the height of priority, search for from high to low according to binary tree when specific implementation, just can draw net result, its workflow diagram as shown in Figure 3.
S207: judge whether region to be detected exists appointment components and parts by recognition result, if so, then performs step S208, otherwise, perform step S209.
S208: judge that region to be detected exists and specify components and parts.
S209: judge that region to be detected does not exist appointment components and parts.
The pcb board detection method that the embodiment of the present invention two provides, can treat surveyed area and position, and can judge whether region to be detected exists appointment components and parts.Detection method provided by the invention realizes simply, detection efficiency is high, false drop rate is low, solves the problem that traditional manual detection mode efficiency is low, loss is high, subjectivity is strong, pcb board detection is subject to external interference.
Embodiment three
The embodiment of the present invention three provides a kind of pcb board pick-up unit, Fig. 4 is the structural representation of this device, and this device comprises: acquiring unit 100, pretreatment unit 101, matching unit 102, determining unit 103, extraction unit 104, taxon 105 and identifying unit 106.Wherein:
Acquiring unit 100, for obtaining the PCB image of pcb board to be detected.Pretreatment unit 101, carries out alignment pre-service for the PCB image obtained acquiring unit 100.Matching unit 102, mates with the standard form be pre-created for pretreatment unit 101 is carried out pretreated PCB image.Determining unit 103, for when the match conditions are met, determines the region to be detected of pretreated PCB image.Extraction unit 104, for extracting the feature of the components and parts in region to be detected that determining unit 103 determines.Taxon 105, carries out Classification and Identification for utilizing the feature of support vector machines to the components and parts that extraction unit 104 extracts that training in advance is good.By the Classification and Identification result of taxon 105, identifying unit 106, for judging whether region to be detected exists appointment components and parts.
Further, pretreatment unit 101 comprises: first obtain subelement, the first image procossing subelement, determine subelement, second obtain subelement and the second image procossing subelement.Wherein:
First obtains subelement, for utilizing Background difference to obtain the foreground image of PCB image PCB image and the background image constructed in advance.First image procossing subelement, for obtaining the foreground image binaryzation of the PCB image that subelement obtains by first, and carries out Morphological scale-space to the foreground image after binaryzation.Determining subelement, for determining edge pixel from the foreground image after the first image procossing subelement process, and utilizing hough transform jointing edge pixel determination straight line.Second obtains subelement, for obtaining the direct slope determining that subelement is determined.Second image procossing subelement, for obtaining the slope image rotating of the straight line that subelement obtains according to second.
The pcb board pick-up unit that the embodiment of the present invention two provides, can treat surveyed area and position, and can judge whether region to be detected exists appointment components and parts.Pcb board pick-up unit provided by the invention realizes simply, detection efficiency is high, false drop rate is low, solves the problem that traditional manual detection mode efficiency is low, loss is high, subjectivity is strong, pcb board detection is subject to external interference.
Embodiment four
The embodiment of the present invention four provides a kind of pcb board detection system, and this system comprises pcb board pick-up unit, the pcb board pick-up unit that this pcb board pick-up unit can provide for embodiment three.
The pcb board detection system that the embodiment of the present invention four provides, can treat surveyed area and position, and can judge whether region to be detected exists appointment components and parts.Pcb board detection system provided by the invention realizes simply, detection efficiency is high, false drop rate is low, solves the problem that traditional manual detection mode efficiency is low, loss is high, subjectivity is strong, pcb board detection is subject to external interference.
For convenience of description, various unit is divided into describe respectively with function when describing above device.Certainly, the function of each unit can be realized in same or multiple software and/or hardware when implementing of the present invention.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add required general hardware platform by software and realizes.Based on such understanding, technical scheme of the present invention can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product can be stored in storage medium, as ROM/RAM, magnetic disc, CD etc., comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) perform the method described in some part of each embodiment of the present invention or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, between each embodiment identical similar part mutually see, what each embodiment stressed is the difference with other embodiments.Especially, for system embodiment, because it is substantially similar to embodiment of the method, so describe fairly simple, relevant part illustrates see the part of embodiment of the method.System embodiment described above is only schematic, the wherein said unit illustrated as separating component or can may not be and physically separates, parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of module wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.Those of ordinary skill in the art, when not paying creative work, are namely appreciated that and implement.
The present invention can be used in numerous general or special purpose computing system environment or configuration.Such as: personal computer, server computer, handheld device or portable set, laptop device, multicomputer system, system, set top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, the distributed computing environment comprising above any system or equipment etc. based on microprocessor.
The present invention can describe in the general context of computer executable instructions, such as program module.Usually, program module comprises the routine, program, object, assembly, data structure etc. that perform particular task or realize particular abstract data type.Also can put into practice the present invention in a distributed computing environment, in these distributed computing environment, be executed the task by the remote processing devices be connected by communication network.In a distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium comprising memory device.
It should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.
The above is only the specific embodiment of the present invention; it should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.