CN116539617A - Method, device and medium for detecting lens defect - Google Patents
Method, device and medium for detecting lens defect Download PDFInfo
- Publication number
- CN116539617A CN116539617A CN202310403665.6A CN202310403665A CN116539617A CN 116539617 A CN116539617 A CN 116539617A CN 202310403665 A CN202310403665 A CN 202310403665A CN 116539617 A CN116539617 A CN 116539617A
- Authority
- CN
- China
- Prior art keywords
- lens
- defect
- determining
- pictures
- defects
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000007547 defect Effects 0.000 title claims abstract description 333
- 238000000034 method Methods 0.000 title claims abstract description 57
- 238000001514 detection method Methods 0.000 claims abstract description 12
- 230000008859 change Effects 0.000 claims description 25
- 238000004590 computer program Methods 0.000 claims description 16
- 238000004519 manufacturing process Methods 0.000 abstract description 4
- 230000008569 process Effects 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 238000004364 calculation method Methods 0.000 description 3
- 238000003384 imaging method Methods 0.000 description 3
- 101100153581 Bacillus anthracis topX gene Proteins 0.000 description 2
- 101150041570 TOP1 gene Proteins 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/84—Systems specially adapted for particular applications
- G01N21/88—Investigating the presence of flaws or contamination
- G01N21/8851—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01M—TESTING STATIC OR DYNAMIC BALANCE OF MACHINES OR STRUCTURES; TESTING OF STRUCTURES OR APPARATUS, NOT OTHERWISE PROVIDED FOR
- G01M11/00—Testing of optical apparatus; Testing structures by optical methods not otherwise provided for
- G01M11/02—Testing optical properties
- G01M11/0242—Testing optical properties by measuring geometrical properties or aberrations
- G01M11/0278—Detecting defects of the object to be tested, e.g. scratches or dust
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/84—Systems specially adapted for particular applications
- G01N21/88—Investigating the presence of flaws or contamination
- G01N21/8851—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
- G01N2021/8887—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges based on image processing techniques
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Physics & Mathematics (AREA)
- Chemical & Material Sciences (AREA)
- Analytical Chemistry (AREA)
- General Physics & Mathematics (AREA)
- Biochemistry (AREA)
- Life Sciences & Earth Sciences (AREA)
- Engineering & Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Signal Processing (AREA)
- General Health & Medical Sciences (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Immunology (AREA)
- Pathology (AREA)
- Geometry (AREA)
- Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
Abstract
The application discloses a method, equipment and medium for detecting lens defects, and belongs to the technical field of lens defect detection. Acquiring lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, and determining whether suspected defects exist in all the lens pictures or not based on image attributes of the lens pictures, wherein the image attributes comprise point position information of the lens pictures; and if the suspected defects exist in all the lens pictures, determining the suspected defects as target defects of the lens to be detected. And shooting the lens to be detected under different focal lengths by focusing the camera at different depths to obtain lens images possibly with defects with different depths, identifying suspected defects in the lens pictures, and determining the suspected defects as target defects after determining that all the lens pictures have the suspected defects. By the method, the lens defects can be detected at different depths, so that the accuracy is high and the production line detection efficiency can be improved.
Description
Technical Field
The present disclosure relates to the field of lens defect detection, and in particular, to a method for detecting a lens defect, a device for detecting a lens defect, and a computer readable storage medium.
Background
Currently, related hardware products and content resources of the head-mounted display device are increasing, and as users are increasing, the number of production thereof is also increasing. In order to ensure that the head-mounted display device can be widely applied and has better user experience, the display screen of the head-mounted display device must achieve better resolution and cannot have dead spots and dirt. In the process of producing the head-mounted display device, the defects of the surface of the lens can be well distinguished by a software algorithm.
However, for defects at different depths of the lens, due to the characteristics of small area, adhesion with the background and the like of the depth defects, and the reasons that all the depth defects cannot be displayed in one image without being in a focusing position of a camera, the defects at different depths of the lens are difficult to detect.
Disclosure of Invention
The present invention provides a method for detecting defects of a lens, a device for detecting defects of a lens, and a computer-readable storage medium, and aims to solve the technical problem that defects of different depths of a lens are difficult to detect in the prior art.
In order to achieve the above object, the present application provides a method for detecting a lens defect, the method comprising:
Acquiring lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, and determining whether suspected defects exist in all the lens pictures or not based on image attributes of the lens pictures, wherein the image attributes comprise point position information of the lens pictures;
and if the suspected defects exist in all the lens pictures, determining that the suspected defects are target defects of the lens to be detected.
Illustratively, the step of determining whether suspected defects exist in all the lens pictures based on the image attributes of the lens pictures includes:
determining regional center points in the regions of interest of the preset defects of any two target lens pictures in all the lens pictures, and determining reference center points of the two target lens pictures based on the regional center points;
determining a first defect center point of a first defect to be determined in one of the target lens pictures and a second defect center point of a second defect to be determined in the other of the target lens pictures;
determining whether the undetermined defects in all the lens pictures meet a preset slope condition based on the reference center point, the first defect center point and the second defect center point, and determining whether the undetermined defects in all the lens pictures meet a preset image size offset condition;
And if the undetermined defects in all the lens pictures meet the preset slope condition and the preset image size deviation condition, determining that suspected defects exist in all the lens pictures.
Illustratively, the step of determining whether the undetermined defects in all the lens pictures meet a preset slope condition includes:
determining a first slope between the reference center point and the first defect center point, a second slope between the reference center point and the second defect center point, and a third slope between the first defect center point and the second defect center point;
and when the variances among the first slope, the second slope and the third slope in the two target lens pictures are smaller than a preset first threshold value, determining that undetermined defects in all the lens pictures meet preset slope conditions.
Illustratively, the step of determining whether the undetermined defects in all the lens pictures meet a preset image size shift condition includes:
determining a first distance between the first defect center point and the reference center point, and a second distance between the second defect center point and the reference center point;
Determining a first maximum distance of the outline of the undetermined defect in one of the target lens pictures, and a second maximum distance of the outline of the undetermined defect in the other of the target lens pictures;
determining an image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance;
and determining a first distance difference between the first distance and the second distance, and determining that undetermined defects in all the lens pictures meet a preset image size offset condition when the first distance difference of any two target lens pictures is smaller than the image size offset.
Illustratively, the step of determining the image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance comprises:
determining a first distance sum of the first distance and the second distance;
determining a second distance sum of the first contour maximum distance and the second contour maximum distance;
determining a second distance difference between the first contour maximum distance and the second contour maximum distance;
An image size offset is determined based on a ratio between the first distance sum, the second distance sum, and the second distance difference.
Illustratively, before the step of determining that the suspected defect is the target defect of the lens to be detected, the method further includes:
determining gradient rectangles and outline rectangles of the suspected defects in any two target lens pictures;
determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle.
The step of determining the gradient rectangle and the outline rectangle of the suspected defect in any two target lens pictures includes:
traversing pixels of the target lens picture, and determining a pixel region with a gradient change value larger than a preset second threshold value as a gradient rectangle of the suspected defect;
and carrying out binarization processing on the target lens picture, and determining that the circumscribed rectangle of the maximum black pixel connected domain is the outline rectangle of the suspected defect.
Illustratively, the step of determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle includes:
determining an intersection area of the gradient rectangle and the outline rectangle;
Determining a target area between the gradient rectangle and the outline rectangle, wherein the target area is a larger value of the area of the gradient rectangle and the area of the outline rectangle;
and if the intersection ratio is greater than a preset third threshold value and the number of black pixels in the target area is greater than a preset fourth threshold value, determining the suspected defect as the target defect, wherein the intersection ratio is the ratio of the intersection area to the target area.
The application also provides a detection device of lens defect, the detection device of lens defect includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, which when executed by the processor, performs the steps of the method for detecting a lens defect as described above.
The present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of detecting a lens defect as described above.
According to the method for detecting the lens defects, the device for detecting the lens defects and the computer-readable storage medium, lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, are obtained, and whether suspected defects exist in all the lens pictures or not is determined based on image attributes of the lens pictures, wherein the image attributes comprise point position information of the lens pictures; and if the suspected defects exist in all the lens pictures, determining that the suspected defects are target defects of the lens to be detected.
Since the lens defects have the specificity of depth characteristics, the defects with different depths of the lens are difficult to detect, and therefore, in the application, the lens to be detected is shot under different focal lengths by focusing a camera at different depths, so that lens images with the defects with different depths are obtained, suspected defects in lens pictures are identified, and after all the lens pictures are determined to have the suspected defects, the suspected defects can be determined to be target defects. By the method, the lens defects can be detected at different depths, so that the accuracy is high and the production line detection efficiency can be improved.
Drawings
FIG. 1 is a schematic diagram of an operating device of a hardware operating environment according to an embodiment of the present application;
FIG. 2 is a flow chart of an embodiment of a method for detecting lens defects according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a depth defect of an embodiment of a method for detecting a lens defect according to an embodiment of the present application;
FIG. 4 is a schematic view of a first gradient rectangle of an embodiment of a method for detecting a lens defect according to an embodiment of the present application;
FIG. 5 is a schematic view of a second gradient rectangle of an embodiment of a method for detecting a lens defect according to an embodiment of the present application;
FIG. 6 is a first outline rectangular schematic diagram of an embodiment of a method for detecting a lens defect according to an embodiment of the present application;
fig. 7 is a second outline rectangular schematic diagram of an embodiment of a method for detecting a lens defect according to an embodiment of the present application.
The realization, functional characteristics and advantages of the present application will be further described with reference to the embodiments, referring to the attached drawings.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
Referring to fig. 1, fig. 1 is a schematic diagram of an operating device of a hardware operating environment according to an embodiment of the present application.
As shown in fig. 1, the operation device may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) Memory or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
It will be appreciated by those skilled in the art that the structure shown in fig. 1 is not limiting of the operating device and may include more or fewer components than shown, or certain components may be combined, or a different arrangement of components.
As shown in fig. 1, an operating system, a data storage module, a network communication module, a user interface module, and a computer program may be included in the memory 1005 as one type of storage medium.
In the operating device shown in fig. 1, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with a user; the processor 1001, the memory 1005 in the operation device of the present application may be provided in an operation device that calls a computer program stored in the memory 1005 through the processor 1001 and performs the following operations:
acquiring lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, and determining whether suspected defects exist in all the lens pictures or not based on image attributes of the lens pictures, wherein the image attributes comprise point position information of the lens pictures;
and if the suspected defects exist in all the lens pictures, determining that the suspected defects are target defects of the lens to be detected.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
the step of determining whether suspected defects exist in all the lens pictures based on the image attributes of the lens pictures comprises the following steps:
determining regional center points in the regions of interest of the preset defects of any two target lens pictures in all the lens pictures, and determining reference center points of the two target lens pictures based on the regional center points;
determining a first defect center point of a first defect to be determined in one of the target lens pictures and a second defect center point of a second defect to be determined in the other of the target lens pictures;
determining whether the undetermined defects in all the lens pictures meet a preset slope condition based on the reference center point, the first defect center point and the second defect center point, and determining whether the undetermined defects in all the lens pictures meet a preset image size offset condition;
and if the undetermined defects in all the lens pictures meet the preset slope condition and the preset image size deviation condition, determining that suspected defects exist in all the lens pictures.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
the step of determining whether the undetermined defects in all the lens pictures meet the preset slope condition comprises the following steps:
determining a first slope between the reference center point and the first defect center point, a second slope between the reference center point and the second defect center point, and a third slope between the first defect center point and the second defect center point;
and when the variances among the first slope, the second slope and the third slope in the two target lens pictures are smaller than a preset first threshold value, determining that undetermined defects in all the lens pictures meet preset slope conditions.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
the step of determining whether the undetermined defects in all the lens pictures meet the preset image size deviation condition comprises the following steps:
determining a first distance between the first defect center point and the reference center point, and a second distance between the second defect center point and the reference center point;
Determining a first maximum distance of the outline of the undetermined defect in one of the target lens pictures, and a second maximum distance of the outline of the undetermined defect in the other of the target lens pictures;
determining an image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance;
and determining a first distance difference between the first distance and the second distance, and determining that undetermined defects in all the lens pictures meet a preset image size offset condition when the first distance difference of any two target lens pictures is smaller than the image size offset.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
the step of determining an image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance, comprises:
determining a first distance sum of the first distance and the second distance;
determining a second distance sum of the first contour maximum distance and the second contour maximum distance;
Determining a second distance difference between the first contour maximum distance and the second contour maximum distance;
an image size offset is determined based on a ratio between the first distance sum, the second distance sum, and the second distance difference.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
before the step of determining that the suspected defect is the target defect of the lens to be detected, the method further includes:
determining gradient rectangles and outline rectangles of the suspected defects in any two target lens pictures;
determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
the step of determining the gradient rectangle and the outline rectangle of the suspected defects in any two target lens pictures comprises the following steps:
traversing pixels of the target lens picture, and determining a pixel region with a gradient change value larger than a preset second threshold value as a gradient rectangle of the suspected defect;
and carrying out binarization processing on the target lens picture, and determining that the circumscribed rectangle of the maximum black pixel connected domain is the outline rectangle of the suspected defect.
In an embodiment, the processor 1001 may call a computer program stored in the memory 1005, and further perform the following operations:
the step of determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle includes:
determining an intersection area of the gradient rectangle and the outline rectangle;
determining a target area between the gradient rectangle and the outline rectangle, wherein the target area is a larger value of the area of the gradient rectangle and the area of the outline rectangle;
and if the intersection ratio is greater than a preset third threshold value and the number of black pixels in the target area is greater than a preset fourth threshold value, determining the suspected defect as the target defect, wherein the intersection ratio is the ratio of the intersection area to the target area.
An embodiment of the present application provides a method for detecting a lens defect, referring to fig. 2, in a first embodiment of the method for detecting a lens defect, the method includes:
step S10, obtaining lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, and determining whether suspected defects exist in all the lens pictures based on image attributes of the lens pictures, wherein the image attributes comprise point position information of the lens pictures.
Step S20, if the suspected defects exist in all the lens pictures, determining the suspected defects as target defects of the lens to be detected.
Referring to fig. 3, the depth defect may be located at any position of the lens, so that in order to obtain a clearer imaging effect of the defect on the image, the camera may be focused at different depths of the lens, that is, the focal length of the camera is continuously changed, so that the camera is focused on the defect at different depths of the lens. Defects of different depths on the lens are displayed on the image as follows: the clearer the lens picture is taken when the focus position and the defect position are more consistent. Therefore, in the present embodiment, a plurality of images are photographed from the lens surface to the bottom surface by adjusting the focal length, that is, the focal length is adjusted from the lens surface to the lens bottom surface, and the plurality of images are photographed during the adjustment, and the photographed images are detected and analyzed. In the present embodiment, the number of lens pictures taken is not limited. In one implementation, 10 images at 10 focal lengths may be taken, and defects on each image may be detected, as illustrated below for two images at two different focal lengths. In an embodiment, 10 lens images under 10 focal lengths are traversed, a subsequent detection step is performed between every two of the first lens image and the remaining nine lens images, a subsequent detection step is performed between every two of the second lens image and the remaining eight lens images, and by this, the suspected defects are confirmed to be target defects in all the results of the pairwise judgment.
After the original pictures of the lens to be detected under different focal lengths are acquired, extracting an effective area to be detected from the original pictures so as to eliminate interference. In one embodiment, a binarization process is performed on an original picture by using a self-adaptive binarization mode to obtain a binary image; then determining the outline of the binary image, and searching to obtain the maximum outline in the binary image, wherein in order to adaptively select the region of interest, the original images with different proportions can be scaled to obtain outline images with different sizes; and finally, acquiring a corresponding effective area in the maximum outline by means of Fourier change, convolution, inverse Fourier change, binarization and the like, and identifying suspected defects of the effective area in the lens picture. Wherein a subsequent detection step is performed for each suspected defect. In another embodiment, firstly, a band-pass filter is formed by subtracting two Gaussian filters with different parameters, then convolution operation is carried out on an image based on the band-pass filter, fourier inverse transformation is carried out after the convolution operation is completed, then the maximum gray value and the minimum gray value of the image are obtained after mask operation, and finally binarization processing is carried out to obtain an effective area.
And after determining that the suspected defects exist in all the lens pictures, determining the suspected defects as target defects, namely determining the suspected defects as depth defects in the lenses to be detected. In an embodiment, a target image in which the depth defect with the largest contrast value is located is determined, and depth information of the defect is determined in the sharpest target image, that is, the depth of the different defect in the lens to be detected is calculated through the sharpest target image.
In the present embodiment, a method of identifying a defect and a method of determining depth information of a defect are not limited.
In this embodiment, lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, are acquired, and whether suspected defects exist in all the lens pictures is determined based on image attributes of the lens pictures, wherein the image attributes comprise point location information of the lens pictures; and if the suspected defects exist in all the lens pictures, determining that the suspected defects are target defects of the lens to be detected.
Since the lens defects have the specificity of depth characteristics, the defects of different depths of the lens are difficult to detect, and therefore, in this embodiment, it is proposed that the lens to be detected is shot under different focal lengths by focusing the camera at different depths, so as to obtain lens images with possible defects of different depths, and the suspected defects in the lens pictures are identified, and after all the lens pictures are determined to have the suspected defects, the suspected defects can be determined to be target defects. By the method, the lens defects can be detected at different depths, so that the accuracy is high and the production line detection efficiency can be improved.
In an embodiment of the method for detecting a lens defect, the step of determining whether suspected defects exist in all the lens pictures based on image attributes of the lens pictures includes:
determining regional center points in the regions of interest of the preset defects of any two target lens pictures in all the lens pictures, and determining reference center points of the two target lens pictures based on the regional center points;
determining a first defect center point of a first defect to be determined in one of the target lens pictures and a second defect center point of a second defect to be determined in the other of the target lens pictures;
determining whether the undetermined defects in all the lens pictures meet a preset slope condition based on the reference center point, the first defect center point and the second defect center point, and determining whether the undetermined defects in all the lens pictures meet a preset image size offset condition;
and if the undetermined defects in all the lens pictures meet the preset slope condition and the preset image size deviation condition, determining that suspected defects exist in all the lens pictures.
In this embodiment, a method for determining whether suspected defects exist in all lens pictures is provided, and whether suspected defects exist in all lens pictures is determined by determining whether the undetermined defects in all lens pictures meet a preset slope condition and a preset image size offset condition.
The point location information included in the image attribute of the lens picture comprises a region center point in a preset defect interest region, a reference center point of the target lens picture and a defect center point of a to-be-determined defect.
Firstly, selecting any two lens pictures as target lens pictures, wherein the contours identified on the target lens pictures are composed of contour points, calculating the coordinates of the maximum contour point and the minimum contour point to obtain the sizes of the regions of interest of different images, and demarcating the regions of interest of preset images in the regions of interest of different images.
Then, determining a region center point in a preset defect interest region of any two target lens pictures, wherein the determined region center point can be obtained by directly reading the region attribute of the defect interest region, in an embodiment, the preset defect interest region is a circular region, the region center point is the center of the preset defect interest region, and the region center point is obtained by directly reading the center coordinates of the preset defect interest region.
Secondly, because of the distortion of the size and the change of the focal length of the image, the same depth defect is on images with different focal lengths, and the coordinate positions of the depth defect are relatively large, for example, only one defect is generated when the focus is in a virtual focus, three or more defects are generated when the focus is not in the virtual focus, or only one defect is generated when the focus is not in the virtual focus, and three or more defects are generated when the focus is in the virtual focus. Therefore, it is necessary to determine the reference center points of the two target lens images based on the region center points, and in an embodiment, the coordinate mean value of the region center points corresponding to the two selected target lens images is used as the reference center point, so as to obtain a precise reference center point avoiding distortion as much as possible.
Next, a first defect center point of a first defect to be determined in one of the target lens pictures and a second defect center point of a second defect to be determined in the other target lens picture are determined by image recognition, and in this embodiment, the method of determining the defect center point is not limited at the same time.
Illustratively, the step of determining whether the undetermined defects in all the lens pictures meet a preset slope condition includes:
Determining a first slope between the reference center point and the first defect center point, a second slope between the reference center point and the second defect center point, and a third slope between the first defect center point and the second defect center point;
and when the variances among the first slope, the second slope and the third slope in the two target lens pictures are smaller than a preset first threshold value, determining that undetermined defects in all the lens pictures meet preset slope conditions.
In this embodiment, a preset slope condition and a method for determining whether the undetermined defects in all lens pictures meet the preset slope condition are provided.
And determining a first slope of the reference center point and the first defect center point, a second slope of the reference center point and the second defect center point and a third slope of the first defect center point and the second defect center point through a slope calculation formula between the two points. In one embodiment, the reference center point is (x c ,y c ) The first defect center point is (x i ,y i ) The second defect center point is (x j ,y j ) A first slope of k i =(y i -y c )/(x i -x c ) The second slope is k j =(y j -y c )/(x j -x c ) The third slope is K= (y) i -y j )/(x i -x j ) When the first slope k of any two target lens pictures i A second slope k j And thirdAnd when the variance of the three values of the slope K is smaller than a preset first threshold value, determining that the defects to be determined in all the lens pictures meet the preset slope condition. That is, images taken at different focal lengths, similarly to scaling up or down in the radial direction along the image center point, illustrate the reference center point, the first defect center point, and the second defect center point, with the three points on a straight line, in the case where the preset slope condition is satisfied.
Illustratively, the step of determining whether the undetermined defects in all the lens pictures meet a preset image size shift condition includes:
determining a first distance between the first defect center point and the reference center point, and a second distance between the second defect center point and the reference center point;
determining a first maximum distance of the outline of the undetermined defect in one of the target lens pictures, and a second maximum distance of the outline of the undetermined defect in the other of the target lens pictures;
determining an image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance;
And determining a first distance difference between the first distance and the second distance, and determining that undetermined defects in all the lens pictures meet a preset image size offset condition when the first distance difference of any two target lens pictures is smaller than the image size offset.
In this embodiment, a preset image size shift condition and a method for determining whether defects to be determined in all lens pictures satisfy the preset image size shift condition are provided.
The definition of the image size offset delta distance is as follows: assuming that the pixel distance after imaging of one line segment at the current focal length is 100 pixels and the pixel distance after imaging at the other focal length is 300 pixels, the image size offset Δdistance is 300-100=200 pixels.
Although the reference center point, the first defect center point and the second defect center point can be determined on the premise of meeting the preset slope condition, the three points are on the same straight line, but the defect center point of the defect to be determined in any two target lens pictures cannot be directly described as the same defect point, and whether the image size offset delta distance corresponds to the position change caused by the focal length change or not needs to be judged, namely whether the image size offset delta distance of any two target lens pictures corresponds to the position change caused by the focal length change or not is also needed. For example, although the image size offset Δdistance is 200 pixels, the position change due to the focal length change is 190 pixels, and there is a case where the camera shooting is inaccurate, and cannot correspond to the actual focal length change.
The determination of the region center point and the reference center point, and the determination of the first defect center point and the second defect center point are not described herein.
Then, determining a first distance between the first defect center point and the reference center point and a second distance between the second defect center point and the reference center point through Euclidean distance calculation; in one embodiment, the first defect center point A is spaced from the reference center point (x c ,y c ) Is D i The first defect center point B is located from the reference center point (x c ,y c ) Is D j 。
Next, determining a first contour maximum distance of the defects to be determined in one of the target lens pictures, and a second contour maximum distance of the defects to be determined in the other target lens picture; in an embodiment, the profile information vector < Point > lnnerprofile_src is obtained by traversing the profile of each pending defect in the preset defect interest area, and the maximum distance of the profile of the pending defect is obtained based on the profile information. In an embodiment, the distance between any two contour points can be calculated by traversing each contour point on the contour of the undetermined defect, and the maximum distance of the contour of the defect is determined, namely, the distance between the two contour points which are farthest apart on the contour of the defect is determined to be the maximum distance of the contour of the defect; each contour upper left point may also be acquired based on contour information:
Point i .x=lnnerProfile_src[i].x;
Point i .y=lnnerProfile_src[i].y;
And coordinates of the lower right point:
Point i+n .x=lnnerProfile_src[i+n].x;
Point i+n . y =lnnerProfile_src[i+n].y;
wherein the upper left point and the lower right point are preset selection standards; by continuously adjusting the subscript of the contour points, the selected contour points are changed, and the maximum distance1 between the two contour points is calculated. Similarly, the corresponding distances of the other lens images are distance2, …, distacneN, N being the number of lens pictures taken.
And secondly, calculating the image size offset delta distance through a distance proportional relation based on the first distance, the second distance, the first contour maximum distance and the second contour maximum distance.
Finally, the focal length change corresponds to the image size offset Δdistance, that is, Δdistance is the largest actual offset in the physical size of the image. If the first distance difference between the first distance and the second distance is greater than the image size offset delta distance, it is indicated that the defect center points of the defects to be determined of any two target lens pictures are not the same defect point. Otherwise, if the first distance difference between any two target lens pictures is smaller than the image size offset, it can be determined that the defects to be determined in all the lens pictures meet the preset image size offset condition, and it can be determined that the defect center points of the defects to be determined in all the lens pictures are the same defect point.
Illustratively, the step of determining the image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance comprises:
determining a first distance sum of the first distance and the second distance;
determining a second distance sum of the first contour maximum distance and the second contour maximum distance;
determining a second distance difference between the first contour maximum distance and the second contour maximum distance;
an image size offset is determined based on a ratio between the first distance sum, the second distance sum, and the second distance difference.
In one embodiment, a first distance sum of the first distance and the second distance is determined to be D i +D j Determining a second distance sum of the first and second contour maximum distances as distance j Determining a second distance difference between the first contour maximum distance and the second contour maximum distance as a distance j-distance, and determining an image size offset Δdistance based on the ratio between the first distance and the second distance difference by a distance proportional relationship because of the size distortion of the image and the change in the focal length:
In an embodiment, to obtain a more accurate calculation result, the image size offset Δdistance is calculated by taking the average of the first distance sum, the second distance sum, and the second distance difference:
the embodiment of the application provides a method for detecting a lens defect, and before the step of determining that the suspected defect is the target defect of the lens to be detected, the method further includes:
determining gradient rectangles and outline rectangles of the suspected defects in any two target lens pictures;
determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle.
Since the image texture affects the image contrast of the region where the defect is located, after determining that the suspected defects in all the lens pictures meet the preset image size offset condition and determining that the defect center points of the suspected defects in all the lens pictures are the same defect point, the final target defect cannot be obtained directly through the image contrast determination.
Therefore, in this embodiment, first, a gradient rectangle and a contour rectangle of suspected defects in any two target lens pictures are determined, and finally, whether the suspected defects are target defects is determined based on the gradient rectangle and the contour rectangle.
The step of determining the gradient rectangle and the outline rectangle of the suspected defect in any two target lens pictures includes:
traversing pixels of the target lens picture, and determining a pixel region with a gradient change value larger than a preset second threshold value as a gradient rectangle of the suspected defect;
and carrying out binarization processing on the target lens picture, and determining that the circumscribed rectangle of the maximum black pixel connected domain is the outline rectangle of the suspected defect.
And performing n-by-n filtering on any two target lens pictures to remove interference points, traversing pixel points of each row and each column, counting gradient change information, and determining that a pixel region with a gradient change value larger than a preset second threshold value is a region where a gradient rectangle with suspected defects is located. In an embodiment, from left to right, from top to bottom, from right to left, and from bottom to top, traversing pixels of the target lens picture, determining a leftmost value left1 (a minimum horizontal coordinate of a pixel point when the gradient change value is greater than the preset second threshold) when the gradient change value is greater than the preset second threshold, a topmost value top1 (a maximum vertical coordinate of a pixel point when the gradient change value is greater than the preset second threshold), a rightmost value right1 (a maximum horizontal coordinate of a pixel point when the gradient change value is greater than the preset second threshold), and a bottommost value bottom1 (a minimum vertical coordinate of a pixel point when the gradient change value is greater than the preset second threshold), and determining rectangular regions Rect (left 1, top1, right1-left1, and bottom1-top 1) from the four points. Referring to fig. 4, the gradient rectangle determined by the gradient change value is rect1, and referring to fig. 5, the gradient rectangle determined by the gradient change value is rect2.
The target lens picture is binarized, and in one embodiment, the adaptive binarization results of fig. 4 are shown in fig. 6, and the adaptive binarization results of fig. 5 are shown in fig. 7. Then, determining that the circumscribed rectangle of the largest black pixel connected domain is a contour rectangle of a suspected defect, in an embodiment, counting black pixel points in the image after binarization processing, obtaining the largest connected domain of the black pixel points, determining that the circumscribed rectangle of fig. 6 is rect_confurs 1 through the contour of the largest black pixel connected domain, and determining that the circumscribed rectangle of fig. 7 is rect_confurs 2.
Illustratively, the step of determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle includes:
determining an intersection area of the gradient rectangle and the outline rectangle;
determining a target area between the gradient rectangle and the outline rectangle, wherein the target area is a larger value of the area of the gradient rectangle and the area of the outline rectangle;
and if the intersection ratio is greater than a preset third threshold value and the number of black pixels in the target area is greater than a preset fourth threshold value, determining the suspected defect as the target defect, wherein the intersection ratio is the ratio of the intersection area to the target area.
In one embodiment, the gradient rectangle Rect1 and the contour rectangle rect_confus1 are subjected to intersection operation, and the gradient rectangle Rect2 and the contour rectangle rect_confus2 are subjected to intersection operation, so as to obtain an intersection area between the gradient rectangle and the contour rectangle.
And determining a larger area between the gradient rectangle and the outline rectangle as a target area, and determining a ratio of an intersection area to the target area, namely determining an intersection ratio, wherein the intersection ratio represents the overlapping degree between the gradient rectangle and the outline rectangle, and the more the gradient rectangle and the outline rectangle are overlapped, the larger the intersection ratio is. In one embodiment, the rectangular area a of the gradient rectangle Rect1 of fig. 4, the rectangular area B of the contour rectangle rect_confurus 1 of fig. 6, and the intersection area of the gradient rectangle Rect1 and the contour rectangle rect_confurus 1 is C. If A is greater than B, the intersection ratio is A/C, and if B is greater than A, the intersection ratio is B/C.
If the number of black pixels in the target area is greater than the preset fourth threshold, that is, if the number of black pixels in the maximum connected domain is greater than the preset fourth threshold (the reason for being smaller than the preset fourth threshold may be misjudgment caused by image textures), and the intersection ratio is greater than the preset third threshold, the suspected defect can be determined to be the target defect, and at this time, the depth of the target defect can be determined by the image where the target defect with the maximum contrast is located.
In addition, the embodiment of the application also provides a device for detecting the lens defect, which comprises: a memory, a processor, and a computer program stored on the memory and executable on the processor, which when executed by the processor, performs the steps of the method for detecting a lens defect as described above.
Furthermore, embodiments of the present application also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method for detecting a lens defect as described above.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the conventional technology in the form of a software product stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above, including several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method described in the embodiments of the present application.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims of the present application.
Claims (10)
1. A method for detecting a lens defect, the method comprising:
Acquiring lens pictures of lenses to be detected, which are shot at a plurality of different focal lengths, and determining whether suspected defects exist in all the lens pictures or not based on image attributes of the lens pictures, wherein the image attributes comprise point position information of the lens pictures;
and if the suspected defects exist in all the lens pictures, determining that the suspected defects are target defects of the lens to be detected.
2. The method of claim 1, wherein the step of determining whether suspected defects exist in all the lens pictures based on image properties of the lens pictures comprises:
determining regional center points in the regions of interest of the preset defects of any two target lens pictures in all the lens pictures, and determining reference center points of the two target lens pictures based on the regional center points;
determining a first defect center point of a first defect to be determined in one of the target lens pictures and a second defect center point of a second defect to be determined in the other of the target lens pictures;
determining whether the undetermined defects in all the lens pictures meet a preset slope condition based on the reference center point, the first defect center point and the second defect center point, and determining whether the undetermined defects in all the lens pictures meet a preset image size offset condition;
And if the undetermined defects in all the lens pictures meet the preset slope condition and the preset image size deviation condition, determining that suspected defects exist in all the lens pictures.
3. The method for detecting lens defects according to claim 2, wherein the step of determining whether the defects to be determined in all the lens pictures satisfy a preset slope condition comprises:
determining a first slope between the reference center point and the first defect center point, a second slope between the reference center point and the second defect center point, and a third slope between the first defect center point and the second defect center point;
and when the variances among the first slope, the second slope and the third slope in the two target lens pictures are smaller than a preset first threshold value, determining that undetermined defects in all the lens pictures meet preset slope conditions.
4. The method for detecting lens defects according to claim 2, wherein the step of determining whether or not the defects to be determined in all the lens pictures satisfy a preset image size shift condition comprises:
Determining a first distance between the first defect center point and the reference center point, and a second distance between the second defect center point and the reference center point;
determining a first maximum distance of the outline of the undetermined defect in one of the target lens pictures, and a second maximum distance of the outline of the undetermined defect in the other of the target lens pictures;
determining an image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance;
and determining a first distance difference between the first distance and the second distance, and determining that undetermined defects in all the lens pictures meet a preset image size offset condition when the first distance difference of any two target lens pictures is smaller than the image size offset.
5. The method of claim 4, wherein the step of determining the image size offset based on the first distance, the second distance, the first contour maximum distance, and the second contour maximum distance comprises:
determining a first distance sum of the first distance and the second distance;
Determining a second distance sum of the first contour maximum distance and the second contour maximum distance;
determining a second distance difference between the first contour maximum distance and the second contour maximum distance;
an image size offset is determined based on a ratio between the first distance sum, the second distance sum, and the second distance difference.
6. The method of claim 1, wherein prior to the step of determining that the suspected defect is a target defect of the lens to be inspected, further comprising:
determining gradient rectangles and outline rectangles of the suspected defects in any two target lens pictures;
determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle.
7. The method for detecting a lens defect according to claim 6, wherein the step of determining gradient rectangles and contour rectangles of the suspected defect in any two target lens pictures comprises:
traversing pixels of the target lens picture, and determining a pixel region with a gradient change value larger than a preset second threshold value as a gradient rectangle of the suspected defect;
and carrying out binarization processing on the target lens picture, and determining that the circumscribed rectangle of the maximum black pixel connected domain is the outline rectangle of the suspected defect.
8. The method of claim 6, wherein the step of determining whether the suspected defect is a target defect based on the gradient rectangle and the contour rectangle comprises:
determining an intersection area of the gradient rectangle and the outline rectangle;
determining a target area between the gradient rectangle and the outline rectangle, wherein the target area is a larger value of the area of the gradient rectangle and the area of the outline rectangle;
and if the intersection ratio is greater than a preset third threshold value and the number of black pixels in the target area is greater than a preset fourth threshold value, determining the suspected defect as the target defect, wherein the intersection ratio is the ratio of the intersection area to the target area.
9. A lens defect detection apparatus, characterized in that the lens defect detection apparatus comprises: memory, a processor, and a computer program stored on the memory and executable on the processor, which when executed by the processor, performs the steps of the method for detecting a lens defect according to any one of claims 1 to 8.
10. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the steps of the method for detecting a lens defect according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310403665.6A CN116539617A (en) | 2023-04-11 | 2023-04-11 | Method, device and medium for detecting lens defect |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310403665.6A CN116539617A (en) | 2023-04-11 | 2023-04-11 | Method, device and medium for detecting lens defect |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116539617A true CN116539617A (en) | 2023-08-04 |
Family
ID=87444403
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310403665.6A Pending CN116539617A (en) | 2023-04-11 | 2023-04-11 | Method, device and medium for detecting lens defect |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116539617A (en) |
-
2023
- 2023-04-11 CN CN202310403665.6A patent/CN116539617A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110717489B (en) | Method, device and storage medium for identifying text region of OSD (on Screen display) | |
CN111612781B (en) | Screen defect detection method and device and head-mounted display equipment | |
CN114581742B (en) | Linearity-based connected domain clustering fusion method, device, system and medium | |
US8805077B2 (en) | Subject region detecting apparatus | |
US8923610B2 (en) | Image processing apparatus, image processing method, and computer readable medium | |
CN109002823B (en) | Region-of-interest determining method, device, equipment and readable storage medium | |
CN113112511B (en) | Method and device for correcting test paper, storage medium and electronic equipment | |
CN111079730A (en) | Method for determining area of sample image in interface image and electronic equipment | |
CN114419045A (en) | Method, device and equipment for detecting defects of photoetching mask plate and readable storage medium | |
CN111767752B (en) | Two-dimensional code identification method and device | |
CN107808165B (en) | Infrared image matching method based on SUSAN corner detection | |
CN109242917A (en) | One kind being based on tessellated camera resolution scaling method | |
CN116342519A (en) | Image processing method based on machine learning | |
JP6221283B2 (en) | Image processing apparatus, image processing method, and image processing program | |
CN109727193B (en) | Image blurring method and device and electronic equipment | |
CN108647680B (en) | Image positioning frame detection method and device | |
CN116539617A (en) | Method, device and medium for detecting lens defect | |
CN110310239A (en) | It is a kind of to be fitted the image processing method for eliminating illumination effect based on characteristic value | |
CN113744200B (en) | Camera dirt detection method, device and equipment | |
CN116797550A (en) | Defect detection method, device, electronic equipment and storage medium | |
CN116506591A (en) | Method and system for acquiring knife edge position during analysis force test of camera | |
CN105930813B (en) | A method of detection composes a piece of writing this under any natural scene | |
CN112529923B (en) | Control identification method and device | |
CN111091513B (en) | Image processing method, device, computer readable storage medium and electronic equipment | |
CN114723767A (en) | Stain detection method and device, electronic equipment and floor sweeping robot system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |