Lens defect detection method and device, computer device and storage medium

By acquiring lens images under different shooting conditions and using sharpness masks and cross-image consistency verification methods, the blurring problem caused by inconsistencies in curvature and focal plane in lens inspection was solved, thereby improving the accuracy and reliability of lens defect detection.

CN121169918BActive Publication Date: 2026-02-27SHENZHEN SMARTMORE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511704763.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-20
Publication Date
2026-02-27
Estimated Expiration
2045-11-20

AI Technical Summary

Technical Problem

Existing methods for detecting lens defects suffer from inaccurate results because the inconsistency between the lens curvature characteristics and the focal plane leads to localized image blurring, making it impossible to effectively identify defects.

Method used

Multiple images of the target lens under different shooting conditions are acquired, and defects are detected through a sharpness mask. Combined with cross-image consistency verification, real defect data is integrated to eliminate duplicate counting and result redundancy.

Benefits of technology

It improves the accuracy and reliability of lens defect detection, ensures the integrity and credibility of the output results, and avoids missed defects due to local blurring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121169918B_ABST
    Figure CN121169918B_ABST
Patent Text Reader

Abstract

The application relates to a lens defect detection method and device, computer equipment and a storage medium. The method comprises the following steps: acquiring images of a target lens under different shooting conditions to obtain a images; determining a sharpness mask corresponding to each image in the a images to obtain a sharpness masks; performing defect detection on the corresponding images in the a images based on the a sharpness masks to obtain a defect detection results; performing cross-image consistency verification based on the a defect detection results and the a images to obtain b real defect data; and determining target defect data corresponding to the target lens according to the b real defect data. The application improves the accuracy of lens defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of defect detection technology, and in particular to a method, apparatus, computer equipment, and storage medium for detecting lens defects. Background Technology

[0002] During the production and testing of lenses, various typical defects can easily appear on the surface and inside of the lenses, including scratches, bubbles, black spots, and dents. These defects directly affect the optical performance and product quality of the lenses. Therefore, accurate detection of lens defects is a key step in the production process.

[0003] Currently, single-image detection is commonly used to detect defects in lenses. However, single-image detection methods rely on only a single lens image for defect detection. Due to the curvature characteristics of the lens itself, and the fact that inconsistent focal planes can easily cause blurring in local areas of the image during the imaging process, defects in the blurred areas cannot be effectively identified, ultimately resulting in missed defects and inaccurate detection results.

[0004] Therefore, improving the accuracy of lens defect detection has become an urgent problem to be solved. Summary of the Invention

[0005] Therefore, it is necessary to provide a lens defect detection method, device, computer equipment, and storage medium to address the above-mentioned technical problems, which can improve the accuracy of lens defect detection.

[0006] In a first aspect, this application provides a method for detecting lens defects, including:

[0007] Images of the target lens under different shooting conditions are acquired, resulting in a images; where a is an integer greater than 1.

[0008] Determine the sharpness mask for each of the a images to obtain a sharpness masks;

[0009] Based on a resolution mask, defects are detected in the corresponding images of a images respectively, and a defect detection results are obtained;

[0010] Based on a defect detection results and a images, cross-... Figure One Consistency verification yielded b real defect data; b is a natural number.

[0011] Based on b real defect data, determine the target defect data corresponding to the target lens.

[0012] Secondly, this application provides a lens defect detection device, comprising:

[0013] The acquisition module is used to acquire images of the target lens under different shooting conditions, resulting in a images; where a is an integer greater than 1.

[0014] a clarity masks are determined respectively, and a plurality of defect detection results are obtained by performing defect detection on the a images based on the a clarity masks.

[0015] a clarity masks are determined respectively, and a plurality of defect detection results are obtained by performing defect detection on the a images based on the a clarity masks. Figure One consistency verification based on the a defect detection results and the a images, and b real defect data are obtained; b is a natural number; and target defect data corresponding to the target lens is determined according to the b real defect data.

[0016] In a third aspect, the present application provides a computer device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the steps in the above method when executing the computer program.

[0017] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps in the above method when executed by a processor.

[0018] In a fifth aspect, the present application provides a computer program product, which comprises a computer program, and the computer program implements the steps in the above method when executed by a processor.

[0019] The above lens defect detection method, device, computer device and storage medium, by collecting a plurality of images under different shooting conditions, performing defect detection on each image to obtain a plurality of defect detection results, then performing cross-consistency verification on the a defect detection results to obtain b real defect data, and finally integrating the b real defect data, avoid the same defect from being repeatedly counted or split, while supplementing the accurate attributes of the defects, eliminating the result redundancy of multi-image detection, forming unified and complete target defect data, ensuring the reliability of the output result, that is, improving the accuracy of lens defect detection. Figure One The above lens defect detection method, device, computer device and storage medium, by collecting a plurality of images under different shooting conditions, performing defect detection on each image to obtain a plurality of defect detection results, then performing cross-consistency verification on the a defect detection results to obtain b real defect data, and finally integrating the b real defect data, avoid the same defect from being repeatedly counted or split, while supplementing the accurate attributes of the defects, eliminating the result redundancy of multi-image detection, forming unified and complete target defect data, ensuring the reliability of the output result, that is, improving the accuracy of lens defect detection. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 An application environment diagram of a lens defect detection method provided by an embodiment of the present application;

[0021] Figure 2 A flowchart of a lens defect detection method provided by an embodiment of the present application;

[0022] Figure 3 A flowchart of a clarity mask determination method provided by an embodiment of the present application;

[0023] Figure 4 A work flow diagram of a lens defect detection method provided by an embodiment of the present application;

[0024] Figure 5 A structural block diagram of a lens defect detection device provided in an embodiment of this application;

[0025] Figure 6 An internal structural diagram of a computer device provided in an embodiment of this application;

[0026] Figure 7 An internal structural diagram of another computer device provided in an embodiment of this application;

[0027] Figure 8 This is an internal structural diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0029] Please see Figure 1 , Figure 1 This diagram illustrates the application environment of a lens defect detection method provided in this application embodiment. The lens defect detection method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a communication network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0030] like Figure 2 As shown, this application provides a method for detecting lens defects, which is applied to... Figure 1 The method will be illustrated using terminal 102 or server 104 as examples. It is understood that a computer device may include at least one of a terminal and a server. The method includes:

[0031] S101. Acquire images of the target lens under different shooting conditions to obtain a images; a is an integer greater than 1.

[0032] The target lens refers to various lenses that need to be detected for defects, such as optical instrument lenses, glasses lenses, industrial lenses, etc., which are not limited here; the shooting condition refers to the focal length or depth of field of the camera.

[0033] Specifically, the target lens can be fixed on a special fixture first to ensure that the lens position does not deviate during the acquisition process (to avoid subsequent image registration difficulties); then the position of the shooting camera can be adjusted so that the camera lens is directly opposite the lens detection area (for example, the lens center and the edge are fully covered), ensuring the completeness of the imaging range; then the light source system can be built, for example, a ring light source or a multi-angle light source can be selected according to the defect type of the target lens; the ring light source is suitable for uniformly illuminating the lens surface and highlighting scratches; the multi-angle light source can project light from different directions to form obvious light and dark contrast for internal or surface defects such as bubbles and depressions.

[0034] Taking the focal length of the shooting condition as an example, after the light source system is built, a plurality of focal length values (for example, from 10mm to 50mm, with a focal length point set every 5mm) can be preset with the help of an electric focusing mechanism (an automatic focusing device connected to the camera lens); start the focusing program, the shooting camera will automatically switch to each preset focal length, and take one image at each focal length, different focal lengths correspond to different depth planes of the lens (for example, short focal length focuses on the lens surface, long focal length focuses on the lens interior), ensuring that defects of different depths such as scratches on the lens surface, depressions on the edge, and bubbles inside can be clearly presented in the image at a certain focal length. During the image shooting process, the light source system can also be used to adjust the light source to make the captured image clearer, for example, the brightness and distance of the ring light source can be adjusted to make the light evenly cover the lens surface, reduce glare interference, and form a clear light and dark boundary for fine scratches. In practical applications, a collection trigger mechanism can be set:

[0035] Through program control, the automatic process of "camera switching focal length → light source synchronous adaptation → shooting lens image" is realized without manual intervention.

[0036] After shooting according to the preset number of focal lengths, a final image (a) is obtained (the number of a can be determined by the number of preset focal length points, for example, if the number of preset focal length points is 8, then a = 8, and the value of a can be adjusted according to the size of the lens and the defect detection accuracy);

[0037] The collected images can be named and stored according to "focal length parameter + shooting time", forming an ordered image sequence (i.e. a images), which provides basic data for subsequent clarity evaluation, cross-image verification, etc.

[0038] It needs to be explained that background removal can also be performed on a image, only retaining the lens image, the core is to separate and retain the area belonging to the lens in the image, and exclude the interference of the shooting background (for example, support, environmental debris, irrelevant light and shadow, etc.). Generally, image segmentation method is used to identify the contour and range of the lens, and the background area is shielded or set as a uniform background color, and finally an image containing only the lens is obtained, providing a "disturbance-free" target area for subsequent clarity analysis, defect detection and other steps.

[0039] Due to the curvature and focal plane difference of the lens, a single image can only clearly present part of the area (such as clear center and blurred edge); a images under different shooting conditions can focus on different depths and areas of the lens, and each image undertakes the "clear imaging task" of the corresponding area, and the combination of multiple images realizes full-area coverage of the lens without dead angle, avoiding defect omission caused by local blur.

[0040] S102, respectively determine the clarity mask corresponding to each image in a images, to obtain a clarity masks.

[0041] Among them, the clarity mask is a "clarity annotation map" corresponding to the original image size, and the essence is the visualization and quantitative presentation of the local clarity of the image. It will divide the image by area block, and each area block is labeled with a qualitative label of "clear (or blurred)", and also with a specific clarity score (for example, a value between 0 and 1), just like a "image clear area map", which accurately indicates the clarity of each part of the original image.

[0042] Specifically, clarity identification can be performed on each image in a images to obtain a clarity masks.

[0043] Please refer to Figure 3 , Figure 3 The flowchart of a clarity mask determination method provided by the embodiment of the application, step S102, respectively determine the clarity mask corresponding to each image in a images, to obtain a clarity masks, can include Figure 3 The steps shown in the figure:

[0044] S21, obtaining a first image; the first image is any image in a images;

[0045] S22, using an adaptive block strategy to block the first image, to obtain c area blocks; c is an integer greater than 1;

[0046] S23, respectively determine the clarity index of each area block in the c area blocks, to obtain c clarity indexes;

[0047] S24, based on the c clarity indexes and the c area blocks, determine the clarity mask corresponding to the first image.

[0048] The definition index is a parameter for quantifying the richness of local or overall details of an image or the sharpness of edges, and the value thereof directly reflects the degree of "definition or blur" of the image. In the embodiments of the present application, the definition index is obtained by fusing multiple indexes such as Laplacian variance, gradient energy, Tenengrad operator, etc.

[0049] Specifically, the first image can be divided into c regional blocks by using an adaptive block strategy. Specifically, a "selectable range" of block size can be determined first, for example, the minimum block can be 64x64 pixels, the maximum block can be 128x128 pixels, and intermediate sizes such as 80x80 pixels can also be supplemented as a transition; then, a preset overlap ratio range of the regional blocks can be obtained, for example, the preset overlap ratio range can be 30%-50% (for example, the regional block of 64x64 pixels overlaps 32 pixels), so as to avoid defects at the block boundary being missed due to cross-block.

[0050] Then, the first image can be "coarsely divided into blocks". The entire image can be preliminarily divided into multiple coarse regional blocks according to an intermediate size (for example, 80x80 pixels). Then, for each coarse regional block, the texture density can be quantified by an algorithm (for example, the total sum of gradient values or entropy values of pixels in the block is calculated), and the higher the gradient value or entropy value, the more complex the texture (belonging to a high-frequency texture region, which can have a defect-intensive area), and vice versa, which is a smooth region (a clean region without obvious defects). Then, the size of each regional block can be adjusted according to the texture density thereof, so as to obtain multiple adjusted regional blocks. For example, a high-frequency texture region (for example, a lens scratch-intensive area or a bubble-intensive area) can be adjusted to a minimum block (for example, 64x64 pixels) to ensure that the defect details can be finely covered and the details are not diluted due to a too large block. A smooth region (for example, a lens center area without defects or a clean edge area) can be adjusted to a maximum block (128x128 pixels) to reduce the number of regional blocks and reduce the algorithmic power consumption for subsequent definition calculation. A transition region (a region between high frequency and smoothness) can be adjusted to an intermediate size (for example, 80x80 pixels) to avoid evaluation deviation caused by sudden change in block size.

[0051] Further, the first image can be formally divided into blocks according to the multiple adjusted regional blocks and the preset overlap ratio range. Specifically, the division can be performed from the top left corner of the image in the order of "horizontal + vertical" to ensure that the blocks overlap and cover the entire image without omission. Finally, c regional blocks are obtained (the value of c is determined by the image resolution and the size distribution of the regional blocks, for example, assuming that the image is 1920x1080 pixels, if the high-frequency area accounts for 30% and the smooth area accounts for 70%, about 200-300 regional blocks can be obtained).

[0052] Further, the sharpness indicators of each of the c region blocks can be determined respectively to obtain c sharpness indicators. Specifically, for each of the c region blocks, the Laplacian variance, gradient energy, and Tenengrad operator corresponding to the region block can be calculated. Since these three indicators are conventional techniques, they will not be described here. Then, the three indicators can be normalized, and the first weight (e.g., 0.4) corresponding to the Laplacian variance, the second weight (e.g., 0.3) corresponding to the gradient energy, and the third weight (e.g., 0.3) corresponding to the Tenengrad operator can be obtained. The sum of the three weights is 1. Then, the weighted operation can be performed according to the three indicators and the three weights to obtain the sharpness indicator. Finally, based on the c sharpness indicators and the c region blocks, the sharpness mask corresponding to the first image can be determined. Specifically, the sharpness indicators greater than the preset sharpness indicator among the c sharpness indicators can be found to obtain f sharpness indicators, where f is a natural number less than c. The f region blocks corresponding to the f sharpness indicators among the c region blocks are labeled as “sharp”, and all the region blocks other than the f region blocks are labeled as “blur”. Then, the c sharpness indicators of the c region blocks and the “sharp (or blur) label” corresponding to each region block can be mapped back to the corresponding positions of the first image to form a region block level sharpness map consistent with the size of the original image, that is, the sharpness mask corresponding to the first image.

[0053] The preset sharpness indicator can be preset or default.

[0054] It can be seen that by performing the adaptive blocking strategy on the image, the block size is dynamically adjusted, small blocks are used to accurately capture defect details in high-frequency texture regions, and large blocks are used to reduce the calculation amount in smooth regions. Both the loss of details is avoided, and the computing cost is reduced, which perfectly adapts to the regional difference characteristics of the lens image.

[0055] S103, based on a sharpness mask, respectively, on the corresponding image in a image defect detection, get a defect detection result.

[0056] Specifically, for each of the a sharpness masks, the corresponding image can be obtained, and then the image can be subjected to defect detection to obtain a defect detection result. In this way, a defect detection result can be obtained.

[0057] In some embodiments, step S103, based on a sharpness mask, respectively, on the corresponding image in a image defect detection, get a defect detection result, including:

[0058] S31. Based on the first sharpness mask, determine the portion of the second image whose sharpness is greater than a preset threshold, and obtain d target sharp images; the first sharpness mask is the sharpness mask corresponding to the second image in a sharpness masks; the second image is any image among a images; d is a natural number;

[0059] S32. Using the trained defect detection model, perform defect detection on d clear target images respectively to obtain d intermediate defect detection results;

[0060] S33. Based on the d intermediate defect detection results, determine the defect detection result corresponding to the second image.

[0061] The preset threshold and the trained defect detection model can both be preset or defaulted in advance. For example, the trained defect detection model can be a detection model based on a deep convolutional neural network.

[0062] Specifically, the second image and its corresponding first sharpness mask can be obtained first. Then, all regions in the first sharpness mask can be traversed to filter out regions whose sharpness (i.e., sharpness index) is greater than a preset threshold, resulting in d sharp regions. Next, the pixel coordinate range of these d sharp regions in the second image can be obtained, resulting in d pixel coordinate ranges. For example, suppose the pixel coordinate range of a certain sharp region can be x∈(100,164), y∈(100,164). Further, the second image can be cropped based on these d pixel coordinate ranges to obtain d target sharp images.

[0063] Specifically, each intermediate defect detection result may include the following information: defect type (e.g., scratch, bubble), defect region, confidence score, defect outline (e.g., rectangle, pixel mask), etc., without limitation; these d intermediate defect detection results can be deduplicated and merged to obtain the defect detection result corresponding to the second image.

[0064] In this way, by locating d clear images of the target through the first clarity mask, the "high-value area where defects can be identified" can be directly screened out, avoiding invalid searches in blurry areas. This operation can reduce computing power consumption (no need to repeat calculations in blurry areas) and reduce the interference of noise on the detection results from the source, providing a foundation for accurate detection.

[0065] S104. Based on a defect detection results and a images, perform cross-... Figure One Consistency verification yielded b real defect data; b is a natural number.

[0066] Specifically, it is possible to perform cross-image processing on a. Figure One Consistency verification is performed to identify the actual defect data in the defect detection results of 'a', and thus obtain the actual defect data of 'b'.

[0067] In some embodiments, step S104, based on a defect detection results and a image, performs cross Figure One consistency verification, to obtain b real defect data, including:

[0068] A1, each image in a image is blocked to obtain a group of area blocks;

[0069] A2, using a preset local registration algorithm to register a group of area blocks, to obtain a group of registered area blocks;

[0070] A3, using a preset transformation algorithm to perform geometric transformation and alignment on the registered a group of area blocks, to obtain the aligned a group of area blocks;

[0071] A4, based on a defect detection results and the aligned a group of area blocks, determine b real defect data.

