A lens detection method and related device

Through the lens detection method based on artificial intelligence, the lens surface texture and non-texture areas are divided, and the grayscale difference mode is used for detection, which solves the problems of slow speed and reliance on manual experience of the existing lens detection method, and achieves efficient and accurate lens defects. detection.

CN113706446BActive Publication Date: 2024-09-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110342784.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-30
Publication Date
2024-09-06
Estimated Expiration
2041-03-30

AI Technical Summary

Technical Problem

Existing lens detection methods rely on manual detection, are slow and rely on human experience, and are prone to missed detections and wrong detections. Moreover, existing threshold segmentation methods are difficult to distinguish lens regional structures and defects.

Method used

The lens detection method based on artificial intelligence is used to obtain the image to be tested and the template image, divide the texture part and the non-texture part, and use the grayscale difference mode to detect defects respectively to improve the detection accuracy.

Benefits of technology

It improves the efficiency and accuracy of lens inspection, reduces the influence of human experience, and is suitable for defect detection of various types of lenses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113706446B
    Figure CN113706446B
Patent Text Reader

Abstract

The embodiment of the present application discloses a lens detection method and related devices, which at least relate to computer vision technology in artificial intelligence. Based on texture, a target lens is divided into a first type of area and a second type of area, and a texture image to be tested, a smooth image to be tested, a template texture image and a template smooth image are determined from the image to be tested and the template image. According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, a first defect sub-region to be determined in the texture image to be tested is determined based on a grayscale difference pattern corresponding to the first type of area; and according to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image, a second defect sub-region to be determined in the smooth image to be tested is determined based on a grayscale difference pattern corresponding to the second type of area; the quality of the target lens is determined based on the first defect sub-region to be determined and the second defect sub-region to be determined, thereby realizing fault detection of the target lens and improving the accuracy of fault detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a lens detection method and related devices. Background Art

[0002] Smart terminals are generally equipped with image acquisition modules with image acquisition functions. Users can use the image acquisition modules of smart terminals (such as the front and rear cameras of mobile phones) to complete functions such as selfies and scene photography.

[0003] As a key component of the image acquisition unit, the quality of the lens will directly affect the imaging quality of the image acquisition module. Therefore, the accuracy of lens defect detection is very high, and it is necessary to avoid lenses with quality defects from being configured in smart terminals.

[0004] In the related art, lens defect detection generally adopts manual detection, which is slow and extremely dependent on human experience, and often results in missed detection and wrong detection. Summary of the invention

[0005] In order to solve the above technical problems, the present application provides a lens detection method and related devices for improving the efficiency and accuracy of lens detection.

[0006] The embodiments of the present application disclose the following technical solutions:

[0007] In one aspect, the present application provides a lens detection method, the method comprising:

[0008] Acquire an image to be tested including a target lens and a template image of the target lens;

[0009] Determine a first type of area and a second type of area of ​​the target lens, wherein the first type of area is determined based on a texture portion of the target lens, and the second type of area is determined based on a non-texture portion of the target lens;

[0010] Determine, from the image to be tested, a texture image to be tested corresponding to the first type of area and a smooth image to be tested corresponding to the second type of area, and determine, from the template image, a template texture image corresponding to the first type of area and a template smooth image corresponding to the second type of area;

[0011] According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively, determining a first undetermined defect sub-region in the texture image to be tested based on a grayscale difference pattern corresponding to the first type of region; and

[0012] According to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image respectively, a second undetermined defect sub-region in the smooth image to be tested is determined based on a grayscale difference pattern corresponding to the second type of region;

[0013] The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined.

[0014] On the other hand, the present application provides a lens detection device, the device comprising: an acquisition unit and a determination unit;

[0015] The acquisition unit is used to acquire an image to be tested including a target lens and a template image of the target lens;

[0016] The determining unit is used to determine a first type of area and a second type of area of ​​the target lens, wherein the first type of area is determined based on a texture portion of the target lens, and the second type of area is determined based on a non-texture portion of the target lens;

[0017] Determine, from the image to be tested, a texture image to be tested corresponding to the first type of area and a smooth image to be tested corresponding to the second type of area, and determine, from the template image, a template texture image corresponding to the first type of area and a template smooth image corresponding to the second type of area;

[0018] According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively, determining a first undetermined defect sub-region in the texture image to be tested based on a grayscale difference pattern corresponding to the first type of region; and

[0019] According to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image respectively, a second undetermined defect sub-region in the smooth image to be tested is determined based on a grayscale difference pattern corresponding to the second type of region;

[0020] The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined.

[0021] In another aspect, the present application provides a computer device, the device comprising a processor and a memory:

[0022] The memory is used to store program code and transmit the program code to the processor;

[0023] The processor is used to execute the method described in the above aspects according to the instructions in the program code.

[0024] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.

[0025] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method described in the above aspects.

[0026] It can be seen from the above technical scheme that when the target lens is detected for defects using the image to be tested including the target lens and the template image corresponding to the target lens, since the lens surface is generally composed of a texture part and a non-texture part, the surface physical characteristics of these two parts are very different. If the defect detection is performed according to a unified detection standard, an erroneous detection result may be obtained. Therefore, the first type of area corresponding to the texture part and the second type of area corresponding to the non-texture part in the target lens can be determined based on the texture, and targeted detection methods are adopted for different types of areas. Among them, the texture image to be tested corresponding to the first type of area and the smooth image to be tested corresponding to the second type of area are determined from the image to be tested, and the template texture image corresponding to the first type of area and the template smooth image corresponding to the second type of area are determined from the template image. For the first type of area, according to the grayscale values ​​of the pixels at the same position in the texture image to be tested and the template texture image, respectively, the first defect sub-area to be determined in the texture image to be tested is determined based on the grayscale difference mode corresponding to the first type of area. For the second type of area, according to the grayscale values ​​of the pixels at the same position in the smooth image to be tested and the template smooth image, respectively, the second defect sub-area to be determined in the smooth image to be tested is determined based on the grayscale difference mode corresponding to the second type of area. The quality of the target lens is determined based on the first defect sub-region to be determined and the second defect sub-region to be determined. Therefore, by dividing the target lens into two types of regions based on texture, defect detection is performed independently in a targeted manner for each type of region, effectively considering the impact of different types of mirror physical characteristics on defect detection, and the defect detection accuracy of both the texture part and the non-texture part is improved. Moreover, the texture-based area division can be adjusted according to the specific mirror physical composition of different lenses, which is more flexible and suitable for defect detection of various types of lenses. This reduces the proportion of human experience in defect detection and improves detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0028] Figure 1 A schematic diagram of an application scenario of a lens detection method provided in an embodiment of the present application;

[0029] Figure 2 A flowchart of a lens detection method provided in an embodiment of the present application;

[0030] Figure 3 A schematic diagram of a differential image multi-threshold segmentation provided in an embodiment of the present application;

[0031] Figure 4 A schematic diagram of processing a second undetermined defect sub-region by morphological expansion provided in an embodiment of the present application;

[0032] Figure 5 A schematic diagram of a lens detection application scenario provided in an embodiment of the present application;

[0033] Figure 6 A schematic diagram of the structure of a lens detection device provided in an embodiment of the present application;

[0034] Figure 7 A schematic diagram of the structure of a server provided in an embodiment of the present application;

[0035] Figure 8 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] The embodiments of the present application are described below in conjunction with the accompanying drawings.

[0037] In the related technologies, lens detection still mostly relies on manual detection, which has slow detection speed, poor detection consistency, and high personnel training cycle and labor cost. At present, there are also some solutions that use fixed threshold or adaptive threshold segmentation algorithm for detection, but the disadvantages are: the lens area structure texture is complex, single threshold segmentation is difficult to distinguish defects from the lens structure itself, and some parts of the lens have a lot of texture interference, and the existing threshold method is difficult to effectively segment defects.

[0038] Based on this, the embodiments of the present application provide a lens detection method and related devices for improving the efficiency and accuracy of lens detection.

[0039] The lens detection method provided in the embodiment of the present application is implemented based on artificial intelligence. Artificial Intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.

