Disclosure of Invention
In view of the above, the application adopts a more accurate image processing algorithm to detect the defects, and combines the directional gradient moment to carry out self-adaptive filtering enhancement, thereby improving the recognition degree of the small defect targets.
In order to achieve the above purpose, the machine vision-based method for detecting the screen printing defects of the photovoltaic cell disclosed by the application comprises the following steps:
collecting RGB images of the photovoltaic cell after screen printing by using a camera;
converting the RGB image into HSV color space;
Filtering enhancement of an image, comprising: calculating the large-scale direction gradient moment and the small-scale direction gradient moment of each pixel of the image, comparing the large-scale direction gradient moment and the small-scale direction gradient moment with a threshold value T, if the ratio of the average value of the large-scale direction gradient moment and the average value of the small-scale direction gradient moment of a certain pixel is larger than the threshold value T, retaining the pixel, otherwise filtering the pixel;
eliminating grid lines in the image;
and carrying out morphological operation on the image to obtain a target image in the image, and identifying the defect type of the target in the image.
Further, the multi-scale directional gradient moment includes a large-scale directional gradient moment and a small-scale directional gradient moment, wherein the large-scale directional gradient moment is the directional gradient moment of all pixels in a circle with 5 pixels as a radius, the small-scale directional gradient moment is the directional gradient moment of all pixels in the circle with the pixel p (x, y) as a center, and the 3 pixels as a radius.
Further, the directional gradient moment is calculated as follows: the circle center pixel is p, a certain pixel in the circle is q, and the directional gradient moment of the pixel q is:
Wherein,AndThe gradient between pixel q and pixel p in the vertical and horizontal directions respectively,Is the gradient direction between pixel q and pixel p,Is the magnitude of the gradient between pixel q and pixel p.
Further, the method for calculating the threshold T is as follows:
for the average value of all pixel gray levels in the grid line with the largest gray level in the image,The average of all pixel gray levels in the gate line with the smallest gray level in the image,Is the pixel gray average value of all grid lines in the image,Is the average value of the pixel gray scale of other areas in the image,Is a regulatory factor.
Still further, the converting the RGB image into the HSV color space includes:
h channel component H:
S channel component S:
V-channel component V: v=
Wherein,Is the maximum of the red, green, and blue components in the RGB space, Tmin is the minimum of the red, green, and blue components in the RGB space, r is the red component value in the RGB space, g is the green component value in the RGB space, and b is the blue component value in the RGB space.
Further, the step of deleting the grid line comprises the following steps:
Positioning the position of the grid line: since the shape of the gate line is a horizontal or vertical line segment, when a certain pixel satisfies rule 1: detecting the last pixel and the next pixel of the pixel if the gradient on the left side of the pixel is larger than the gradient threshold G1 and the gradient on the upper side and the lower side is smaller than the gradient threshold G2, continuing the operation if the last pixel or the next pixel also accords with the rule 1, and if 10 continuous pixels accord with the rule 1, the pixels are on the left side of the vertical grid line; when a certain pixel satisfies rule 2: the gradient on the right side of the pixel is larger than the gradient threshold G1, the gradient on the upper side and the gradient on the lower side are smaller than the gradient threshold G2, the last pixel and the next pixel of the pixel are detected, when the last pixel or the next pixel also accords with the rule 2, the operation is continued, and if 10 continuous pixels accord with the rule 2, the pixels are on the right side of the vertical grid line; recording coordinates of pixels in the grid line;
When a certain pixel satisfies rule 3: detecting one pixel on the left and one pixel on the right of the pixel when the gradient on the upper side of the pixel is larger than a gradient threshold G1 and the gradient on the left and the right is smaller than a gradient threshold G2, continuing the operation when the one pixel on the left or the one pixel on the right also accords with the rule 3, and if 10 continuous pixels all accord with the rule 3, arranging the pixels on the upper side of the horizontal grid line; when a certain pixel satisfies rule 4: the gradient below the pixel is larger than the gradient threshold G1, the gradient on the left and the gradient on the right are smaller than the gradient threshold G2, then the pixel on the left and the pixel on the right of the pixel are detected, when one pixel on the left or one pixel on the right also accords with the rule 4, the operation is continued, and if 10 continuous pixels accord with the rule 4, the pixels are arranged on the lower side of the horizontal grid line; recording coordinates of pixels in the grid line;
deleting the grid line: deleting the pixels of the left coordinates, the pixels of the right coordinates and the pixels of the middle coordinates of the left coordinates and the right coordinates according to the left coordinates and the right coordinates of the vertical grid line; and deleting the pixels of the upper side coordinates, the pixels of the lower side coordinates and the pixels of the middle coordinates of the upper side coordinates and the lower side coordinates of the horizontal grid line according to the upper side coordinates and the lower side coordinates of the horizontal grid line.
Further, after the target in the image is obtained, the characteristics of the target are matched with the template, and the defect type is one of virtual printing, nodes, slurry leakage, printing offset and scratches.
Further, the features of the object include aspect ratio, area and edge features, and the matching algorithm is a quadratic matching error algorithm.
Compared with the prior art, the invention has the following beneficial effects:
An improved filtering enhancement algorithm is adopted, and the target and the background are judged by combining the directional gradient moment, so that the recognition capability of the small defect target is improved.
Detailed Description
The invention is further described below with reference to the accompanying drawings, without limiting the invention in any way, and any alterations or substitutions based on the teachings of the invention are intended to fall within the scope of the invention.
Referring to fig. 1, the method for detecting the screen printing defects of the photovoltaic cell provided by the application comprises the following steps:
s1, acquiring RGB images of a photovoltaic cell after screen printing by using a camera;
S2, converting the RGB image into HSV color space;
S3, carrying out filtering enhancement on the image, wherein the filtering enhancement comprises the following steps: and calculating the large-scale direction gradient moment and the small-scale direction gradient moment of each pixel of the image, comparing the large-scale direction gradient moment and the small-scale direction gradient moment with a threshold value T, if the ratio of the average value of the large-scale direction gradient moment of a certain pixel to the average value of the large-scale direction gradient moment is larger than the threshold value T, retaining the pixel, otherwise filtering the pixel.
The multi-scale directional gradient moment comprises a large-scale directional gradient moment and a small-scale directional gradient moment, wherein the large-scale directional gradient moment is the directional gradient moment of all pixels in a circle with 5 pixels as a radius, the small-scale directional gradient moment is the directional gradient moment of all pixels in the circle with the pixel p (x, y) as the center, and the 3 pixels as the directional gradient moment of all pixels in the circle with the radius.
The directional gradient moment is calculated as follows: the circle center pixel is p, a certain pixel in the circle is q, and the directional gradient moment of the pixel q is:
Wherein,AndThe gradient between pixel q and pixel p in the vertical and horizontal directions respectively,Is the gradient direction between pixel q and pixel p,Is the magnitude of the gradient between pixel q and pixel p.
The image gradient calculation method is the prior art in the field, and can refer to hundred degrees encyclopedia:
https://baike.baidu.com/item/%E5%9B%BE%E5%83%8F%E6%A2%AF%E5%BA%A6/8528837fr=ge_ala 。
In addition, if the threshold setting is fixed, it cannot be applied to various actual scenes, so the threshold in the present application is adaptively set, and the specific method is as follows:
for the average value of all pixel gray levels in the grid line with the largest gray level in the image,The average of all pixel gray levels in the gate line with the smallest gray level in the image,Is the pixel gray average value of all grid lines in the image,Is the average value of the pixel gray scale of other areas in the image,The regulating factors are different for each type of photovoltaic cell slice and are obtained through experiments.
When the average value of the large-scale directional moment of all pixels and the average value of the small-scale directional moment of all pixels are smaller than a threshold value, the image filtering enhancement algorithm indicates that the texture of the region is smoother and can be filtered, and when the average value of the large-scale directional moment of all pixels and the average value of the small-scale directional moment of all pixels are larger than the threshold value, the texture of the region is larger, edges of the target are reserved, and therefore the effect of enhancing the target is achieved.
S4, eliminating grid lines in the image, and only leaving a defect image.
S5, carrying out morphological operation on the image to obtain a target image in the image, and identifying the defect type of the target in the image. After the target in the image is obtained, matching the characteristics of the target with the template to obtain one of the defect types including virtual printing, nodes, slurry leakage, printing offset and scratches.
In some embodiments, converting an RGB image into an HSV color space includes:
h channel component H:
S channel component S:
V-channel component V: v=
Wherein,Is the maximum of the red, green, and blue components in the RGB space, Tmin is the minimum of the red, green, and blue components in the RGB space, r is the red component value in the RGB space, g is the green component value in the RGB space, and b is the blue component value in the RGB space.
In some embodiments, the step of deleting the gate line is:
Positioning the position of the grid line: since the shape of the gate line is a horizontal or vertical line segment, when a certain pixel satisfies rule 1: detecting the last pixel and the next pixel of the pixel if the left gradient is larger than the gradient threshold G1 and the up-down gradient is smaller than the gradient threshold G2, continuing the operation if the last pixel or the next pixel also accords with the rule 1, and if 10 continuous pixels accord with the rule 1, the pixels are on the left side of the vertical grid line; when a certain pixel satisfies rule 2: the right gradient is larger than the gradient threshold G1, the upper gradient and the lower gradient are smaller than the gradient threshold G2, the last pixel and the next pixel of the pixel are detected, when the last pixel or the next pixel also accords with the rule 2, the operation is continued, and if 10 continuous pixels accord with the rule 2, the pixels are on the right side of the vertical grid line; recording coordinates of pixels in the grid line;
When a certain pixel satisfies rule 3: detecting a pixel on the left and a pixel on the right of the pixel if the upper gradient is larger than a gradient threshold G1 and the left and right gradients are smaller than a gradient threshold G2, continuing the operation when the pixel on the left or the pixel on the right also accords with the rule 3, and if 10 continuous pixels accord with the rule 3, arranging the pixels on the upper side of the horizontal grid line; when a certain pixel satisfies rule 4: detecting a pixel on the left and a pixel on the right of the pixel if the lower gradient is larger than a gradient threshold G1 and the left and right gradients are smaller than a gradient threshold G2, continuing the operation when the pixel on the left or the pixel on the right also accords with the rule 4, and if 10 continuous pixels accord with the rule 4, arranging the pixels on the lower side of the horizontal grid line; recording coordinates of pixels in the grid line; the gradient threshold G1 is larger than the gradient threshold G2, and the gradient threshold G1 is used for judging whether the pixel is at the edge of the grid line, and if the gradient is large, the gray change is large, which indicates that the pixel is at the edge of the grid line. The gradient threshold G2 is used to determine whether the pixels at the edges of the two gate lines are adjacent, and the gray scale variation of the pixels at the edges of the two gate lines is small. If the left-right gradient or the up-down gradient of the pixel is larger than the gradient threshold G1, the pixel is indicated to be the edge of the grid line; if the pixel has a left-right gradient or an up-down gradient less than the gradient threshold G2, this pixel is illustrated as the edge of the gate line and is adjacent to the other gate line pixels.
Deleting the grid line: deleting the pixels of the left coordinates, the pixels of the right coordinates and the pixels of the middle coordinates of the left coordinates and the right coordinates according to the left coordinates and the right coordinates of the vertical grid line; and deleting the pixels of the upper side coordinates, the pixels of the lower side coordinates and the pixels of the middle coordinates of the upper side coordinates and the lower side coordinates of the horizontal grid line according to the upper side coordinates and the lower side coordinates of the horizontal grid line.
In some embodiments, the features of the target include aspect ratio, area, and edge features, and the matching algorithm is a quadratic matching error algorithm. The matching algorithm uses a secondary matching error algorithm commonly used in the field, wherein the first matching is rough matching, interlaced column data of templates, namely, one-fourth template data, are taken, and interlaced column scanning matching is carried out on the searched graph, namely, matching is carried out within one-fourth range of the original graph. The matching speed is remarkably improved because the data volume is greatly reduced. And (3) carrying out accurate matching in the second matching, namely carrying out search matching in the field of the 1 st error minimum point (imin,jmin), namely carrying out search matching in a rectangle with the diagonal point (imin+1,jmin+1), and obtaining a final result, wherein imin,jmin is the coordinate of the first error minimum point.
In some embodiments, the present application normalizes the average of the large scale directional moments of all pixels and the average of the small scale directional moments of all pixels to the interval of [0,1 ]. Therefore, the range of the threshold value T is also the interval of [0,1 ].
In some embodiments, the morphological operations include open operations, which are well known in the art, and are not described in detail herein.
Referring to fig. 2, in some embodiments, the method for acquiring the surface image of the photovoltaic cell includes: the distance between the area array camera 1 and the photovoltaic cell 3 is 400mm, the polarized area light source 2 is 350mm away from the photovoltaic cell, the polarized area light source 2 irradiates the photovoltaic cell, and the camera shoots and acquires images of the photovoltaic cell. And carrying out defect detection on the acquired screen printing image of the photovoltaic cell by using the defect detection method.
Compared with the prior art, the invention has the following beneficial effects:
An improved filtering enhancement algorithm is adopted, and the target and the background are judged by combining the directional gradient moment, so that the recognition capability of the small defect target is improved.
The word "preferred" is used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as "preferred" is not necessarily to be construed as advantageous over other aspects or designs. Rather, use of the word "preferred" is intended to present concepts in a concrete fashion. The term "or" as used in this disclosure is intended to mean an inclusive "or" rather than an exclusive "or". That is, unless specified otherwise or clear from the context, "X uses a or B" is intended to naturally include any of the permutations. That is, if X uses A; x is B; or X uses both A and B, then "X uses A or B" is satisfied in any of the foregoing examples.
Moreover, although the disclosure has been shown and described with respect to one or more implementations, equivalent alterations and modifications will occur to others skilled in the art based upon a reading and understanding of this specification and the annexed drawings. The present disclosure includes all such modifications and alterations and is limited only by the scope of the following claims. In particular regard to the various functions performed by the above described components (e.g., elements, etc.), the terms used to describe such components are intended to correspond, unless otherwise indicated, to any component which performs the specified function of the described component (e.g., that is functionally equivalent), even though not structurally equivalent to the disclosed structure which performs the function in the herein illustrated exemplary implementations of the disclosure. Furthermore, while a particular feature of the disclosure may have been disclosed with respect to only one of several implementations, such feature may be combined with one or other features of the other implementations as may be desired and advantageous for a given or particular application. Moreover, to the extent that the terms "includes," has, "" contains, "or variants thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term" comprising.
The functional units in the embodiment of the invention can be integrated in one processing module, or each unit can exist alone physically, or a plurality of or more than one unit can be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product. The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, or the like. The above-mentioned devices or systems may perform the storage methods in the corresponding method embodiments.
In summary, the foregoing embodiment is an implementation of the present invention, but the implementation of the present invention is not limited to the embodiment, and any other changes, modifications, substitutions, combinations, and simplifications made by the spirit and principles of the present invention should be equivalent to the substitution manner, and all the changes, modifications, substitutions, combinations, and simplifications are included in the protection scope of the present invention.