[0072] Wherein, the preset local registration algorithm and the preset transformation algorithm can be preset or default.

[0073] Specifically, for each image in a image, it can be blocked to obtain a group of area blocks, specifically, each image can be blocked by fixed size, so as to obtain a group of area blocks; Then, a preset local registration algorithm can be used to register a group of area blocks, to obtain a group of registered area blocks, specifically, the preset local registration algorithm can include at least one of the following: local registration algorithm based on SIFT feature point matching, local registration algorithm based on SURF feature point matching, local registration algorithm based on ORB feature point matching, for example, assuming that the preset local registration algorithm is the local registration algorithm based on SIFT feature point matching, the registration process is as follows:

[0074] 1, area block corresponding grouping:

[0075] From a group of area blocks, the area blocks corresponding to the same lens physical area are selected to form a registration group, for example, the first area block of all images is a group, the second area block is another group, and finally the registration group consistent with the number of single image area blocks is formed (for example, assuming that each image is divided into c area blocks, then c registration groups are formed, each registration group contains a area block); In addition, it can also be confirmed that the size and coordinate record of all area blocks in each group is complete, and the abnormal area blocks caused by image edge clipping (such as small size and out-of-range coordinates) are excluded to avoid registration error.

[0076] 2, select reference area block:

[0077] Select one area block with the highest clarity index from each registration group as the "reference area block", and the remaining area blocks as "to be registered area blocks".

[0078] 3. Extracting SIFT feature points and descriptors

[0079] Aligning with the reference region block as the reference, the SIFT algorithm is executed on the reference region block and each to-be-registered region block in the registration group, respectively, to obtain SIFT feature points and descriptors. Specifically, the SIFT algorithm is a conventional technical means, and thus will not be described herein.

[0080] 4. Feature point matching and filtering

[0081] The feature points are matched by using a "nearest neighbor distance ratio" strategy. The descriptor distance of each feature point in the to-be-registered region block and all feature points of the reference region block is calculated, the two feature points with the closest distance are selected, and if the distance ratio of the two feature points is less than a target preset threshold (for example, 0.75), the matching pair is retained, and the false matching is removed. Further, the abnormal matching pairs are filtered. The inlier matching pairs that meet the geometric constraint are selected by using the RANSAC algorithm (random sample consensus), and the outliers caused by distortion and noise are removed, so as to ensure the matching accuracy, and a group of matching pairs corresponding to the registration group is obtained.

[0082] Steps 1 to 4 are repeated until all the registration groups are matched, a plurality of groups of matching pairs (each group corresponds to a region block of the same lens physical region) are obtained, that is, a group of region blocks after registration, which is not a group of region blocks after geometric alignment, but a group of region blocks after the establishment of the corresponding relationship of feature points and the determination of the matching logic between region blocks. The group of region blocks after registration is a key intermediate state for connecting the "region block" and the "geometric transformation", and avoids the problem of "no basis" in subsequent transformation.

[0083] Then, a preset transformation algorithm can be used to perform geometric transformation and alignment on the a group of region blocks after registration, to obtain a group of region blocks after alignment. The preset transformation algorithm can include at least one of a local affine transformation algorithm, a thin plate spline (TPS) transformation algorithm, and the like, and is not limited herein. Specifically, for each matching pair in the plurality of groups of matching pairs, a geometric transformation is calculated and applied by using the preset transformation algorithm, so that all to-be-registered region blocks in the group and the reference region block are accurately aligned, and finally a group of region blocks after alignment is obtained, and the specific process is as follows:

[0084] According to the different curvature distortion of the lens, a local affine transformation algorithm or a TPS transformation algorithm is selected, for example, for slight linear distortion (for example, a lens center area block), a local affine transformation algorithm is adopted, an affine transformation matrix (containing 6 parameters, which can describe translation, rotation, scaling and other linear deformation) is calculated based on the matching pairs in the registration group, the affine transformation matrix is applied to the to-be-registered area block, and all pixel coordinates of the to-be-registered area block are mapped and adjusted, so that the feature points of the to-be-registered area block are accurately overlapped with the corresponding feature points of the reference area block, and the alignment of the area block is completed; for example, for severe nonlinear distortion (for example, a lens edge area block), a TPS transformation algorithm is adopted, a TPS transformation model (which can describe nonlinear deformation by simulating the bending of an elastic thin plate through a radial basis function) is constructed based on the matching pairs in the registration group; the TPS transformation model is applied to the to-be-registered area block, and all pixel coordinates of the to-be-registered area block are mapped and adjusted (for example, non-integer coordinates are processed by interpolation), and the bending deviation is corrected, so that the feature points of the to-be-registered area block are accurately overlapped with the corresponding feature points of the reference area block, and the alignment of the area block is completed.

[0085] In this way, all to-be-registered area blocks in each registration group can be aligned with the reference area block, then all aligned area blocks (for example, an area block group of image 1, an area block group of image 2, etc.) can be sorted according to the image attribution, and a group of aligned area blocks a are obtained; finally, based on the a defect detection results and the a group of aligned area blocks, b real defect data can be determined.

[0086] Due to the lens curvature, the area blocks of different images are prone to misalignment. By area block disassembly, the whole image distortion is converted into a local problem. Through feature point matching and geometric transformation, the corresponding area blocks of a images are accurately overlapped, a unified coordinate reference of the same physical area is established for cross-image defect comparison, and misjudgment of defects due to misalignment is avoided.

[0087] In some embodiments, each defect result in the a defect detection results includes: a defect type, a defect area; based on the a defect detection results and the a group of aligned area blocks, b real defect data are determined, including:

[0088] B1, a first defect detection result and a first group of area blocks corresponding to the first defect detection result in the a group of aligned area blocks are obtained; the first defect detection result includes: a first defect type, a first defect area; the first defect detection result is any one of the a defect detection results;

[0089] B2, based on the a defect detection results, a position area where the first defect type appears in the a group of aligned area blocks is determined, and at least one position area is obtained;

[0090] B3, a target area number is obtained according to the number of areas in which at least one position area and the first defect area coincide.

[0091] B4, determine a target weight corresponding to the first defect detection result based on the number of target regions;

[0092] B5, when the target weight is greater than a preset weight and the number of target regions is greater than a preset number, determine that the first defect detection result is real defect data in the b real defect data; or when the target weight is not greater than the preset weight and / or the number of target regions is not greater than the preset number, determine that the first defect detection result is false defect data.

[0093] The preset weight and the preset number can be preset or defaulted in advance.

[0094] Specifically, the first defect detection result can be obtained first, then the first group of region blocks corresponding to the first defect detection result can be found from the aligned a groups of region blocks, and then the position region of the first defect type in the aligned a groups of region blocks can be determined based on the a defect detection results, to obtain at least one position region. Specifically, all defect detection results containing the first defect type can be extracted from the a defect detection results to obtain at least one defect detection result, and then at least one defect region can be extracted from the at least one defect detection result. Since the a groups of region blocks have been aligned (with reference to the reference region block), and the a defect detection results are obtained by defect detection on the a images without alignment, all coordinates in the at least one defect region need to be converted to the coordinate system of the reference region block to eliminate the positional deviation before the alignment of the region blocks, so as to obtain at least one position region.

[0095] Then, the number of target regions can be obtained according to the number of regions in which the at least one position region coincides with the first defect region. Specifically, for each position region in the at least one position region, the overlapping area of the position region and the first defect region can be calculated. For example, assuming that the coordinate range of the first defect region is x∈(x1,x2), y∈(y1,y2), and the coordinate range of a position region is x∈(x1',x2'), y∈(y1',y2'), the coordinate intersection can be calculated as follows:

[0096] The width of the overlapping region is min(x2,x2')-max(x1,x1');

[0097] The height of the overlapping region is min(y2,y2')-max(y1,y1');

[0098] If both the width and the height are greater than 0, the overlapping area is width x height.

[0099] Then, a preset coincidence ratio (for example, 30%) can be obtained, and when the proportion of the coincidence area to the position area is greater than or equal to the preset coincidence ratio, or the proportion of the coincidence area to the first defect area is greater than or equal to the preset coincidence ratio, it is determined that the two satisfy the preset coincidence condition, and the total number of all position areas that satisfy the preset coincidence condition in at least one position area is counted, that is, the number of target areas; then, the target weight corresponding to the first defect detection result can be determined based on the number of target areas.

[0100] When the target weight is greater than the preset weight and the number of target areas is greater than the preset number, it is indicated that the defect is not noise (for example, a fuzzy artifact, light and shadow interference) misdetected by the trained defect detection model, but a high-confidence candidate defect that stably appears in multiple images and has clear features, and has the "stability" feature of a real defect, and the first defect detection result can be determined as real defect data in the b real defect data; or when the target weight is not greater than the preset weight and / or the number of target areas is not greater than the preset number, it is indicated that the defect can be misdetected by the trained defect detection model (for example, a lens surface reflection is misjudged as a scratch) or appears only in a single image (for example, shooting noise), and does not have the feature of "stably existing in multiple images" of a real defect, and the self-confidence cannot support it as a real defect, and the first defect detection result can be determined as false defect data.

[0101] It can be seen that by calculating the number of coincidences between the position area and the first defect area based on the aligned a group of area blocks, the coordinate deviation caused by lens distortion is eliminated, the "position matching" is more accurate, the position of the real defect coincides with the concentrated area of the same type of defect, and the pseudo-defect (such as noise) has no such correlation, and the false defect is preliminarily screened out from the spatial dimension.

[0102] In some embodiments, based on the number of target areas, the target weight corresponding to the first defect detection result is determined, including:

[0103] C1, determining a second sharpness mask corresponding to the first group of area blocks in the a sharpness masks;

[0104] C2, determining a sharpness score corresponding to the first defect area according to the second sharpness mask;

[0105] C3, determining a region consistency score according to the number of target areas;

[0106] C4, determining a confidence score corresponding to the first defect detection result by using the trained defect detection model;

[0107] C5, determining the target weight corresponding to the first defect detection result according to a preset weight calculation formula based on the sharpness score, the region consistency score, the confidence score, and the preset weight calculation formula.

[0108] The preset weight calculation formula can be preset or defaulted in advance.

[0109] Specifically, the image identifier to which the first group of region blocks belong can be acquired, and then a second definition mask can be found from the a definition masks according to the image identifier. Then, the definition score corresponding to the first defect region can be determined according to the second definition mask. Specifically, the definition index of the first defect region can be extracted from the second definition mask to obtain a first definition index, and the definition score can be determined according to the first definition index. For example, a preset mapping relationship between the definition index and the score can be stored in advance, and the definition score corresponding to the first definition index can be determined based on the mapping relationship. Alternatively, at least one definition index corresponding to at least one position region can be determined according to the a definition masks, and the average value of the at least one definition index can be calculated to obtain an average definition index. The definition score can be determined according to the average definition index. Similarly, the definition score corresponding to the average definition index can be determined based on the mapping relationship between the definition index and the score. It should be explained that the larger the definition index is, the higher the score is.

[0110] Then, the region consistency score can be determined according to the number of target regions. Specifically, a preset mapping relationship between the number of regions and the score can be stored in advance, and the region consistency score corresponding to the number of target regions can be determined based on the mapping relationship. Alternatively, a first ratio can be obtained by dividing the number of target regions by the number of images (i.e., a), and the region consistency score can be determined according to the first ratio. A preset mapping relationship between the ratio and the score can be stored in advance, and the region consistency score corresponding to the first ratio can be determined based on the mapping relationship.

[0111] Further, the confidence score corresponding to the first defect detection result can be determined by using the trained defect detection model. Specifically, when the trained defect detection model detects defects in the image, it will not only output the defect type and the defect region, but also output the confidence. The model confidence can be directly extracted from the output data of the trained defect detection model, and the confidence score can be determined according to the model confidence. For example, a preset mapping relationship between the confidence and the score can be stored in advance, and the confidence score corresponding to the model confidence can be determined based on the mapping relationship.

[0112] It should be explained that the definition score, the region consistency score, and the confidence score have the same value range, for example, they can all be 0-1.

[0113] Finally, the definition score, the region consistency score, the confidence score, and the preset weight calculation formula can be calculated. The specific calculation formula is as follows:

[0114] W = a x Qclear + b x Cconsistency + g x Pmodel

[0115] Wherein, W represents the target weight corresponding to the first defect detection result, a, b, g are the first weight, the second weight, and the third weight preset in advance, Qclear represents the definition score, Cconsistency represents the regional consistency score, and Pmodel represents the confidence score; according to the above formula, the target weight can be obtained.

[0116] It can be seen that the definition score excludes the "fuzzy area block false detection"; the regional consistency score verifies the "cross-image position matching degree" (the real defect position is more unified); and the confidence score reflects the "model judgment reliability". The three are combined to judge from three dimensions of area block quality, position rationality, and model judgment, avoiding the false judgment caused by looking at a single dimension, thereby improving the reliability of defect detection.

[0117] S105, determining the target defect data corresponding to the target lens according to the b real defect data.

[0118] Specifically, the b real defect data can be directly de-duplicated and merged to obtain the target defect data corresponding to the target lens.

[0119] In some embodiments, each of the b real defect data includes a defect type and a defect area, and the target defect data corresponding to the target lens is determined according to the b real defect data, including:

[0120] S51, determining the defect area of each real defect data in the b real defect data to obtain b defect areas;

[0121] S52, drawing the b defect areas in a preset coordinate system, and merging the b defect areas in the preset coordinate system to obtain e merging results; e is a positive integer less than or equal to b;

[0122] S53, determining the target defect data corresponding to the target lens based on the b real defect data and the e merging results.

[0123] Wherein, the preset coordinate system can be preset or defaulted in advance.

[0124] Specifically, for each of the b real defect data, a corresponding defect region can be extracted therefrom, thereby obtaining b defect regions; then, the b defect regions can be plotted in a preset coordinate system. Specifically, since the b defect regions come from the a groups of region blocks after alignment, they already have a unified coordinate basis. Only by eliminating the local coordinate deviation through coordinate conversion (for example, region block internal coordinate → preset global coordinate system), the coordinates of the b defect regions can be mapped to the preset coordinate system. Then, the b defect regions can be merged in the preset coordinate system to obtain e merging results. Specifically, the b defect regions in the preset coordinate system can be clustered according to the “adjacent or overlapping” rule, and those that should be merged are grouped into the same group to obtain e candidate groups, specifically as follows:

[0125] Set a judgment threshold: define the quantitative standard of “adjacent” (for example, the edge distance between two defect regions < 2 pixels) and “overlapping” (for example, the overlapping area accounts for ≥ 30% of any defect area) to avoid subjective judgment;

[0126] Execute clustering algorithm: DBSCAN clustering (suitable for density type data) can be used to group the defect regions that meet the “adjacent or overlapping” condition into a “defect candidate group”, and those that do not meet the condition are grouped separately, finally obtaining e candidate groups, each of which corresponds to a “single defect instance” to be generated.

[0127] For each candidate group in the e candidate groups, the position coordinate range thereof in the preset coordinate system can be determined. For example, if the defect regions in the group are regular (such as rectangles), the minimum circumscribed rectangle of all regions is taken as the coordinate range after merging. For another example, if the regions are irregular (such as scratches and bubbles), a “convex hull algorithm” can be used to fit the contours of all regions in the group, or an “ellipse fitting” can be used to optimize the shape (more suitable for circular or elliptical defects such as bubbles), and the position coordinate range is determined according to the optimized shape. Then, the area of the defect region can also be determined according to the position coordinate range. Furthermore, the average (or maximum) of the confidence scores (which can come from model output or previous calculation) of all defect regions in the group can be obtained, and the target confidence level is obtained by dividing according to the preset level, for example, when the average is ≥ 0.9, the target confidence level is “high confidence level”, when the average is between 0.6 and 0.9, the target confidence level is “medium confidence level”, and when the average is between 0 and 0.6, the target confidence level is “low confidence level”. The “position coordinate range, shape, size area, confidence level” of each candidate group after merging are arranged as structured data (for example, dictionary or table), and e merging results are output, each of which corresponds to a real single defect instance, rather than a scattered candidate region.

[0128] Finally, the target defect data can be determined based on the b real defect data and the e merging results. Specifically, the defect types in the b real defect data can be extracted to obtain b defect types, and the b defect types are added to the corresponding merging results in the e merging results to obtain the target defect data.

[0129] For better understanding, please refer to Figure 4 , Figure 4 The working flow chart of the lens defect detection method provided by the embodiment of the application is shown in the figure. As can be seen, the working flow of the lens defect detection method is as follows:

[0130] 1. Multi-image acquisition

[0131] Multiple images of the same lens are acquired (shot from different angles, lighting, etc.), providing a multi-source data basis for subsequent detection and avoiding the information limitations of a single image.

[0132] 2. Clarity analysis and region optimization

[0133] The clarity of the multiple images is evaluated, and the clear regions are selected to exclude the interference of blur on defect detection and ensure that the subsequent detection is based on high-reliability visual information.

[0134] 3. Single-image defect detection (in parallel)

[0135] Defect detection is performed on each "optimized image" separately to identify the preliminary clues (such as regions and types) of defects in a single image, and multiple groups are parallelly detected to improve the coverage of detection.

[0136] 4. Cross-image consistency verification Figure One

[0137] The defects detected in different images are verified for "cross-image consistency" (such as position and shape matching), and the "false defects" of single-image false detection are filtered to ensure the authenticity of the defects. Figure One

[0138] 5. Multi-source result merging

[0139] The verified defect results in multiple images are merged to generate more complete and accurate final defect information (such as merging adjacent / overlapping defects, outputting coordinates, shapes, sizes, etc.).

[0140] The entire process improves the comprehensiveness and accuracy of lens defect detection through "multi-image complementation → clear selection → single-image detection → cross-image verification → multi-source merging", and reduces missed detection and false detection.

[0141] In summary, the above lens defect detection method acquires a images under different shooting conditions, performs defect detection on each image to obtain a defect detection results, and then performs cross-image consistency verification on the a defect detection results to obtain target defect data. Figure One ​​Consistency verification, b real defect data are obtained, and finally the b real defect data are integrated to avoid repeated counting or splitting of the same defect, supplement the accurate attributes of the defects, eliminate the result redundancy of multi-image detection, form unified and complete target defect data, and ensure the reliability of the output result, that is, the accuracy of the lens defect detection is improved.

[0142] It should be understood that, although each step in the flowchart involved in each of the above embodiments is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each of the above embodiments can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least part of other steps or steps or stages in other steps.

[0143] Based on the same inventive concept, the embodiments of the present application also provide a lens defect detection device. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more lens defect detection device embodiments provided below can refer to the limitations of the lens defect detection method in the above text, which will not be repeated here.

[0144] Please refer to Figure 5 , Figure 5 A structural block diagram of a lens defect detection device 500 provided by the embodiments of the present application is shown in the figure, and the lens defect detection device 500 comprises:

[0145] The acquisition module 501 is configured to acquire images of the target lens under different shooting conditions respectively, and obtain a images; a is an integer greater than 1;

[0146] The determination module 502 is configured to determine a sharpness mask corresponding to each image in the a images respectively, and obtain a sharpness masks;

[0147] The defect detection module 503 is configured to perform defect detection on the corresponding images in the a images based on the a sharpness masks respectively, and obtain a defect detection results; based on the a defect detection results and the a images, cross-image defect detection is performed to obtain b real defect data; b is a natural number; according to the b real defect data, target defect data corresponding to the target lens is determined. Figure One Consistency verification, b real defect data are obtained, and finally the b real defect data are integrated to avoid repeated counting or splitting of the same defect, supplement the accurate attributes of the defects, eliminate the result redundancy of multi-image detection, form unified and complete target defect data, and ensure the reliability of the output result, that is, the accuracy of the lens defect detection is improved.

[0148] In some embodiments, in the aspect of determining a sharpness mask corresponding to each of the a images respectively, the determining module 502 is specifically configured to:

[0149] obtain a first image; the first image is any one of the a images;

[0150] perform block division on the first image by using an adaptive block division strategy to obtain c regional blocks; c is an integer greater than 1;

[0151] determine a sharpness index of each of the c regional blocks respectively to obtain c sharpness indexes;

[0152] determine a sharpness mask corresponding to the first image based on the c sharpness indexes and the c regional blocks.

[0153] In some embodiments, in the aspect of performing defect detection on the corresponding image in the a images respectively based on the a sharpness masks to obtain a defect detection result, the defect detection module 503 is specifically configured to:

[0154] determine a part of images in the second image with a sharpness greater than a preset threshold according to the first sharpness mask to obtain d target clear images; the first sharpness mask is a sharpness mask corresponding to the second image in the a sharpness masks; the second image is any one of the a images; d is a natural number;

[0155] perform defect detection on the d target clear images respectively by using the trained defect detection model to obtain d intermediate defect detection results;

[0156] determine a defect detection result corresponding to the second image according to the d intermediate defect detection results.

[0157] In some embodiments, in the aspect of performing cross Figure One consistency verification based on the a defect detection results and the a images to obtain b real defect data, the defect detection module 503 is specifically configured to:

[0158] perform block division on each of the a images to obtain a group of regional blocks;

[0159] perform registration on the a group of regional blocks by using a preset local registration algorithm to obtain the a group of regional blocks after registration;

[0160] perform geometric transformation on the a group of regional blocks after registration by using a preset transformation algorithm and align the a group of regional blocks after registration;

[0161] determine the b real defect data based on the a defect detection results and the a group of regional blocks after alignment.

[0162] In some embodiments, each of the a defect detection results comprises a defect type and a defect region; and in determining the b real defect data based on the a defect detection results and the aligned a groups of region blocks, the defect detection module 503 is specifically configured to:

[0163] obtain a first defect detection result and a first group of region blocks corresponding to the first defect detection result in the aligned a groups of region blocks; the first defect detection result comprises a first defect type and a first defect region; the first defect detection result is any one of the a defect detection results;

[0164] determine a position region of the first defect type in the aligned a groups of region blocks based on the a defect detection results, to obtain at least one position region;

[0165] obtain a target region number according to a number of regions in which the at least one position region coincides with the first defect region;

[0166] determine a target weight corresponding to the first defect detection result based on the target region number;

[0167] when the target weight is greater than a preset weight and the target region number is greater than a preset number, determine that the first defect detection result is real defect data in the b real defect data; or

[0168] when the target weight is not greater than the preset weight and / or the target region number is not greater than the preset number, determine that the first defect detection result is false defect data.

[0169] In some embodiments, in determining the target weight corresponding to the first defect detection result based on the target region number, the defect detection module 503 is specifically configured to:

[0170] determine a second resolution mask corresponding to the first group of region blocks in the a resolution masks;

[0171] determine a resolution score corresponding to the first defect region according to the second resolution mask;

[0172] determine a region consistency score according to the target region number;

[0173] determine a confidence score corresponding to the first defect detection result by using the trained defect detection model;

[0174] determine the target weight corresponding to the first defect detection result according to a preset weight calculation formula of the resolution score, the region consistency score, and the confidence score.

[0175] In some embodiments, each of the b real defect data comprises: a defect type, a defect area, and the defect detection module 503 is specifically configured to:

[0176] determine the defect area of each of the b real defect data, to obtain b defect areas;

[0177] draw the b defect areas in a preset coordinate system, merge the b defect areas in the preset coordinate system, to obtain e merging results; e is a positive integer less than or equal to b;

[0178] determine the target defect data corresponding to the target lens based on the b real defect data and the e merging results.

[0179] The above various modules in the lens defect detection device 500 can be all or partially realized by software, hardware and combinations thereof. The above various modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to call and execute the operations corresponding to the above various modules by the processor.

[0180] In some embodiments, a computer device is provided, which can be a server, and an internal structure diagram thereof can be as shown in Figure 6 The computer device includes a processor, a memory, an input / output interface (I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The database of the computer device is used to store lens defect detection related data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to realize the steps in the above lens defect detection method.

[0181] In some embodiments, a computer device is provided, which can be a terminal, and an internal structure diagram thereof can be as shown in Figure 7As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through the system bus, the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control ability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with the external terminal in a wired or wireless manner. The wireless manner can be realized through WIFI, mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by the processor to realize the steps in the above lens defect detection method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen; The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.

[0182] Those skilled in the art can understand that, Figure 6 or Figure 7 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.

[0183] In some embodiments, a computer device is provided, which includes a memory and a processor, the memory stores a computer program, and the processor executes the computer program to realize the steps in the above method embodiments.

[0184] In some embodiments, as Figure 8 A block diagram of the internal structure of a computer readable storage medium is provided, which stores a computer program. The computer program is executed by the processor to realize the steps in the above method embodiments.

[0185] In some embodiments, a computer program product is provided, which includes a computer program. The computer program is executed by the processor to realize the steps in the above method embodiments.

[0186] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of the country and region.

[0187] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of each method can be included. Any reference to a memory, database or other medium used in the embodiments provided by the present application can include at least one of a non-volatile and volatile memory. The non-volatile memory can include a read-only memory (Read-Only Memory, ROM), a magnetic tape, a floppy disk, a flash memory, an optical storage, a high-density embedded non-volatile memory, a resistive memory (ReRAM), a magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), a ferroelectric memory (Ferroelectric Random Access Memory, FRAM), a phase change memory (Phase Change Memory, PCM), a graphene memory, etc. The volatile memory can include a random access memory (Random Access Memory, RAM) or an external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided by the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided by the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0188] The technical features of the above embodiments can be combined in any way. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist contradictory, they should be considered as the scope of the present disclosure.

[0189] The above embodiments only express several implementation ways of the present application, and the description is specific and detailed, but it should not be understood as a limitation to the patent scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method of lens defect detection, characterized in that, The method comprises the following steps: acquiring images of the target lens under different shooting conditions respectively, to obtain a images; a is an integer greater than 1; determining a sharpness mask corresponding to each of the a images respectively, to obtain a sharpness masks; performing defect detection on the corresponding images in the a images respectively based on the a sharpness masks, to obtain a defect detection results; performing cross-image consistency verification based on the a defect detection results and the a images, to obtain b real defect data; b is a natural number; determining target defect data corresponding to the target lens according to the b real defect data.

2. The method of claim 1, wherein, The method comprises the following steps: acquiring a first image; the first image is any image in the a images; performing block division on the first image by using an adaptive block division strategy, to obtain c regional blocks; c is an integer greater than 1; determining a sharpness index of each of the c regional blocks, to obtain c sharpness indexes; determining a sharpness mask corresponding to the first image based on the c sharpness indexes and the c regional blocks.

3. The method according to claim 1 or 2, characterized in that, The method comprises the following steps: determining part of the second image with a sharpness greater than a preset threshold according to a first sharpness mask, to obtain d target clear images; the first sharpness mask is a sharpness mask corresponding to the second image in the a sharpness masks; the second image is any image in the a images; d is a natural number; performing defect detection on the d target clear images respectively by using a trained defect detection model, to obtain d intermediate defect detection results; determining a defect detection result corresponding to the second image according to the d intermediate defect detection results.

4. The method of claim 3, wherein, The method comprises the following steps: performing block division on each of the a images, to obtain a groups of regional blocks; performing registration on the a groups of regional blocks by using a preset local registration algorithm, to obtain registered a groups of regional blocks; performing geometric transformation on the registered a groups of regional blocks by using a preset transformation algorithm and aligning, to obtain aligned a groups of regional blocks; determining b real defect data based on the a defect detection results and the aligned a groups of regional blocks.

5. The method of claim 4, wherein, Each of the a defect detection results comprises a defect type and a defect region; the method comprises the following steps: acquiring a first defect detection result and a first group of regional blocks corresponding to the first defect detection result in the aligned a groups of regional blocks; the first defect detection result comprises a first defect type and a first defect region; the first defect detection result is any defect detection result in the a defect detection results; determine a position region where the first defect type appears in the aligned a groups of region blocks based on the a defect detection results, to obtain at least one position region; obtain a target region number according to a number of regions where the at least one position region coincides with the first defect region; determine a target weight corresponding to the first defect detection result based on the target region number; when the target weight is greater than a preset weight and the target region number is greater than a preset number, determine that the first defect detection result is real defect data in the b real defect data; or when the target weight is not greater than the preset weight and / or the target region number is not greater than the preset number, determine that the first defect detection result is false defect data.

6. The method of claim 5, wherein, The method comprises the following steps: determine a second resolution mask corresponding to the first group of region blocks in the a resolution masks; determine a resolution score corresponding to the first defect region according to the second resolution mask; determine a region consistency score according to the target region number; determine a confidence score corresponding to the first defect detection result by using the trained defect detection model; determine the target weight corresponding to the first defect detection result according to the resolution score, the region consistency score, the confidence score, and a preset weight calculation formula.

7. The method of claim 1 or 2, wherein, Each of the b real defect data comprises a defect type and a defect region. The method comprises the following steps: determine the defect region of each real defect data in the b real defect data to obtain b defect regions; merge the b defect regions in a preset coordinate system to obtain e merging results; e is a positive integer less than or equal to b; determine the target defect data corresponding to the target lens based on the b real defect data and the e merging results.

8. An apparatus for detecting defects in an ophthalmic lens, the apparatus comprising: The method comprises the following steps: an acquisition module is configured to acquire images of a target lens under different shooting conditions to obtain a images; a is an integer greater than 1; a determination module is configured to determine a resolution mask corresponding to each image in the a images to obtain a resolution masks; a defect detection module is configured to perform defect detection on corresponding images in the a images based on the a resolution masks to obtain a defect detection results; and perform cross-image consistency verification based on the a defect detection results and the a images to obtain b real defect data. b is a natural number; and the target defect data corresponding to the target lens is determined based on the b real defect data. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is characterized in that, The processor executes the computer program to implement the steps of the method of any one of claims 1 to 7.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Product image reconstruction method, product reconstruction model training method and device

    CN114782300A

  • Methods and systems for detecting defects in a reticle design pattern

    WO2008141064A1