[0040] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0041] In the embodiments of the present application, the artificial intelligence technologies mainly involved include the above-mentioned computer vision technology, machine learning / deep learning and other directions.

[0042] The lens detection method provided in the present application can be applied to lens detection devices with data processing capabilities, such as terminal devices and servers. Specifically, the terminal device can be a smart phone, desktop computer, laptop computer, tablet computer, smart speaker, smart watch and other smart terminals, but is not limited thereto; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and the present application does not limit this.

[0043] The lens inspection equipment can have computer vision technology capabilities. Computer Vision Technology (CV) Computer Vision is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify, track and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, and other technologies.

[0044] The lens detection equipment can have machine learning capabilities. Machine Learning (ML) is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks.

[0045] In the lens detection method provided in the embodiment of the present application, the artificial intelligence model used mainly involves the application of computer vision technology, and the quality of the target lens in the image to be tested is determined through image processing, image recognition and other methods.

[0046] The lens detection device provided in the embodiment of the present application also has cloud computing capabilities, which use cloud computing capabilities to perform fault detection on the target lens.

[0047] In order to facilitate understanding of the technical solution of the present application, the lens detection method provided in the embodiment of the present application is introduced below in combination with actual application scenarios, taking the server as the lens detection device.

[0048] See also Figure 1 , which is a schematic diagram of an application scenario of a lens detection method provided by an embodiment of the present application. Figure 1 In the application scenario shown, the target lens is the rear camera of a smartphone, and the lens detection device described above is a server 100, which is used to determine whether the rear camera has quality problems. If it is determined that the rear camera has no quality problems, the rear camera can be installed in the smartphone later.

[0049] In order to detect whether the target lens has quality problems, a test image including the target lens is captured, and the server 100 obtains the test image and a template image of the target lens, wherein the template image is a pre-collected image including a standard lens without quality problems, and the standard lens and the target lens are of the same type of lens.

[0050] The lens surface generally includes a textured part and a non-textured part. The surface physical characteristics of these two parts are very different. If defect detection is performed according to a unified detection standard, incorrect detection results may be obtained.

[0051] In order to improve the accuracy of detection, based on the texture of the target lens, the target lens is divided into a first type of area determined based on the texture part and a second type of area determined based on the non-texture part, so that different detection standards are used for different types of areas to perform defect detection. The server 100 determines the texture image to be tested corresponding to the first type of area and the smooth image to be tested corresponding to the second type of area from the image to be tested, and determines the template texture image corresponding to the first type of area and the template smooth image corresponding to the second type of area from the template image.

[0052] The server 100 processes the corresponding images in different ways according to the characteristics of different regions. For the first type of region, according to the grayscale values ​​of the pixels at the same position in the texture image to be tested and the template texture image, respectively, the first undetermined defect sub-region in the texture image to be tested is determined based on the grayscale difference mode corresponding to the first type of region, such as the texture grayscale difference mode. For the second type of region, according to the grayscale values ​​of the pixels at the same position in the smooth image to be tested and the template smooth image, respectively, the second undetermined defect sub-region in the smooth image to be tested is determined based on the grayscale difference mode corresponding to the second type of region, such as the smooth grayscale difference mode.

[0053] The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined, such as Figure 1 In the application scenario shown, it is determined that the target lens has a quality problem based on the first defect sub-region to be determined and the second defect sub-region to be determined.

[0054] Therefore, by dividing the target lens into two types of areas based on texture, defect detection is performed independently in a targeted manner for each type of area, effectively considering the impact of different types of mirror physical characteristics on defect detection, and the defect detection accuracy of both texture and non-texture parts is improved. Moreover, the texture-based area division can be adjusted according to the specific mirror physical composition of different lenses, which is more flexible and suitable for defect detection of various types of lenses, reducing the proportion of human experience in defect detection and improving detection efficiency.

[0055] In conjunction with the accompanying drawings, a lens detection method provided in an embodiment of the present application is introduced below using a server as a lens detection device.

[0056] See also Figure 2 , which is a flow chart of a lens detection method provided by an embodiment of the present application. Figure 2 As shown, the lens detection method includes the following steps:

[0057] S201: Acquire an image to be tested including a target lens and a template image of the target lens.

[0058] The template image is an image of a standard lens without quality problems. The standard lens and the target lens are of the same type of lens. Template images of different types of standard lenses can be collected in advance to perform defect detection on different types of target lenses.

[0059] As a possible implementation method, the size of the image to be tested is the same as that of the template image. If the size of the image acquired by the server (hereinafter referred to as the preprocessed image) is larger than the size of the template image, the image positioning can be performed in the preprocessed image through a template matching method, that is, searching for a target area image in the preprocessed image, and the target area image has the same size, direction, and image elements as the template image. After successful positioning, the target area image is cut out from the preprocessed image, and the cut target area image is the image to be tested, which includes the target lens.

[0060] S202: Determine the first type of area and the second type of area of ​​the target lens.

[0061] Due to the complexity of the physical structure of the lens, different physical structures often use different materials, and different materials correspond to different textures. For example, the convex surface of the lens often uses a frosted rod, which has a lot of textures, while the end face of the lens is generally a mirror surface and is relatively smooth. Therefore, different parts of the lens correspond to different surface physical characteristics.

[0062] In related technologies, the difference image threshold segmentation technology is also used for defect detection. This method first matches and aligns the image to be tested with the template image, then calculates the absolute difference of the grayscale pixel values ​​of the aligned image to be tested and the template image - the difference image, and finally performs single threshold segmentation (unified detection standard) on the difference image to extract the defect area in the image to be tested and determine the quality of the image to be tested.

[0063] Since different parts of the target lens correspond to different surface physical features, if defect detection is performed according to the unified detection standard in the relevant technology, the detection results of some parts will be less accurate or even wrong, so that the overall detection result of the target lens is less accurate. Therefore, the target lens can be divided into two types of areas based on texture, namely the first type of area determined based on the texture part and the second type of area determined based on the non-texture part. For example, the convex surface of the target lens belongs to the first type of area, and the end face of the target lens belongs to the second type of area. Therefore, different detection methods are used for different types of areas to improve the accuracy of the detection results.

[0064] It should be noted that the embodiment of the present application does not specifically limit the number of the first type of area and the second type of area, which can be one or more. For example, the interior of the end surface can be further subdivided into multiple areas.

[0065] It should be noted that different types of lenses have different physical structures. The positions of the corresponding first and second types of areas can be determined for different physical structures. Combined with the template image corresponding to each type of lens, defect detection can be achieved for different types of lenses.

[0066] S203: Determine the texture image to be tested corresponding to the first type of area and the smooth image to be tested corresponding to the second type of area from the image to be tested, and determine the template texture image corresponding to the first type of area and the template smooth image corresponding to the second type of area from the template image.

[0067] In order to be able to perform targeted detection on the first category of areas and the second category of areas respectively, images corresponding to the first category of areas and the second category of areas in the image to be tested and the template image are obtained, that is, the texture image to be tested corresponding to the first category of areas and the smooth image to be tested corresponding to the second category of areas are determined from the image to be tested, and the template texture image corresponding to the first category of areas and the template smooth image corresponding to the second category of areas are determined from the template image.

[0068] For example, continue with Figure 1 As an example, the target lens shown in FIG. 1 includes an end face and a convex face. The convex face region A can be divided on the template image T by manual annotation or other methods. mask and end area B mask . Determine the convex area A from the image S to be tested mask The corresponding texture image S to be tested A It can be expressed as S A =S×A mask , that is, the texture image S to be tested A The convex area A in the image S to be tested mask Determine the end face area B from the image to be tested S mask The corresponding smoothed image S to be tested B It can be expressed as S B =S×B mask , that is, the smoothed image S to be tested B The end surface area B in the image S to be tested mask Determine the convex area A from the template image T mask The corresponding template texture image T A It can be expressed as T A =T×A mask , that is, the template texture image T A is the convex area A in the template image T mask Determine the end face area B from the template image T mask The corresponding template smoothed image T B It can be expressed as T B =T×B mask, that is, the template smoothed image T B The template image T is in the end surface area B mask Part of the image.

[0069] Therefore, a regional detection scheme can be used according to different image properties (smooth image, texture image), that is, different defect detection methods are adopted for the end face and convex surface of the target lens. Compared with the unified detection standard in the related art that compares the image to be tested and the template image as a whole, the embodiment of the present application refines the defect detection from image-level detection to image block-level detection through regional comparison. The defect detection schemes for each area are independent of each other, which is not only more targeted, but also improves the defect detection accuracy of different areas, and the accuracy of the overall detection result of the target lens is also improved.

[0070] S204: determining a first undetermined defect sub-region in the texture image to be tested based on a grayscale difference pattern corresponding to the first type of region according to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image respectively; and determining a second undetermined defect sub-region in the smooth image to be tested based on a grayscale difference pattern corresponding to the second type of region according to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image respectively.

[0071] After the image to be tested and the template image are partitioned according to the first type of area and the second type of area, the images corresponding to the first type of area and the second type of area are detected using different detection methods, which are described below.

[0072] (I) For the first type of area

[0073] For the texture part of the target lens, the texture image to be tested and the template texture image are compared, and the first undetermined defect sub-region in the texture image to be tested is determined by the grayscale difference mode corresponding to the first type of area, with respect to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image.

[0074] For example, a plane rectangular coordinate system is established in the upper left corners of the texture image to be tested and the template texture image, and the coordinates of the pixel representing the same position of the target lens are found in the texture image to be tested and the template texture image respectively. If the difference in the grayscale values ​​at the two coordinates is within the allowable range, then the position corresponding to the coordinate in the texture image to be tested does not have a quality problem; if the difference in the grayscale values ​​at the two coordinates exceeds the allowable range, then the position corresponding to the coordinate in the texture image to be tested may have a quality problem, thereby determining the first pending defect sub-region.

[0075] It should be noted that the embodiment of the present application does not specifically limit the position of the origin for establishing the plane rectangular coordinate system.

[0076] The grayscale difference mode of the first type of area is set for the surface physical characteristics of the texture part of the target lens, and this application does not make specific limitations on this. The following takes the grayscale difference mode of the first type of area as a difference image single threshold segmentation method as an example for explanation, see S204a1-S204a2.

[0077] S204a1: Determine the grayscale difference corresponding to the pixel according to the grayscale values ​​of the pixel at the same position in the texture image to be tested and the template texture image respectively.

[0078] S204a2: Determine a first pending defect sub-region based on a first target pixel whose grayscale difference value among pixels is greater than a texture difference threshold.

[0079] For example, Figure 1 Taking the convex area of ​​the target lens as an example, the texture image S A and the template texture image T A The grayscale value of the pixel at the same position representing the convex area is obtained, and the absolute difference between the two grayscale values ​​(the grayscale difference corresponding to a pixel) is obtained. According to the texture image S to be tested A and the template texture image T A The absolute difference of the corresponding pixels in can be used to obtain a difference image A with the same size as the template image. D , which can be expressed as A D =|T A -S A |.

[0080] Use texture difference threshold t A1 Difference graph A D Perform single threshold segmentation and transform the difference image A D Above the texture difference threshold t A1 The corresponding pixel is used as the first target pixel, the first target pixel corresponds to the texture image to be tested, and the convex defect image mask (mask) formed by the first target pixel is determined. M , the convex defect mask image A M The connected domain is determined as the first pending defect sub-region.

[0081] It should be noted that the number of the first pending defect sub-regions may be one or more, and this application does not impose any specific limitation on this.

[0082] (II) For the second type of area

[0083] For the non-texture part of the target lens, the smooth image to be tested and the template smooth image are compared, and the second undetermined defect sub-region in the texture image to be tested is determined by the grayscale difference mode corresponding to the second type of area, based on the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template smooth image.

[0084] For example, a plane rectangular coordinate system is established at the lower left corner of the smooth image to be tested and the template smooth image, and the coordinates of the pixel representing the same position of the target lens are found in the smooth image to be tested and the template smooth image respectively. If the difference in the grayscale values ​​at the two coordinates is within the allowable range, then the position corresponding to the coordinate in the smooth image to be tested has no quality problem; if the difference in the grayscale values ​​at the two coordinates exceeds the allowable range, then the position corresponding to the coordinate in the smooth image to be tested may have a quality problem and is determined to be the second defect sub-region to be determined.

[0085] The grayscale difference mode of the second type of area is set for the surface physical features of the non-texture part of the target lens, and this application does not make specific limitations on this. The grayscale difference mode of the second type of area is a difference map multi-threshold segmentation method as an example for explanation, see S204b1-S204b3.

[0086] S204b1: Determine the grayscale difference corresponding to the pixel according to the grayscale values ​​of the pixel at the same position in the smooth image to be tested and the template texture image respectively.

[0087] For example, Figure 1 Taking the end surface area of ​​the target lens shown in the figure as an example, the smooth image S B and template smoothed image T B The grayscale value of the pixel at the same position representing the end face area is obtained, and the absolute difference between the two grayscale values ​​(the grayscale difference corresponding to a pixel) is obtained. According to the smoothed image S to be tested B and template smoothed image T B The absolute difference of the corresponding pixels in can be used to obtain the difference image B with the same size as the template image. D , which can be expressed as B D =|T B -S B |.

[0088] S204b2: Determine the grayscale area where the pixel is located based on the position parameters of the pixel.

[0089] Although the non-texture area of ​​the target lens is smoother than the texture area, the grayscale values ​​of different areas in the non-texture area of ​​the target lens may be different. For example, if the end face of the target lens is composed of multiple rings, there are obvious differences in the grayscale values ​​of different ring areas in the image to be tested. If the same type of defects fall in different ring areas, the grayscale difference between them and different ring areas is also inconsistent.

[0090] like Figure 1 The target lens shown has three annular areas, see Figure 3, assuming that among the three annular areas, the grayscale mean of the area indicated by the white circle is G1, the grayscale mean of the area indicated by the striped circle is G2, and the grayscale mean of the area indicated by the black circle is G3, G1≠G2≠G3. If there is a defect with a grayscale mean of G0, then G1-G0≠G2-G0≠G3-G0. Therefore, if a uniform threshold is used for defect detection on the end face of the target lens, the detection result will be inaccurate.

[0091] Based on this, different grayscale areas can be determined based on the grayscale value distribution in the second type of area, such as determining pixels whose grayscale values ​​fall into the same interval as a grayscale area, and setting different regional differential thresholds according to the grayscale means of different grayscale areas, that is, multiple regional differential thresholds can be set according to the grayscale area. For example, if the grayscale area includes at least a first grayscale area and a second grayscale area, the regional differential threshold corresponding to the first grayscale area is different from the regional differential threshold corresponding to the second grayscale area.

[0092] For example, Figure 1 For the target lens shown in the figure, the second type of area can be divided into three grayscale areas according to the grayscale value distribution, that is, each annular area is a grayscale area, and three regional difference thresholds [t B1 , t B2 , t B3 ], t B1 ≠t B2 ≠t B3 .

[0093] Therefore, by determining the grayscale area according to the grayscale value distribution and setting different regional differential thresholds for different grayscale areas, the difference in different grayscale areas for the same defect can be reduced, thereby improving the accuracy of the detection results of each grayscale area, and then improving the accuracy of the overall detection results.

[0094] S204b3: Determine a second pending defect sub-region based on a second target pixel whose grayscale difference value is greater than the regional difference threshold corresponding to the grayscale region.

[0095] After determining the grayscale area where the pixel is located according to the pixel position parameter, if the grayscale value of the pixel is greater than the regional differential threshold corresponding to the grayscale area where the pixel is located, the pixel is used as the second target pixel, the second target pixel corresponds to the smoothed image to be tested, and the area formed by the second target pixels is the second defect sub-area to be determined.

[0096] It should be noted that the second pending defect sub-region may be one or more, and this application does not make any specific limitation on this.

[0097] For example, using three regional difference thresholds [t B1 , t B2 , tB3 ] for the difference graph B D Perform multi-threshold segmentation and divide the grayscale area above the corresponding area difference threshold t B1 The pixel point with the grayscale value higher than the corresponding regional difference threshold t is taken as the second target pixel. Similarly, the pixel point with the grayscale value higher than the corresponding regional difference threshold t B2 The pixel point with the value of t is taken as the second target pixel, and the pixel point with the value of tt in the third grayscale area that is higher than the corresponding regional difference threshold t B3 The pixel point is taken as the second target pixel, and the end face defect mask image B composed of the second target pixel is determined. M , the end face defect mask image B M The connected domain is determined as the second pending defect sub-region.

[0098] S205: Determine the quality of the target lens according to the first defect sub-region to be determined and the second defect sub-region to be determined.

[0099] For example, continue with Figure 1 Taking the target lens shown in the figure as an example, the convex surface defect mask A M And end face defect mask image B M The position of the identified target lens may have quality problems, thereby determining the quality of the target lens, such as whether there are quality problems, the position of the corresponding defects, etc.

[0100] It can be seen from the above technical scheme that when the target lens is detected for defects using the image to be tested including the target lens and the template image corresponding to the target lens, since the lens surface is generally composed of a texture part and a non-texture part, the surface physical characteristics of these two parts are very different. If the defect detection is performed according to a unified detection standard, an erroneous detection result may be obtained. Therefore, the first type of area corresponding to the texture part and the second type of area corresponding to the non-texture part in the target lens can be determined based on the texture, and targeted detection methods are adopted for different types of areas. Among them, the texture image to be tested corresponding to the first type of area and the smooth image to be tested corresponding to the second type of area are determined from the image to be tested, and the template texture image corresponding to the first type of area and the template smooth image corresponding to the second type of area are determined from the template image. For the first type of area, according to the grayscale values ​​of the pixels at the same position in the texture image to be tested and the template texture image, respectively, the first defect sub-area to be determined in the texture image to be tested is determined based on the grayscale difference mode corresponding to the first type of area. For the second type of area, according to the grayscale values ​​of the pixels at the same position in the smooth image to be tested and the template smooth image, respectively, the second defect sub-area to be determined in the smooth image to be tested is determined based on the grayscale difference mode corresponding to the second type of area. The quality of the target lens is determined based on the first defect sub-region to be determined and the second defect sub-region to be determined. Therefore, by dividing the target lens into two types of regions based on texture, defect detection is performed independently in a targeted manner for each type of region, effectively considering the impact of different types of mirror physical characteristics on defect detection, and the defect detection accuracy of both the texture part and the non-texture part is improved. Moreover, the texture-based area division can be adjusted according to the specific mirror physical composition of different lenses, which is more flexible and suitable for defect detection of various types of lenses. This reduces the proportion of human experience in defect detection and improves detection efficiency.

[0101] If there is interference from factors such as lighting in the image to be tested and the template image, the first defect sub-region to be determined and the second defect sub-region to be determined may not be real defects, which may easily lead to the problem of false detection. In order to improve the accuracy of determining the quality of the target lens, the first defect sub-region to be determined and the second defect sub-region to be determined may be further verified, which are described below.

[0102] (I) Verify the first pending defect sub-area

[0103] The first defect sub-region to be determined is determined for the texture part of the target lens. Since the texture of the texture part is irregular, the texture of the same type of lens may be different even at the same position. Therefore, for the same position of the target lens, due to the difference in texture between the texture image to be tested and the template texture image, the position in the texture image to be tested may be identified as a defect.

[0104] Based on this, the embodiment of the present application proposes to perform a secondary comparison based on image features to reduce the false recognition rate of defects, see S301-S303 for details.

[0105] S301: Determine a first region image feature of a first undetermined defect subregion and a second region image feature of a region corresponding to the first undetermined defect subregion in a template texture image.

[0106] The first undetermined defect sub-region is a partial region in the texture image to be tested, a first region image feature of the partial region is obtained, and a second region image feature of a position corresponding to the partial region in the template texture image is obtained.

[0107] The embodiment of the present application does not specifically limit the first region image feature and the second region image feature, and may be a texture feature, a pixel feature, etc. The first region image feature and the second region image feature belong to the same feature.

[0108] S302: Determine a first real defect sub-region in a first pending defect sub-region according to a feature difference between the first region image feature and the second region image feature.

[0109] The following description is made by taking the first region image feature and the second region image feature as Local Binary Pattern (LBP) features as an example, see S3021-S3023. Among them, LBP features are an operator used to describe local texture features of an image, a type of texture feature, and have significant advantages such as rotation invariance and grayscale invariance.

[0110] S3021: Determine a first texture feature histogram corresponding to the image feature of the first region, and a second texture feature histogram corresponding to the image feature of the second region.

[0111] For example, continue with Figure 1 Taking the target lens shown in FIG. 1 as an example, the texture image S to be tested is obtained through S301. A The first region image feature is the feature map S A-LBP , and the template texture image T A The second region image feature is the feature map T A-LBP .

[0112] If the first defect sub-region to be determined is one, obtain S A-LBP The corresponding histogram (first texture feature histogram), and T A-LBP The corresponding histogram (second texture feature histogram).

[0113] If there are multiple first defect sub-regions to be determined, the multiple first defect sub-regions to be determined constitute a first defect sub-region set A to be determined. M-array , then calculate AM-array Each first undetermined defect sub-region corresponds to S A-LBP The histogram of the texture image to be tested is normalized to obtain the first region image feature set S corresponding to the texture image to be tested. H-array Similarly, calculate A M-array Each first undetermined defect sub-region corresponds to T A-LBP The histogram of the template texture image is normalized to obtain the first region image feature set T corresponding to the template texture image. H-array .

[0114] It should be noted that a first undetermined defect sub-region may be divided into multiple regions, and the first texture feature histogram and the second texture feature histogram may be determined according to the multiple divided first undetermined defect sub-regions, so that subsequent detection may be more accurate.

[0115] S3022: Determine a texture feature difference according to the first texture feature histogram and the second texture feature histogram.

[0116] For example, use the OpenCV (Open Source Computer Vision Library, a cross-platform computer vision library) function compareHist() to calculate T H-array and S H-array The difference of each corresponding histogram in is determined as the texture feature difference.

[0117] S3023: Determine the first undetermined defect sub-region whose texture feature difference is greater than the texture threshold as the first real defect sub-region.

[0118] For example, if the texture feature difference is greater than the texture threshold t A2 , indicating that in the texture image S to be tested A In the example, the first undetermined defect sub-region corresponding to the texture feature difference is a real defect region and is determined to be the first real defect sub-region.

[0119] If multiple first real defect sub-regions are obtained, multiple first undetermined defect sub-regions can be superimposed to obtain the convex surface real defect mask image A of the target lens. M-ture .

[0120] S303: Determine the quality of the target lens according to the first real defect sub-region and the second to-be-determined defect sub-region.

[0121] Thus, a more realistic first real defect sub-region is determined from the first to-be-determined defect sub-region. Compared with determining the quality of the target lens based on the first to-be-determined defect sub-region and the second to-be-determined defect sub-region, the accuracy of determining the quality of the target lens based on the first real defect sub-region and the second to-be-determined defect sub-region is improved.

[0122] (II) Verify the second pending defect sub-area

[0123] The second undetermined defect sub-region is determined for the non-texture part of the target lens, and its corresponding second undetermined defect sub-region may also have the problem of misdetection. Based on this, the embodiment of the present application proposes to perform a secondary comparison according to image features to reduce the misrecognition rate of defects. For details, see S401-S404.

[0124] S401: Determine a third region image feature of a second defect sub-region to be determined, and a fourth region image feature of a region corresponding to the second defect sub-region to be determined in a template smoothed image.

[0125] The second undetermined defect sub-region is a partial region in the smooth image to be tested, and the third region image feature of the partial region is obtained, and the fourth region image feature of the position corresponding to the partial region in the template smooth image is obtained.

[0126] The embodiment of the present application does not specifically limit the third region image feature and the fourth region image feature, which may be a texture feature, a pixel feature, etc. The third region image feature and the fourth region image feature belong to the same feature.

[0127] S402: Determine a cross-correlation difference parameter of a second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fourth region.

[0128] The following description is made by taking the third region image feature and the fourth region image feature as pixel mean as an example, wherein the pixel mean is a type of pixel feature.

[0129] For example, if the second defect sub-region to be determined is one, the pixel mean of the second defect sub-region to be determined and the pixel mean of the region corresponding to the second defect sub-region to be determined in the template smoothed image are obtained through S401, and the absolute difference between the two pixel means (a characteristic mean difference) is the cross-correlation difference parameter.

[0130] If there are multiple second defect sub-regions to be determined, the multiple second defect sub-regions to be determined constitute a second defect sub-region set B M-array , then calculate B M-array Each second pending defect sub-region corresponds to S B The pixel mean value is obtained to obtain the third region image feature set S corresponding to the smoothed image to be tested. mean-array Similarly, calculate B M-array Each second undetermined defect sub-region corresponds to T B The pixel mean of the template smoothed image is obtained by taking the third region image feature set T mean-array Finally, calculate S mean-array and Tmean-array The absolute difference of each corresponding pixel mean in , and multiple cross-correlation difference parameters D are obtained. c , which can be expressed as D c =|T mean-array -S mean-array |.

[0131] It should be noted that, a second undetermined defect sub-region may be divided into multiple sub-regions, and the cross-correlation difference parameters of the second undetermined defect sub-region may be determined according to the multiple divided sub-regions, so that subsequent detection may be more accurate.

[0132] S403: Determine a second real defect sub-region in the second pending defect sub-region by using the cross-correlation difference parameter.

[0133] For example, if the cross-correlation difference parameter is greater than a preset threshold, the second undetermined defect sub-region corresponding to the cross-correlation difference parameter is a real defect region and is determined to be the second real defect sub-region.

[0134] It should be noted that compared with the texture part, the non-texture part is more affected by lighting. If the smooth image to be tested and the template smooth image are not obtained under the same lighting conditions, for example, the image to be tested is taken when the light source is directly above the target lens, and the template image is taken when the light source is above the right of the standard lens. At this time, the reflective area of ​​the light source for the smooth image to be tested and the template smooth image is different. When comparing according to the template smooth image, the area affected by lighting in the smooth image to be tested (such as the reflective area) may be identified as a defect.

[0135] Based on this, the embodiment of the present application proposes to compare with the surrounding pixels to find the area affected by the lighting in the smooth image to be tested, remove the influence of this part of the area on defect recognition, thereby reducing the false recognition rate of defects, see S4031-S4034 for details.

[0136] S4031: Based on the morphological expansion processing of the second defect sub-region to be determined, determine the peripheral area of ​​the second defect sub-region to be determined.

[0137] See also Figure 4 , which is a schematic diagram of a second undetermined defect sub-region processed by morphological dilation provided by an embodiment of the present application. The second undetermined defect sub-region is a spot region, and the peripheral region of the second undetermined defect sub-region is a white region around the spot region. Through morphological dilation processing, the peripheral region of the second undetermined defect sub-region is obtained, so that the second undetermined defect sub-region can be compared with its peripheral region to determine whether the second undetermined sub-region is affected by light.

[0138] S4032: Determine the fifth area image feature of the surrounding area.

[0139] The embodiment of the present application does not specifically limit the fifth region image feature, which may be a texture feature, a pixel feature, etc. The fifth region image feature and the third region image feature belong to the same feature.

[0140] S4033: Determine the autocorrelation difference parameter of the second to-be-determined defect sub-region according to the feature difference between the image feature of the third region and the image feature of the fifth region.

[0141] The image performance of the area affected by light is generally similar. For example, the image of the illuminated area appears as a light spot, and the pixels corresponding to the area have a regular pattern. Therefore, the current pixel and the surrounding pixels of the second undetermined defect sub-area can be compared. If they are similar, the current pixel may be affected by light, and the corresponding area is not a real defect; if they are not similar, the current pixel is not affected by light, and the corresponding area is a real defect.

[0142] Taking the image feature of the fifth area as the pixel mean as an example, if the second defect sub-area to be determined is obtained as one, the pixel mean of the second defect sub-area to be determined and the pixel mean of the surrounding area of ​​the second defect sub-area to be determined are obtained, and the absolute difference between the two pixel means (a feature mean difference) is the autocorrelation difference parameter.

[0143] If there are multiple second defect sub-regions to be determined, morphological dilation processing is performed on each second defect sub-region to be determined in step S4031, and the surrounding area of ​​each second defect sub-region to be determined is extracted to obtain a dilated area set B consisting of the surrounding areas of multiple second defect sub-regions to be determined. dilated-array Calculate B dilated-array The surrounding area of ​​each second undetermined defect sub-area corresponds to S B The pixel mean value is obtained to obtain the fifth region image feature set S corresponding to the smoothed image to be tested. dilated-mean-array , and finally calculate S mean-array and S dilated-mean-array The absolute difference of each corresponding pixel mean in , and multiple autocorrelation difference parameters D are obtained. s , which can be expressed as D s =|S mean-array -S dilated-mean-array |.

[0144] It should be noted that, a second undetermined defect sub-region may be divided into multiple sub-regions, and the autocorrelation difference parameter of the second undetermined defect sub-region may be determined according to the multiple divided sub-regions, so that subsequent detection may be more accurate.

[0145] S4034: Determine a second real defect sub-region in the second pending defect sub-region by using the cross-correlation difference parameter and the autocorrelation difference parameter.

[0146] The cross-correlation difference parameters are determined by comparing the smoothed image to be tested with the template smoothed image, and the autocorrelation difference parameters are determined by performing neighborhood comparison between the current pixel and the pixels in the surrounding area. The second real defect sub-area is determined by combining the cross-correlation difference parameters and the autocorrelation difference parameters, so that accurate and stable defect detection can be performed under changing lighting conditions.

[0147] For example, according to the cross-correlation difference parameter D c and the autocorrelation difference parameter D s The comprehensive difference parameter D can be obtained, which can be expressed as D = ω1 × D c +ω2×D s , where ω1 and ω2 are the weight coefficients of the cross-correlation difference parameter and the autocorrelation difference parameter. When the comprehensive difference parameter is greater than the threshold t B4 When , it means that in the smooth image S B In the example, the second undetermined defect sub-region corresponding to the comprehensive difference parameter is a real defect region and is determined to be the second real defect sub-region.

[0148] If multiple second real defect sub-regions are obtained, multiple second undetermined defect sub-regions can be superimposed to obtain the end face real defect mask image B of the target lens. M-ture .

[0149] Therefore, the cross-correlation difference parameter represents local information, the autocorrelation difference parameter represents global information, and the comprehensive difference parameter achieves the purpose of integrating global information and local information by giving different weights to the cross-correlation difference parameter and the autocorrelation difference parameter. In the case of changing illumination, such as when the smoothed image to be tested and the template smoothed image are not obtained under the same illumination conditions, accurate and stable defect detection can be performed.

[0150] S404: Determine the quality of the target lens according to the first pending defect sub-region and the second real defect sub-region.

[0151] Thus, a more realistic second real defect sub-region is determined from the second pending defect sub-region. Compared with determining the quality of the target lens based on the first pending defect sub-region and the second pending defect sub-region, the accuracy of determining the quality of the target lens based on the first pending defect sub-region and the second real defect sub-region is improved.

[0152] It should be noted that a relatively real first real defect sub-region can be determined from the first undetermined defect sub-region through S301-S303, and a relatively real second real defect sub-region can be determined from the second undetermined defect sub-region through S401-S404. The quality of the target lens is determined based on the first real defect sub-region and the second real defect sub-region, thereby further improving the accuracy of detection.

[0153] For example, defect detection is performed on the end face and convex surface of the target lens respectively, and the detection results are superimposed to obtain the defect detection result S of the target lens. M , which can be expressed as S M =A M-ture +B M-ture Then, the defects of the target lens are morphologically analyzed, and the defects with smaller areas are filtered out to obtain the final defect detection result S M .

[0154] Next, the lens detection method provided in the embodiment of the present application is described by taking the target lens as the rear camera in a smartphone as an example.

[0155] Today, the smartphone market is huge, and the photography function of smartphones is highly valued as one of the core functions. As a key component of the image acquisition module, the lens of a smartphone directly affects the imaging quality of the lens, so it is very important to inspect the quality of the lens and ensure the yield rate.

[0156] In related technologies, deep learning-based defect segmentation technology is also used. Specific segmentation methods include Pyramid Scene Parsing Network (PSPNet), Unified Perceptual Parsing Network (UperNet) and High-Resoultion Net (HRNet). This type of method collects a large amount of image data and marks the defect area, then trains the above segmentation model based on this marked data, and finally uses the trained segmentation model to perform defect segmentation detection on the image to be inspected. However, it requires the collection and annotation of a large amount of image data in advance. In many industrial scenarios, the number of defective products is generally small, so cumulative collection is required, which is often time-consuming and labor-intensive and will extend the development cycle.

[0157] The method provided in the embodiment of the present application does not involve a deep learning model, does not require a large amount of labeled data, can be quickly put online for use and iteration, and is applicable to any hardware environment that can perform image processing. Detailed description is given below.

[0158] See also Figure 5 , which is a schematic diagram of a lens detection application scenario provided by an embodiment of the present application. Figure 5 In the application scenario shown, the target lens is a rear camera, and the rear camera includes a convex area and an end area, wherein the convex area belongs to the first type of area, and the end area belongs to the second type of area.

[0159] S1: Acquire the image of the rear camera to be detected.

[0160] S2: For the rear camera to be detected, obtain the image to be tested and the template image, and determine the convex area and the end area of ​​the rear camera.

[0161] The template image can be a template image of a single defect-free standard lens collected by the user. The detection mask area is marked in the template image. The detection mask area includes the convex area, the end area, and the multi-threshold area of ​​the end area. Then, relevant parameters are configured, such as the detection mode and threshold, so that defect detection can be completed for the image of the online rear camera.

[0162] S3: Image positioning.

[0163] Based on the detection mask area of ​​the template image, the texture image to be tested, the smooth image to be tested, the template texture image and the template smooth image are located through the image.

[0164] S4: Comparative testing by region.

[0165] Through regional comparison and detection, the defect detection schemes in each area are independent of each other, making defect detection more targeted and flexible from image-level detection to image block-level detection. Among them, the smooth end face area uses pixel features - pixel mean, and the convex area with rich textures uses texture features - LBP features.

[0166] S5: For the convex area, a difference image single threshold segmentation method is used to determine the first undetermined defect sub-area.

[0167] The single threshold segmentation method of the difference image can refer to the aforementioned S204a1-S204a2.

[0168] S6: Perform secondary comparison through LBP feature differences to obtain the first real defect sub-region.

[0169] The specific method for determining the first real defect sub-region may refer to the aforementioned S301-S302.

[0170] S7: For the end face area, a second defect sub-area to be determined is determined by using a differential image multi-threshold segmentation method.

[0171] Among them, the difference image multi-threshold segmentation method can refer to the aforementioned S204b1-S204b3.

[0172] By using a multi-threshold segmentation method, different regional difference thresholds are configured for different grayscale areas, thereby improving the segmentation accuracy of the rear camera under conditions of diverse grayscale distribution.

[0173] S8: Obtain a second real defect sub-region through the cross-correlation difference parameter and the autocorrelation difference parameter.

[0174] The method for determining the cross-correlation difference parameter can refer to the aforementioned S401-S402, the method for determining the autocorrelation difference parameter can refer to the aforementioned S4031-S4033, and the method for determining the second real defect sub-region by combining the cross-correlation difference parameter and the autocorrelation difference parameter can refer to the aforementioned S4034.

[0175] S9: Obtain the test result.

[0176] Thus, the first real defect sub-region can be determined from the first pending defect sub-region, and the second real defect sub-region can be determined from the second pending defect sub-region. The defect detection result determined based on the first real defect sub-region and the second real defect sub-region has a higher accuracy rate. Moreover, the technical solution of the present application can be quickly migrated and applied to the defect detection tasks of lenses required by different models of smartphones, so that in the lens detection link of the image acquisition module production line, lens defect automatic detection can be carried out efficiently and comprehensively, the lens quality of smartphones can be strictly controlled, and the efficiency of the smartphone image acquisition module industrial assembly line can be effectively improved.

[0177] In view of the lens detection method provided in the above embodiment, an embodiment of the present application also provides a lens detection device.

[0178] See also Figure 6 , which is a schematic diagram of the structure of a lens detection device provided in an embodiment of the present application. Figure 6 As shown, the lens detection device 600 includes: an acquisition unit 601 and a determination unit 602;

[0179] The acquisition unit 601 is used to acquire an image to be tested including a target lens and a template image of the target lens;

[0180] The determining unit 602 is used to determine a first type of area and a second type of area of ​​the target lens, wherein the first type of area is determined based on a texture portion of the target lens, and the second type of area is determined based on a non-texture portion of the target lens;

[0181] Determine, from the image to be tested, a texture image to be tested corresponding to the first type of area and a smooth image to be tested corresponding to the second type of area, and determine, from the template image, a template texture image corresponding to the first type of area and a template smooth image corresponding to the second type of area;

[0182] According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively, determining a first undetermined defect sub-region in the texture image to be tested based on a grayscale difference pattern corresponding to the first type of region; and

[0183] According to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image respectively, a second undetermined defect sub-region in the smooth image to be tested is determined based on a grayscale difference pattern corresponding to the second type of region;

[0184] The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined.

[0185] As a possible implementation manner, the determining unit 602 is configured to:

[0186] Determine the grayscale difference corresponding to the pixel according to the grayscale values ​​of the pixel at the same position in the texture image to be tested and the template texture image respectively;

[0187] The first to-be-determined defect sub-region is determined based on a first target pixel whose grayscale difference among the pixels is greater than a texture difference threshold.

[0188] As a possible implementation manner, the determining unit 602 is configured to:

[0189] Determine the grayscale difference corresponding to the pixel according to the grayscale values ​​of the pixel at the same position in the smooth image to be tested and the template texture image respectively;

[0190] Determining the grayscale region where the pixel is located according to the position parameter of the pixel, wherein the grayscale region is determined based on the grayscale value distribution in the second type of region;

[0191] The second to-be-determined defect sub-region is determined based on a second target pixel whose grayscale difference in the pixel is greater than a regional difference threshold corresponding to the grayscale region in which the pixel is located.

[0192] As a possible implementation manner, based on the target lens, the grayscale area includes at least a first grayscale area and a second grayscale area, and a regional difference threshold corresponding to the first grayscale area is different from a regional difference threshold corresponding to the second grayscale area.

[0193] As a possible implementation manner, the determining unit 602 is configured to:

[0194] Determine a first region image feature of the first undetermined defect subregion and a second region image feature of a region corresponding to the first undetermined defect subregion in the template texture image;

[0195] Determine a first real defect sub-region in the first pending defect sub-region according to a feature difference between the first region image feature and the second region image feature;

[0196] The quality of the target lens is determined according to the first real defect sub-region and the second pending defect sub-region.

[0197] As a possible implementation manner, the first region image feature and the second region image feature are texture features, and the determining unit 602 is configured to:

[0198] Determine a first texture feature histogram corresponding to the image features of the first region, and a second texture feature histogram corresponding to the image features of the second region;

[0199] determining a texture feature difference according to the first texture feature histogram and the second texture feature histogram;

[0200] The first undetermined defect sub-region whose texture feature difference is greater than the texture threshold is determined as the first real defect sub-region.

[0201] As a possible implementation manner, the determining unit 602 is configured to:

[0202] Determine a third region image feature of the second undetermined defect sub-region and a fourth region image feature of a region corresponding to the second undetermined defect sub-region in the template smoothed image;

[0203] Determining a cross-correlation difference parameter of the second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fourth region;

[0204] Determine a second real defect sub-region in the second undetermined defect sub-region by using the cross-correlation difference parameter;

[0205] The quality of the target lens is determined according to the first pending defect sub-region and the second real defect sub-region.

[0206] As a possible implementation, the lens detection device 600 is further used for:

[0207] Determine a peripheral region of the second undetermined defect subregion based on a morphological dilation process of the second undetermined defect subregion;

[0208] determining a fifth area image feature of the peripheral area;

[0209] Determining an autocorrelation difference parameter of the second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fifth region;

[0210] The determining unit 602 is configured to:

[0211] A second real defect sub-region in the second pending defect sub-region is determined by using the cross-correlation difference parameter and the autocorrelation difference parameter.

[0212] As a possible implementation manner, the third region image feature, the fourth region image feature and the fifth region image feature are pixel means; and the determining unit 602 is configured to:

[0213] determining a feature mean difference between the third region image feature and the fourth region image feature as the cross-correlation difference parameter; and

[0214] A feature mean difference between the third region image feature and the fifth region image feature is determined as the autocorrelation difference parameter.

[0215] The lens detection device provided by the embodiment of the present application performs defect detection on the target lens using an image to be tested including the target lens and a template image corresponding to the target lens. Since the lens surface is generally composed of a texture part and a non-texture part, the surface physical characteristics of these two parts are very different. If the defect detection is performed according to a unified detection standard, an erroneous detection result may be obtained. Therefore, the first type of area corresponding to the texture part and the second type of area corresponding to the non-texture part in the target lens can be determined based on the texture, and targeted detection methods are adopted for different types of areas. Among them, the texture image to be tested corresponding to the first type of area and the smooth image to be tested corresponding to the second type of area are determined from the image to be tested, and the template texture image corresponding to the first type of area and the template smooth image corresponding to the second type of area are determined from the template image. For the first type of area, according to the grayscale values ​​of the pixels at the same position in the texture image to be tested and the template texture image respectively, the first defect sub-area to be determined in the texture image to be tested is determined based on the grayscale difference mode corresponding to the first type of area. For the second type of area, according to the grayscale values ​​of the pixels at the same position in the smooth image to be tested and the template smooth image respectively, the second defect sub-area to be determined in the smooth image to be tested is determined based on the grayscale difference mode corresponding to the second type of area. The quality of the target lens is determined based on the first defect sub-region to be determined and the second defect sub-region to be determined. Therefore, by dividing the target lens into two types of regions based on texture, defect detection is performed independently in a targeted manner for each type of region, effectively considering the impact of different types of mirror physical characteristics on defect detection, and the defect detection accuracy of both the texture part and the non-texture part is improved. Moreover, the texture-based area division can be adjusted according to the specific mirror physical composition of different lenses, which is more flexible and suitable for defect detection of various types of lenses. This reduces the proportion of human experience in defect detection and improves detection efficiency.

[0216] The lens detection device described above may be a computer device, which may be a server or a terminal device. The computer device provided in the embodiment of the present application will be introduced from the perspective of hardware entity. Figure 7 The following is a schematic diagram of the server structure. Figure 8 Shown is a schematic diagram of the structure of the terminal equipment.

[0217] See also Figure 7 , Figure 7 14 is a schematic diagram of a server structure provided in an embodiment of the present application. The server 1400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1422 (for example, one or more processors) and memory 1432, and one or more storage media 1430 (for example, one or more mass storage devices) storing application programs 1442 or data 1444. Among them, the memory 1432 and the storage medium 1430 may be short-term storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1422 may be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the server 1400.

[0218] The server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or one or more operating systems 1441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0219] The steps performed by the server in the above embodiment can be based on the Figure 7 The server structure shown.

[0220] The CPU 1422 is used to perform the following steps:

[0221] Acquire an image to be tested including a target lens and a template image of the target lens;

[0222] Determine a first type of area and a second type of area of ​​the target lens, wherein the first type of area is determined based on a texture portion of the target lens, and the second type of area is determined based on a non-texture portion of the target lens;

[0223] Determine, from the image to be tested, a texture image to be tested corresponding to the first type of area and a smooth image to be tested corresponding to the second type of area, and determine, from the template image, a template texture image corresponding to the first type of area and a template smooth image corresponding to the second type of area;

[0224] According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively, determining a first undetermined defect sub-region in the texture image to be tested based on a grayscale difference pattern corresponding to the first type of region; and

[0225] According to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image respectively, a second undetermined defect sub-region in the smooth image to be tested is determined based on a grayscale difference pattern corresponding to the second type of region;

[0226] The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined.

[0227] Optionally, the CPU 1422 may also execute the method steps of any specific implementation of the lens detection method in the embodiments of the present application.

[0228] See also Figure 8 , Figure 8 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 8 The block diagram shows a partial structure of a smart phone related to a terminal device provided in an embodiment of the present application, and the smart phone includes: a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art can understand that Figure 8 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0229] Combine the following Figure 8 A detailed introduction to the various components of a smartphone:

[0230] The RF circuit 1510 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 1580 for processing; in addition, the designed uplink data is sent to the base station. Usually, the RF circuit 1510 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, referred to as LNA), a duplexer, etc. In addition, the RF circuit 1510 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0231] The memory 1520 can be used to store software programs and modules. The processor 1580 implements various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 1520. The memory 1520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, a phone book, etc.), etc. In addition, the memory 1520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0232] The input unit 1530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the smart phone. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532. The touch panel 1531, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 1531 or near the touch panel 1531 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 1531 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1580, and can receive and execute the command sent by the processor 1580. In addition, the touch panel 1531 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 1531, the input unit 1530 may also include other input devices 1532. Specifically, other input devices 1532 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.

[0233] The display unit 1540 may be used to display information input by the user or information provided to the user and various menus of the smartphone. The display unit 1540 may include a display panel 1541. Optionally, the display panel 1541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Further, the touch panel 1531 may cover the display panel 1541. When the touch panel 1531 detects a touch operation on or near it, it is transmitted to the processor 1580 to determine the type of touch event. Subsequently, the processor 1580 provides a corresponding visual output on the display panel 1541 according to the type of touch event. Although in Figure 8 In the embodiment, the touch panel 1531 and the display panel 1541 are used as two independent components to implement the input and output functions of the smartphone, but in some embodiments, the touch panel 1531 and the display panel 1541 can be integrated to implement the input and output functions of the smartphone.

[0234] The smartphone may also include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1541 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1541 and / or the backlight when the smartphone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the smartphone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in smartphones, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

[0235] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between the user and the smartphone. The audio circuit 1560 can transmit the received audio data to the speaker 1561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1560 and converted into audio data, and then the audio data is output to the processor 1580 for processing, and then sent to another smartphone through the RF circuit 1510, or the audio data is output to the memory 1520 for further processing.

[0236] WiFi is a short-range wireless transmission technology. Smartphones can help users send and receive emails, browse web pages, and access streaming media through WiFi modules 1570. It provides users with wireless broadband Internet access. Figure 8 A WiFi module 1570 is shown, but it is understandable that it is not an essential component of the smartphone and can be omitted as needed without changing the essence of the invention.

[0237] The processor 1580 is the control center of the smartphone, which uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in the memory 1520, and calling data stored in the memory 1520. Optionally, the processor 1580 may include one or more processing units; preferably, the processor 1580 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1580.

[0238] The smart phone also includes a power supply 1590 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption management.

[0239] Although not shown, the smartphone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0240] In the embodiment of the present application, the memory 1520 included in the smart phone can store program codes and transmit the program codes to the processor.

[0241] The processor 1580 included in the smart phone can execute the lens detection method provided in the above embodiment according to the instructions in the program code.

[0242] The embodiment of the present application further provides a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute the lens detection method provided in the above embodiment.

[0243] The embodiment of the present application also provides a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the lens detection method provided in various optional implementations of the above aspects.

[0244] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the above-mentioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the above-mentioned storage medium can be at least one of the following media: read-only memory (English: read-only memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store program codes.

[0245] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0246] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A lens detection method, characterized in that: The method comprises: Acquire an image to be tested including a target lens and a template image of the target lens; Determine a first type of area and a second type of area of ​​the target lens, wherein the first type of area is determined based on a texture portion of the target lens, and the second type of area is determined based on a non-texture portion of the target lens; Determine, from the image to be tested, a texture image to be tested corresponding to the first type of area and a smooth image to be tested corresponding to the second type of area, and determine, from the template image, a template texture image corresponding to the first type of area and a template smooth image corresponding to the second type of area; According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively, a first undetermined defect sub-region in the texture image to be tested is determined based on a grayscale difference pattern corresponding to the first type of region, including: determining the grayscale difference corresponding to the pixel according to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively; determining the first undetermined defect sub-region based on a first target pixel whose grayscale difference in the pixel is greater than a texture difference threshold; and According to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image, respectively, a second undetermined defect sub-region in the smooth image to be tested is determined based on a grayscale difference mode corresponding to the second type of region, including: determining the grayscale difference corresponding to the pixel according to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image, respectively; determining the grayscale region in which the pixel is located according to the position parameter of the pixel, the grayscale region being determined based on the grayscale value distribution in the second type of region; determining the second undetermined defect sub-region based on a second target pixel whose grayscale difference in the pixel is greater than a regional differential threshold corresponding to the grayscale region in which the pixel is located; The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined.

2. The method according to claim 1, characterized in that Based on the target lens, the grayscale area includes at least a first grayscale area and a second grayscale area, and a regional difference threshold corresponding to the first grayscale area is different from a regional difference threshold corresponding to the second grayscale area.

3. The method according to claim 1, characterized in that The determining the quality of the target lens according to the first defect sub-region to be determined and the second defect sub-region to be determined includes: Determine a first region image feature of the first undetermined defect subregion and a second region image feature of a region corresponding to the first undetermined defect subregion in the template texture image; Determine a first real defect sub-region in the first pending defect sub-region according to a feature difference between the first region image feature and the second region image feature; The quality of the target lens is determined according to the first real defect sub-region and the second pending defect sub-region.

4. The method according to claim 3, characterized in that The first region image feature and the second region image feature are texture features, and determining the first real defect sub-region in the first pending defect sub-region according to the feature difference between the first region image feature and the second region image feature includes: Determine a first texture feature histogram corresponding to the image features of the first region, and a second texture feature histogram corresponding to the image features of the second region; determining a texture feature difference according to the first texture feature histogram and the second texture feature histogram; The first undetermined defect sub-region whose texture feature difference is greater than the texture threshold is determined as the first real defect sub-region.

5. The method according to claim 1 or 2, characterized in that: The determining the quality of the target lens according to the first defect sub-region to be determined and the second defect sub-region to be determined includes: Determine a third region image feature of the second undetermined defect sub-region and a fourth region image feature of a region corresponding to the second undetermined defect sub-region in the template smoothed image; Determining a cross-correlation difference parameter of the second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fourth region; Determine a second real defect sub-region in the second undetermined defect sub-region by using the cross-correlation difference parameter; The quality of the target lens is determined according to the first pending defect sub-region and the second real defect sub-region.

6. The method according to claim 5, characterized in that The method further comprises: Determine a peripheral region of the second undetermined defect subregion based on a morphological dilation process of the second undetermined defect subregion; determining a fifth area image feature of the peripheral area; Determining an autocorrelation difference parameter of the second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fifth region; The determining, by using the cross-correlation difference parameter, a second real defect sub-region in the second pending defect sub-region comprises: A second real defect sub-region in the second pending defect sub-region is determined by using the cross-correlation difference parameter and the autocorrelation difference parameter.

7. The method according to claim 6, characterized in that The third region image feature, the fourth region image feature and the fifth region image feature are pixel means; and determining the cross-correlation difference parameter of the second to-be-determined defect sub-region according to the feature difference between the third region image feature and the fourth region image feature comprises: Determine a feature mean difference between the third region image feature and the fourth region image feature as the cross-correlation difference parameter; The step of determining the autocorrelation difference parameter of the second to-be-determined defect sub-region according to the feature difference between the image feature of the third region and the image feature of the fifth region includes: A feature mean difference between the third region image feature and the fifth region image feature is determined as the autocorrelation difference parameter.

8. A lens detection device, characterized in that: The device comprises: an acquisition unit and a determination unit; The acquisition unit is used to acquire an image to be tested including a target lens and a template image of the target lens; The determining unit is used to determine a first type of area and a second type of area of ​​the target lens, wherein the first type of area is determined based on a texture portion of the target lens, and the second type of area is determined based on a non-texture portion of the target lens; Determine, from the image to be tested, a texture image to be tested corresponding to the first type of area and a smooth image to be tested corresponding to the second type of area, and determine, from the template image, a template texture image corresponding to the first type of area and a template smooth image corresponding to the second type of area; According to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively, a first undetermined defect sub-region in the texture image to be tested is determined based on a grayscale difference pattern corresponding to the first type of region, including: determining the grayscale difference corresponding to the pixel according to the grayscale values ​​of pixels at the same position in the texture image to be tested and the template texture image, respectively; determining the first undetermined defect sub-region based on a first target pixel whose grayscale difference in the pixel is greater than a texture difference threshold; and According to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image, respectively, a second undetermined defect sub-region in the smooth image to be tested is determined based on a grayscale difference mode corresponding to the second type of region, including: determining the grayscale difference corresponding to the pixel according to the grayscale values ​​of pixels at the same position in the smooth image to be tested and the template texture image, respectively; determining the grayscale region in which the pixel is located according to the position parameter of the pixel, the grayscale region being determined based on the grayscale value distribution in the second type of region; determining the second undetermined defect sub-region based on a second target pixel whose grayscale difference in the pixel is greater than a regional differential threshold corresponding to the grayscale region in which the pixel is located; The quality of the target lens is determined according to the first defect sub-region to be determined and the second defect sub-region to be determined.

9. The device according to claim 8, characterized in that Based on the target lens, the grayscale area includes at least a first grayscale area and a second grayscale area, and a regional difference threshold corresponding to the first grayscale area is different from a regional difference threshold corresponding to the second grayscale area.

10. The device according to claim 8, characterized in that The determining unit is used for: Determine a first region image feature of the first undetermined defect subregion and a second region image feature of a region corresponding to the first undetermined defect subregion in the template texture image; Determine a first real defect sub-region in the first pending defect sub-region according to a feature difference between the first region image feature and the second region image feature; The quality of the target lens is determined according to the first real defect sub-region and the second pending defect sub-region.

11. The device according to claim 10, characterized in that The first region image feature and the second region image feature are texture features, and the determining unit is used to: Determine a first texture feature histogram corresponding to the image features of the first region, and a second texture feature histogram corresponding to the image features of the second region; determining a texture feature difference according to the first texture feature histogram and the second texture feature histogram; The first undetermined defect sub-region whose texture feature difference is greater than the texture threshold is determined as the first real defect sub-region.

12. The device according to claim 8 or 9, characterized in that The determining unit is used for: Determine a third region image feature of the second undetermined defect sub-region and a fourth region image feature of a region corresponding to the second undetermined defect sub-region in the template smoothed image; Determining a cross-correlation difference parameter of the second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fourth region; Determine a second real defect sub-region in the second undetermined defect sub-region by using the cross-correlation difference parameter; The quality of the target lens is determined according to the first pending defect sub-region and the second real defect sub-region.

13. The device according to claim 12, characterized in that The device is also used for: Determine a peripheral region of the second undetermined defect subregion based on a morphological dilation process of the second undetermined defect subregion; determining a fifth area image feature of the peripheral area; Determining an autocorrelation difference parameter of the second to-be-determined defect sub-region according to a feature difference between the image feature of the third region and the image feature of the fifth region; The determining unit is used for: A second real defect sub-region in the second pending defect sub-region is determined by using the cross-correlation difference parameter and the autocorrelation difference parameter.

14. The device according to claim 13, characterized in that The third region image feature, the fourth region image feature and the fifth region image feature are pixel means; the determining unit is used to: Determine a feature mean difference between the third region image feature and the fourth region image feature as the cross-correlation difference parameter; A feature mean difference between the third region image feature and the fifth region image feature is determined as the autocorrelation difference parameter.

15. A computer device, characterized in that: The device comprises a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the method according to any one of claims 1 to 7 according to the instructions in the program code.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 7.

17. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method according to any one of claims 1 to 7.