Disclosure of Invention
The embodiment of the invention aims to provide a defect detection method and device and a computer scale storage medium, so that the accuracy of defect detection is improved while the production cost and the occupied space are not increased additionally.
In order to solve the above technical problems, an embodiment of the present invention provides a defect detection method, which is applied to a transparent cover plate, and includes: setting marks on one surface of the transparent cover plate as a front surface and the other surface as a back surface; acquiring a first view of the transparent cover plate at a first placement angle and a second view of the transparent cover plate at a second placement angle; establishing a mapping relation between the positions of points on the transparent cover plate in the first view and the positions of the points on the transparent cover plate in the second view according to the positions of the marks in the first view and the positions of the marks in the second view; obtaining a mapping view according to the first view and the mapping relation; and acquiring the position difference value of the same defect on the mapping view and the second view as a mapping deviation value, and judging whether the defect is positioned on the front surface or the back surface according to the mapping deviation value.
The embodiment of the invention also provides a defect detection device, which comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a defect detection method as described above.
The embodiment of the invention also provides a computer readable storage medium storing a computer program which when executed by a processor implements the defect detection method.
Compared with the prior art, the embodiment of the invention sets the mark on the front surface of the transparent cover plate, establishes the mapping relation between the positions of each point on the first view and the second view according to the position of the mark, and converts the first view into the mapping view through the mapping relation. Through set up the mark on transparent cover plate's openly, solved the problem of no reference object on the transparent cover plate to judgement defect that can be accurate is located openly or the back, compares in the manual work dyestripping detection among the prior art, can effectually prevent the influence of artifical subjective factor, promotes the accuracy that detects, need not to tear the membrane moreover, just need not to increase extra stations such as dyestripping, pad pasting, effectual reduction in production cost, save production space.
In addition, the determining that the defect is located on the front surface or the back surface according to the mapping deviation value specifically includes: judging whether the mapping deviation value is larger than a preset threshold value or not; if yes, judging that the defect is positioned on the back surface. Because the error exists, even if the defect on the front surface exists between the position on the mapping view and the position on the second view, when the mapping deviation value is judged to be larger than the preset threshold value, the defect is judged to be on the back surface, namely the preset threshold value is a preset threshold value of the mapping deviation value, the influence of the mapping deviation value of the defect on the front surface caused by the error on the detection result is eliminated, and the accuracy of defect detection is effectively improved.
In addition, the obtaining the position difference value of the same defect on the mapping view and the second view as the mapping deviation value specifically includes: intercepting the defect and a preset area around the defect from the mapping view as a template image corresponding to the defect; acquiring N neighborhood of the region with the same position, shape and area as the template image in the second view as a search image, wherein N is a positive integer; acquiring a region with highest similarity with the template image in the search image as an optimal region; and acquiring a position difference value of the optimal region and the template image as the mapping deviation value.
In addition, the determining whether the defect is located on the front surface or the back surface according to the mapping deviation value specifically includes: judging whether the mapping deviation value is larger than a preset threshold value or not; if not, executing the following steps; acquiring the area of the search image as a first area, acquiring the area of the defect in the template image as a second area, and acquiring the area of the defect in the search image as a third area; acquiring a gray average value of the template image as a first gray average value, and acquiring a gray average value of a neighborhood of the defect as a second gray average value; and when the first gray average value is larger than the second gray average value, the difference value between the first gray average value and the second gray average value is larger than the gray deviation value, the ratio of the second area to the first area is larger than the first area occupation ratio, and the ratio of the third area to the second area is larger than the second area occupation ratio, judging that the defect is positioned on the back surface. For the defects with the mapping deviation value not larger than the preset threshold value, whether the defects are positioned on the front side or the back side is further judged according to the relation between the area and the gray value, so that the defect detection accuracy is further improved.
In addition, before the mapping relationship between the position of each point on the transparent cover plate in the first view and the position of each point in the second view is established, the method further includes: threshold segmentation is carried out on the first view to form a first binary image; extracting an image of the marker from the first binary image as a first marker image; threshold segmentation is carried out on the second view to form a second binary image; and extracting the marked image from the second binary image as a second marked image.
In addition, the extracting the marked image from the first binary image as a first marked image specifically includes: extracting an image of the mark from the first binary image as a first mark image according to the characteristic information of the mark; the extracting the marked image from the second binary image as a second marked image specifically includes: extracting the marked image from the second binary image as a second marked image according to the characteristic information of the mark; wherein the feature information includes at least one of shape information and size information of the feature.
In addition, the front surface is provided with a mark, which specifically comprises: a plurality of marks are arranged on the front face, and the marks are numbered; the establishing a mapping relationship between the position of each point on the transparent cover plate in the first view and the position of each point on the transparent cover plate in the second view according to the position of the mark in the first view and the position of the mark in the second view specifically comprises: and establishing a mapping relation between the positions of the points on the transparent cover plate in the first view and the positions of the points on the transparent cover plate in the second view according to the position coordinates of the marks with the same number in the first view and the position coordinates of the marks in the second view.
In addition, before the obtaining the position difference value of the same defect on the mapping view and the second view as the mapping deviation value, the method further includes: sequentially performing filtering processing and threshold segmentation on the first view; and sequentially carrying out filtering processing and threshold segmentation on the mapping view.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art will understand that in various embodiments of the present invention, numerous technical details have been set forth in order to provide a better understanding of the present application. However, the technical solutions claimed in the present application can be implemented without these technical details and with various changes and modifications based on the following embodiments.
The first embodiment of the present invention relates to a defect detection method applied to a transparent cover plate, and the specific flow is shown in fig. 1, including:
step S101: a mark is provided on the front face of the transparent cover plate.
In this step, one surface of the transparent cover plate is set as the front surface, the other surface is set as the back surface, and a mark is provided on the front surface of the transparent cover plate.
Specifically, in the present embodiment, the bonding surface of the transparent cover plate is the back surface, and the non-bonding surface is the front surface. The mark is arranged on the non-bonding surface of the transparent cover plate, so that secondary pollution to the bonding surface due to the arrangement of the mark can be effectively prevented. It should be understood that the use of the bonding surface of the transparent cover plate as the back surface and the non-bonding surface as the front surface is only one specific example in the present embodiment, and is not limited thereto, and in other embodiments of the present invention, the bonding surface of the transparent cover plate may be the front surface and the non-bonding surface may be the back surface, and may be specifically set according to actual needs.
Further, in the present embodiment, the number of marks provided on the front surface is plural, and the plural marks are numbered.
Step S102: a first view and a second view of the transparent cover plate are acquired.
Specifically, in this step, a first view and a second view of the transparent cover plate are acquired by the image pickup device. The first view is a view of the transparent cover plate acquired by the camera device under a first placement angle, and the second view is a view of the transparent cover plate acquired by the camera device under a second placement angle. The first placing angle and the second placing angle are angles of a plane where the transparent cover plate is located relative to an imaging direction of the imaging device.
Step S103: and establishing a mapping relation between the positions of the points on the transparent cover plate in the first view and the positions of the points on the transparent cover plate in the second view.
Specifically, in this step, first, the first view and the second view are respectively subjected to threshold segmentation to form a first binary image and a second binary image, and the marked images are respectively extracted from the first binary image and the second binary image as a first marked image and a second marked image according to the pre-stored feature information of the marks, so as to obtain the position coordinates of the marks in the first view and the second view. Wherein the characteristic information of the mark is at least one of shape information and size information of the mark. For example, in the present embodiment, the feature information of the pre-stored mark is a circle with a radius greater than 5, and then a circle image with a radius greater than 5 is acquired as the first mark image and the second mark image in the first binary view and the second binary view, and further the position coordinates of the first mark image and the second mark image in the first view and the second view, respectively, are acquired. It should be understood that the feature information of the mark is at least one of shape information and size information of the mark, which is only a specific application example in the present embodiment, and is not limited to the specific application example, and in other embodiments of the present invention, the feature information of the mark may also be other information such as a positional relationship, and may be specifically and flexibly set according to actual needs.
Further, in this step, when the number of marks is plural, a mapping relationship between the positions of the points on the transparent cover plate in the first view and the positions of the points on the transparent cover plate in the second view is established according to the position coordinates of the marks of the same number in the first view and the position coordinates in the second view.
Step S104: and obtaining a mapping view according to the first view and the mapping relation.
Specifically, in this step, the position coordinates of each point on the first view are mapped according to the mapping relationship, and the image generated by the mapping is used as the mapping view.
Step S105: and acquiring the position difference value of the same defect on the mapping view and the second view as a mapping deviation value.
Specifically, in this step, the first view is subjected to filtering processing according to the size of the defect, and then the first view after the filtering processing is subjected to threshold segmentation, and the result is shown in fig. 2. And (3) carrying out filtering processing on the second view according to the size of the defect, and then carrying out threshold segmentation on the second view after the filtering processing, wherein the result is shown in fig. 3. In the present embodiment, two gaussian filters having kernel sizes of 11 to 3 are linearly combined, and the first view and the second view are filtered, where the larger the defect, the larger the kernel size of the gaussian filter, the smaller the defect, and the smaller the kernel size of the gaussian filter. It will be appreciated that the linear combination of two gaussian filters with a kernel size of 11 to 3 is only a specific example in this embodiment, and in other embodiments of the present invention, the filtering may be performed by other manners or kernel sizes, which are not limited specifically herein, and may be flexibly set according to actual needs.
Further, after the first view and the second view are subjected to filtering processing and threshold segmentation, firstly, capturing the defect and a preset area around the defect from the mapping view as a template image corresponding to the defect; as shown in fig. 4, a rectangular region including a defect image is taken as a template image, and the upper left corner X coordinate of the rectangular region is rect.x, the upper left corner Y coordinate of the rectangle is rect.y, the width of the rectangle is rect.width, and the height of the rectangle is rect.height. Then N neighborhood of the region with the same position, shape and area as the template image in the second view is obtained as a search image, wherein N is a positive integer; as shown in fig. 5, the upper left corner X coordinate of the search image is rect.x-N, the upper left corner Y coordinate of the search image is rect.y+n, the width of the rectangle is rect.width+2*N, and the height of the rectangle is rect.height+2*N. Then, placing the template image in the search image to perform pixel-by-pixel similarity comparison, and obtaining a region with highest similarity with the template image in the search image as an optimal region; and acquiring a position difference value between the optimal region and the template image as a mapping deviation value.
Step S106: and judging whether the mapping deviation value is larger than a preset threshold value, if so, executing the step S107, and if not, executing the step S108.
Step S107: and judging that the defect is positioned on the back surface.
Step S108: and judging that the defect is positioned on the front surface.
Compared with the prior art, the defect detection method provided by the first embodiment of the invention solves the problem that no reference object exists on the transparent cover plate by arranging the mark on the front surface of the transparent cover plate, thereby accurately judging whether the defect is positioned on the front surface or the back surface.
A second embodiment of the present invention relates to a defect detection method. The second embodiment is substantially the same as the first embodiment, and includes the following specific steps as shown in fig. 6:
step S201: a mark is provided on the front face of the transparent cover plate.
Step S202: a first view and a second view of the transparent cover plate are acquired.
Step S203: and establishing a mapping relation between the positions of the points on the transparent cover plate in the first view and the positions of the points on the transparent cover plate in the second view.
Step S204: and obtaining a mapping view according to the first view and the mapping relation.
Step S205: and acquiring the position difference value of the same defect on the mapping view and the second view as a mapping deviation value.
Step S206: and judging whether the mapping deviation value is greater than a preset threshold value, if so, executing step S207, and if not, executing step S208.
Step S207: and judging that the defect is positioned on the back surface.
Since steps S201 to S207 in the present embodiment are the same as steps S101 to S107 in the first embodiment, specific reference may be made to the specific contents in the first embodiment, and the description thereof will not be repeated here.
Step S208: judging whether the search image and the template image meet the preset conditions, if so, executing step S207, and if not, executing step S208.
Specifically, in this step, the Area of the search image is acquired as a first Area SumArea, the Area of the defect in the template image is acquired as a second Area1, and the Area of the defect in the search image is acquired as a third Area2; acquiring a gray average value of a template image as a first gray average value g1, and acquiring a gray average value of a neighborhood of the defect as a second gray average value g2;
the preset condition is that the first gray average value g1 is larger than the second gray average value g2, the difference value g1-g2 between the first gray average value and the second gray average value is larger than the gray deviation value delta g, the ratio of the second Area1 to the first Area SumArea is larger than the first Area occupation ratio ka1, and the ratio of the third Area2 to the second Area1 is larger than the second Area occupation ratio ka2.
Step S209: and judging that the defect is positioned on the front surface.
Compared with the prior art, the defect detection method provided by the second embodiment of the invention has the advantages that the steps of judging whether the search image and the template image meet the preset conditions are added while all the technical effects of the first embodiment are maintained, so that the defect position detection accuracy can be further improved.
It should be understood that the above steps of the various methods are divided, for clarity of description, and may be combined into one step or split into multiple steps when implemented, so long as they contain the same logic relationship, and all the steps are within the protection scope of the present patent; it is within the scope of this patent to add insignificant modifications to the algorithm or flow or introduce insignificant designs, but not to alter the core design of its algorithm and flow.
A third embodiment of the present invention relates to a defect detecting apparatus, as shown in fig. 7, comprising: at least one processor 301; and a memory 302 communicatively coupled to the at least one processor 301; wherein the memory 302 stores instructions executable by the at least one processor 301, the instructions being executable by the at least one processor 301 to enable the at least one processor 301 to perform the elevator reservation method as in the first to third embodiments.
Where the memory 302 and the processor 301 are connected by a bus, the bus may comprise any number of interconnected buses and bridges, the buses connecting the various circuits of the one or more processors 301 and the memory 302 together. The bus may also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art, and therefore, will not be described any further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or may be a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor 301 is transmitted over a wireless medium via an antenna, which further receives the data and transmits the data to the processor 301.
The processor 301 is responsible for managing the bus and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And memory 302 may be used to store data used by processor 301 in performing operations.
A fourth embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The computer program, when executed by a processor, implements the embodiments of the defect detection method of the first to second embodiments.
That is, it will be understood by those skilled in the art that all or part of the steps in implementing the methods of the embodiments described above may be implemented by a program stored in a storage medium, where the program includes several instructions for causing a device (which may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps in the methods of the embodiments described herein. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific embodiments in which the invention is practiced and that various changes in form and details may be made therein without departing from the spirit and scope of the invention.