Method and system for detecting surface defects of plastic optical lens

Through the combination of phase consistency multi-scale edge detection and VGG16 model, combined with a 2D measuring instrument to obtain defect size, the error detection and missed detection problems in surface defect detection of plastic optical lenses are solved, and the detection effect of high-precision and low error detection rate is achieved.

CN119540151AActive Publication Date: 2025-02-28WUXI XINJUHONG INTELLIGENT TECHNOLOGY CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411508484.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-02-28
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

The prior art has problems of mis-detection and missed detection when detecting surface defects of plastic optical lenses, and the detection efficiency is low, making it difficult to ensure the detection consistency in large-scale production.

Method used

The phase consistency multi-scale edge detection algorithm is used to divide optical zones and non-optical zones by fitting an elliptical model, and a defect detection model is constructed in combination with VGG16. The length and width of the defect area are obtained using a two-dimensional measuring instrument to perform multimodal data characteristics fusion.

Benefits of technology

It greatly improves detection accuracy, reduces false detection and missed detection rates, ensures detection consistency in large-scale production, and improves the ability to accurately classify complex defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540151A_ABST
    Figure CN119540151A_ABST
Patent Text Reader

Abstract

The invention discloses a plastic optical lens surface defect detection method and system, and the method comprises the steps: S1, carrying out the phase consistency multi-scale edge detection of a plastic lens image, and obtaining a coordinate set of edge points of a plastic lens; s2, fitting an elliptic model based on the edge point set, dividing an optical region and a non-optical region by using a fitting result, and generating an optical region mask; s3, carrying out enhancement and feature extraction on pixels in the optical region, screening a potential defect region through binaryzation to obtain a potential defect map, and obtaining the length and width of the defect region by using a quadratic element measuring instrument; s4, constructing a defect detection model based on VGG16, and training and optimizing the defect detection model by using the labeled training sample to obtain an optimized model; and S5, detecting the plastic lens image of which the defect category is not marked by using the optimized model to obtain a defect detection result. According to the invention, false detection and missing detection of surface defects of the plastic optical lens can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of lens surface defect detection, and in particular to a method and system for detecting surface defects of a plastic optical lens. Background Art

[0002] With the widespread application of optical products in consumer electronics, automobiles, medical equipment and precision instruments, the quality requirements for optical lenses are getting higher and higher. Plastic optical lenses are gradually replacing traditional glass lenses and becoming the mainstream of the market due to their advantages such as lightness, easy processing and low cost. However, due to the softness and susceptibility to contamination of plastic materials, defects such as bubbles, scratches, cracks and impurities are inevitable during the production process. Therefore, how to efficiently and accurately detect these defects and ensure the quality of products has become an important research topic in the industry.

[0003] At present, the detection of surface defects of plastic optical lenses in the market mainly relies on manual inspection and traditional image processing methods. Traditional detection methods mainly rely on manual operation to visually inspect the surface defects of optical lenses. However, manual inspection has problems such as strong subjectivity, low detection efficiency, and easy fatigue, making it difficult to ensure the consistency of detection in mass production. In addition, since some minor defects are difficult to identify with the naked eye, the missed detection rate is high. Some detection schemes use simple image processing techniques such as edge detection, histogram analysis, and binarization. These methods work well when detecting simple and significant defects, but their detection accuracy is low for complex, minor or blurred defects. These methods are often easily affected by environmental factors such as changes in illumination and lens position deviation, resulting in false detection and missed detection. Summary of the invention

[0004] In view of this, the present invention provides a method for detecting surface defects of a plastic optical lens, aiming to reduce false detection and missed detection of surface defects of a plastic optical lens, and to provide a reliable solution for quality inspection of a plastic optical lens.

[0005] To achieve the above object, the present invention provides a method for detecting surface defects of a plastic optical lens, comprising the following steps:

[0006] S1: Perform phase consistency multi-scale edge detection on the plastic lens image to obtain a set of plastic lens edge point coordinates;

[0007] S2: Fitting an ellipse model based on the edge point set, dividing the optical area and the non-optical area using the fitting result, and generating an optical area mask;

[0008] S3: Enhance and extract features of pixels in the optical area, and screen potential defect areas through binarization to obtain a potential defect map, and use a two-dimensional measuring instrument to obtain the length and width of the defect area;

[0009] S4: Build a defect detection model based on VGG16, use the labeled training samples to train and optimize the defect detection model, and obtain the optimized model;

[0010] S5: Use the optimized model to detect the plastic lens image without labeled defect categories to obtain defect detection results;

[0011] As a further improvement method of the present invention:

[0012] Optionally, in step S1, performing phase consistency multi-scale edge detection on the plastic lens image to obtain a set of plastic lens edge point coordinates includes:

[0013] S11: Preprocessing the plastic lens image I using Gaussian filtering, specifically:

[0014]

[0015] Wherein, π is the circumference of a circle; e is a natural constant; σ is the standard deviation of the Gaussian kernel; i = -a, -a+1, ..., 0, ..., a-1, a, j = -a, -a+1, ..., 0, ..., a-1, a; a is the radius of the Gaussian kernel; x and y are the horizontal and vertical coordinates of the plastic lens image pixel, respectively; I (xi, yj) is the pixel value of the plastic lens image I at the pixel position (xi, yj); The preprocessed image The pixel value at pixel location (x,y);

[0016] S12: Extract edge points based on phase consistency:

[0017] S121: Preprocessed image Perform a multi-scale Fourier transform, specifically:

[0018]

[0019] Where M and N are the horizontal and vertical lengths of the plastic lens image, respectively; δ is an imaginary unit, satisfying δ 2 = -1; u and v are the frequency domain positions in the horizontal and vertical directions respectively; F(u,v) is the pixel value of the Fourier transform result image F at the frequency domain position (u,v);

[0020] The multi-scale Fourier transform result image is extracted based on the Fourier transform result image, specifically:

[0021]

[0022] Among them, f n is the center frequency of the nth scale, is the number of scales; is the bandwidth control parameter; F n (u,v) is the Fourier transform result image F at the nth scale n The pixel value at position (u,v) in the frequency domain;

[0023] S122: Calculate multi-scale phase map:

[0024] Perform inverse Fourier transform on the multi-scale Fourier transform result image to obtain a multi-scale phase image, specifically:

[0025]

[0026] in, is the inverse Fourier transform; arg is the complex phase extraction function; θ n (x,y) is the phase image θ of the nth scale n The phase value at the pixel location (x,y);

[0027] S123: Calculate phase consistency:

[0028] The phase consistency result diagram is calculated using a multi-scale phase diagram, specifically:

[0029]

[0030] in, is the average phase value of the phase image at the pixel position (x, y) under all scales; PC(x, y) is the pixel value of the phase consistency result image PC at the pixel position (x, y); W n (x,y) is the weight of the pixel position (x,y) at the nth scale, specifically:

[0031]

[0032] S124: Extract edge points:

[0033] Filter the pixels in the phase consistency result map PC to obtain the edge point set, specifically:

[0034]

[0035] Wherein, T is the edge point extraction threshold; E is the coordinate set of the edge points of the plastic lens; are the horizontal and vertical coordinates of the kth edge point; The phase consistency result PC is at the pixel position The pixel value at .

[0036] Optionally, in step S2, fitting an ellipse model based on the edge point set, dividing the optical zone and the non-optical zone using the fitting result, and generating an optical zone mask comprises:

[0037] S21: Fitting an ellipse model using the plastic lens edge point coordinate set:

[0038] Using the least squares method, the sum of square errors of the edge points of the plastic lens is taken as the optimization target, specifically:

[0039]

[0040] Where Z is the error function; |E| is the total number of edge points of the plastic lens in E; is the center coordinate of the ellipse model; a and b are the major axis and minor axis of the ellipse model respectively;

[0041] The error function Z is respectively used to calculate the parameters of the ellipse model Find the partial derivatives of a and b, and set the partial derivatives to 0 to solve for the parameters of the fitted ellipse model a' and b'; where is the center coordinate of the fitted ellipse model; a' and b' are the major axis and minor axis of the fitted ellipse model respectively;

[0042] S22: Divide the inner and outer regions of the fitted elliptical model to obtain an optical zone mask:

[0043] S221: Constructing the conditions for determining the area division:

[0044] Through the fitted ellipse model, if the pixel is in the fitted ellipse model, it is in the optical area, otherwise it is in the non-optical area, and the pixel set R of the optical area is obtained. optical ;

[0045] S222: Generate optical zone mask:

[0046] The pixel values ​​of the pixels in the optical zone are set to 1, and the pixel values ​​of the pixels in the non-optical zone are set to 0, to generate the optical zone mask Mask.

[0047] Optionally, in step S3, pixels in the optical zone are enhanced and features are extracted, potential defect areas are screened by binarization, a potential defect map is obtained, and a two-dimensional measuring instrument is used to obtain the length and width of the defect area, including:

[0048] S31: Perform image enhancement:

[0049] The pixels in the optical zone of the plastic lens image I are enhanced using a local contrast enhancement method, wherein the local contrast enhancement method is:

[0050]

[0051] Among them, I enh (x,y) is the enhanced image I enh The pixel value at the pixel position (x, y); mean 5×5 (x,y) and std 5×5 (x, y) are the mean and standard deviation of the pixel values ​​in a local window of size 5×5 centered at the pixel position (x, y) of the plastic lens image I; Mask(x, y) is the pixel value of the optical zone mask Mask at the pixel position (x, y);

[0052] S32: Feature extraction:

[0053] Use the Laplace operator to extract features from the enhanced image and obtain the Laplace feature map I hp ;

[0054] S33: Use binarization to screen potential defect areas:

[0055] For Laplace characteristic graph I hp Apply the threshold τ for binarization, specifically:

[0056]

[0057] Wherein, B(x,y) is the pixel value of the potential defect image B at the pixel position (x,y);

[0058] S34: Measure the length and width of the defect area:

[0059] The length and width of the defect area are obtained using a two-dimensional measuring instrument, where the length and width of the defect area are the long side and the short side of the minimum circumscribed rectangle containing the defect area.

[0060] Optionally, in step S4, a defect detection model is constructed based on VGG16, and the defect detection model is optimized by training with labeled training samples to obtain an optimized model, including:

[0061] S41: Building a defect detection model:

[0062] The VGG16 architecture is used as the defect detection model; VGG16 uses the plastic lens image I and the potential defect map B as input to obtain the input feature vector, specifically:

[0063] Fea VGG = VGG16([I,B])

[0064] Among them, Fea VGGis the input feature vector, obtained before the fully connected layer of the VGG16 architecture, with a dimension of 4096; [I, B] is the input sample obtained by concatenating the plastic lens image I and the potential defect image B in the channel dimension;

[0065] The length and width of the defect area are input into a separate fully connected layer and mapped to the input feature vector Fea VGG Same feature dimension and same as Fea VGG Add together to obtain the fused feature vector Fea fusion ;

[0066] The fusion feature vector Fea fusion Input to the fully connected layer of the VGG16 architecture and use the normalized exponential function to calculate the defect probability vector, specifically:

[0067] P = Softmax(MLP(Fea fusion ))

[0068] Where P is a C-dimensional defect probability vector, each dimension of the vector corresponds to the probability of defects of different categories, and C is the total number of categories; Softmax is a normalized exponential function; MLP is the fully connected layer of the VGG16 architecture;

[0069] S42: Training model:

[0070] The model is trained using the cross entropy loss function, which is:

[0071]

[0072] Where Loss is the loss value; q is the sample number, q = 1, 2, ..., Q, Q is the number of training samples; cls is the category number, cls = 1, 2, ... C; is the true label of the qth labeled training sample. If the qth training sample input to the defect detection model belongs to the clsth class defect, it is 1, otherwise it is 0; The probability that the qth training sample input to the model belongs to the clsth class defect predicted by the defect detection model;

[0073] The stochastic gradient descent method is used to iteratively optimize the parameters of the defect detection model to reduce the loss value Loss until the set number of iterations is reached to obtain the optimized model.

[0074] Optionally, in step S5, the optimized model is used to detect the plastic lens image without labeled defect categories to obtain defect detection results, including:

[0075] S51: Get the model prediction results:

[0076] The plastic lens image without defect category labeling, the corresponding defect map generated by steps S1 to S3, and the length and width of the defect area obtained by the two-dimensional measuring instrument are input into the optimized model to obtain the probability vector predicted by the model.

[0077] S52: Determine the final detection category:

[0078] By predicting the probability vector of the model Perform the maximum value operation and select the category with the highest probability as the final defect category, specifically:

[0079]

[0080] in, The defect category number predicted by the defect detection model; The model predicts the probability that the sample input to the model belongs to the cls class of defects.

[0081] The present invention also discloses a system for detecting surface defects of a plastic optical lens, comprising:

[0082] Edge detection module: performs phase consistency multi-scale edge detection on plastic lens images;

[0083] Optical zone division module: Fitting an ellipse model based on the edge point set, and using the fitting results to divide the optical zone and non-optical zone;

[0084] Potential defect extraction module: enhances and extracts features from pixels in the optical area, and screens potential defect areas through binarization to obtain potential defect maps, and uses a two-dimensional measuring instrument to obtain the length and width of the defect area;

[0085] Model building module: build a defect detection model based on VGG16, and use labeled training samples to train and optimize the defect detection model;

[0086] Model application module: Use the optimized model to detect plastic lens images without labeled defect categories;

[0087] Beneficial effects:

[0088] The present invention uses a phase-consistent multi-scale edge detection algorithm to extract edge information of plastic lenses in complex backgrounds and ensure accurate division of optical and non-optical areas. Traditional image processing algorithms are often susceptible to noise interference, resulting in false detection and missed detection problems. The present invention greatly improves detection accuracy through the optimization of deep learning models and the fusion of geometric features. In addition, the use of a two-dimensional measuring instrument to obtain the precise size of the defect area allows the model to have a more comprehensive understanding of the defect characteristics and further reduce the detection error rate.

[0089] The present invention introduces a two-dimensional measuring instrument in the defect detection process to measure key geometric features such as the length and width of the defect area, and inputs these features and image information into the VGG16 model for classification. Compared with the detection method that relies solely on image information, the fusion of multi-dimensional features improves the model's discrimination ability and can also classify complex defects more accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0090] Figure 1 A schematic diagram of a process of detecting surface defects of a plastic optical lens according to an embodiment of the present invention;

[0091] Figure 2 Schematic diagram of defects of an embodiment of the present invention, wherein (a) shows white spots / black spots, (b) shows dirt, and (c) shows flow marks. DETAILED DESCRIPTION

[0092] The present invention is further described below in conjunction with the accompanying drawings, but the present invention is not limited in any way. Any changes or substitutions made based on the teachings of the present invention belong to the protection scope of the present invention.

[0093] Embodiment 1: A method for detecting surface defects of a plastic optical lens, such as Figure 1 As shown, the following steps are included:

[0094] S1: Perform phase consistency multi-scale edge detection on the plastic lens image to obtain the coordinate set of the edge points of the plastic lens:

[0095] S11: Preprocessing the plastic lens image I using Gaussian filtering, specifically:

[0096]

[0097] Wherein, π is the circumference of a circle; e is a natural constant; σ is the standard deviation of the Gaussian kernel; i = -a, -a+1, ..., 0, ..., a-1, a, j = -a, -a+1, ..., 0, ..., a-1, a; a is the radius of the Gaussian kernel, which is 3 in this embodiment; x and y are the horizontal coordinate and vertical coordinate of the plastic lens image pixel, respectively; I (xi, yj) is the pixel value of the plastic lens image I at the pixel position (xi, yj); The preprocessed image The pixel value at pixel location (x,y);

[0098] S12: Extract edge points based on phase consistency:

[0099] S121: Preprocessed image Perform a multi-scale Fourier transform, specifically:

[0100]

[0101] Where M and N are the horizontal and vertical lengths of the plastic lens image, respectively; δ is an imaginary unit, satisfying δ 2 = -1; u and v are the frequency domain positions in the horizontal and vertical directions respectively; F(u,v) is the pixel value of the Fourier transform result image F at the frequency domain position (u,v);

[0102] The multi-scale Fourier transform result image is extracted based on the Fourier transform result image, specifically:

[0103]

[0104] Among them, f n is the center frequency of the nth scale, is the number of scales. In this embodiment f 1 =0.05, f 2 =0.1, f 3 =0.2; is the bandwidth control parameter, which is 0.8 in this embodiment; F n (u,v) is the Fourier transform result image F at the nth scale n The pixel value at position (u,v) in the frequency domain;

[0105] S122: Calculate multi-scale phase map:

[0106] Perform inverse Fourier transform on the multi-scale Fourier transform result image to obtain a multi-scale phase image, specifically:

[0107]

[0108] in, is the inverse Fourier transform; arg is the complex phase extraction function; θ n (x,y) is the phase image θ of the nth scale n The phase value at the pixel location (x,y);

[0109] S123: Calculate phase consistency:

[0110] The phase consistency result diagram is calculated using a multi-scale phase diagram, specifically:

[0111]

[0112] in, is the average phase value of the phase image at the pixel position (x, y) under all scales; PC(x, y) is the pixel value of the phase consistency result image PC at the pixel position (x, y); Wn (x,y) is the weight of the pixel position (x,y) at the nth scale, specifically:

[0113]

[0114] S124: Extract edge points:

[0115] Filter the pixels in the phase consistency result map PC to obtain the edge point set, specifically:

[0116]

[0117] Wherein, T is the edge point extraction threshold, which is 0.2 in this embodiment; E is the edge point coordinate set of the plastic lens; are the horizontal and vertical coordinates of the kth edge point; The phase consistency result PC is at the pixel position The pixel value at .

[0118] This step uses Gaussian filtering for preprocessing to remove noise from the plastic lens image and improve the stability of edge detection. In the subsequent phase consistency calculation, even if the image has uneven brightness, reflections or local blur, the key edges can still be accurately identified. In addition, multi-scale Fourier transform combined with phase information analysis effectively resists noise interference, making the detection results more reliable.

[0119] This step uses multi-scale Fourier transform to enable edge detection to capture features at different scales at the same time. High-frequency scales focus on detail information, such as tiny scratches or cracks; low-frequency scales capture overall contours and large defect features. The multi-scale information is fused through the phase consistency method to ensure that edge features under complex structures are not ignored, thereby comprehensively improving the detection effect.

[0120] S2: Fit an ellipse model based on the edge point set, use the fitting result to divide the optical area and the non-optical area, and generate an optical area mask:

[0121] S21: Fitting an ellipse model using the plastic lens edge point coordinate set:

[0122] Using the least squares method, the sum of square errors of the edge points of the plastic lens is taken as the optimization target, specifically:

[0123]

[0124] Where Z is the error function; |E| is the total number of edge points of the plastic lens in E; is the center coordinate of the ellipse model; a and b are the major axis and minor axis of the ellipse model respectively;

[0125] The error function Z is respectively used to calculate the parameters of the ellipse model Find the partial derivatives of a and b, and set the partial derivatives to 0 to solve for the parameters of the fitted ellipse model a' and b'; where is the center coordinate of the fitted ellipse model; a' and b' are the major axis and minor axis of the fitted ellipse model respectively;

[0126] S22: Divide the inner and outer regions of the fitted elliptical model to obtain an optical zone mask:

[0127] S221: Constructing the conditions for determining the area division:

[0128] The pixels are divided into optical area and non-optical area by the fitted ellipse model, specifically:

[0129]

[0130] Among them, R optical is a pixel set in the optical zone;

[0131] S222: Generate optical zone mask:

[0132] The pixel values ​​of the pixels in the optical area are set to 1, and the pixel values ​​of the pixels in the non-optical area are set to 0, and the optical area mask Mask is generated, specifically:

[0133]

[0134] Wherein, Mask(x,y) is the pixel value of the optical area mask Mask at the pixel position (x,y).

[0135] This step can accurately describe the edge morphology of the plastic lens by fitting the ellipse model using the least squares method. The ellipse model is suitable for the shape characteristics of most plastic lenses and helps to accurately divide the optical area and the non-optical area. Compared with simple rectangular or circular segmentation methods, the ellipse model can better fit the actual contour of the lens, ensuring a more accurate segmentation result.

[0136] S3: Enhance the pixels in the optical area, extract features, and screen potential defect areas through binarization to obtain a potential defect map. Use a two-dimensional measuring instrument to obtain the length and width of the defect area:

[0137] S31: Perform image enhancement:

[0138] The pixels in the optical zone of the plastic lens image I are enhanced using a local contrast enhancement method, wherein the local contrast enhancement method is:

[0139]

[0140] Among them, I enh(x,y) is the enhanced image I enh The pixel value at the pixel position (x, y); mean 5×5 (x,y) and std 5×5 (x, y) are the mean and standard deviation of the pixel values ​​in a local window of size 5×5 centered at the pixel position (x, y) of the plastic lens image I;

[0141] S32: Feature extraction:

[0142] The Laplace operator is used to extract features from the enhanced image, specifically:

[0143] I hp (x,y)=I enh (x+1,y)+I enh (x-1,y)+I enh (x,y+1)+I enh (x,y-1)-4I enh (x,y)

[0144] Among them, I hp (x,y) is the Laplace characteristic map I hp The pixel value at the pixel position (x, y); I enh (x+1,y),I enh (x-1,y),I enh (x,y+1) and I enh (x, y-1) are the enhanced images I enh The pixel values ​​at pixel locations (x+1,y), (x-1,y), (x,y+1), and (x,y-1);

[0145] S33: Use binarization to screen potential defect areas:

[0146] For Laplace characteristic graph I hp A threshold τ is applied for binarization. In this embodiment, τ=10, specifically:

[0147]

[0148] Wherein, B(x,y) is the pixel value of the potential defect image B at the pixel position (x,y);

[0149] S34: Measure the length and width of the defect area:

[0150] The length and width of the defect area are obtained using a two-dimensional measuring instrument, where the length and width of the defect area are the long side and the short side of the minimum circumscribed rectangle containing the defect area.

[0151] The local contrast enhancement method makes the subtle texture and brightness changes in the optical area more obvious. The average value and standard deviation are calculated for each local window to achieve adaptive contrast enhancement. This method effectively avoids the influence of uneven lighting and overall brightness changes on the inspection results, making tiny defects easier to identify.

[0152] Measuring the length and width of the defect area using the minimum enclosing rectangle can provide high-precision size information. This method ensures that the measurement results are still applicable to irregular-shaped defects and can effectively reflect the actual size of the defects, providing reliable data support for quality control.

[0153] S4: Build a defect detection model based on VGG16, use the labeled training samples to train and optimize the defect detection model, and obtain the optimized model:

[0154] S41: Building a defect detection model:

[0155] The VGG16 architecture is used as the defect detection model; VGG16 uses the plastic lens image I and the potential defect map B as input to obtain the input feature vector, specifically:

[0156] Fea VGG = VGG16([I,B])

[0157] Among them, Fea VGG is the input feature vector, obtained before the fully connected layer of the VGG16 architecture, with a dimension of 4096; [I, B] is the input sample obtained by concatenating the plastic lens image I and the potential defect image B in the channel dimension;

[0158] The length and width of the defect area are input into a separate fully connected layer and mapped to the input feature vector Fea VGG Same feature dimension and same as Fea VGG Add together to obtain the fused feature vector Fea fusion ;

[0159] The fusion feature vector Fea fusion Input to the fully connected layer of the VGG16 architecture and use the normalized exponential function to calculate the defect probability vector, specifically:

[0160] P = Softmax(MLP(Fea fusion ))

[0161] Wherein, P is a C-dimensional defect probability vector, each dimension of the vector corresponds to the probability of a different type of defect, and C is the total number of categories. In this embodiment, C=4, representing no defect, white spot / black spot, dirt, and flow mark, respectively. Figure 2As shown; Softmax is a normalized exponential function; MLP is a fully connected layer of the VGG16 architecture;

[0162] S42: Training model:

[0163] The model is trained using the cross entropy loss function, which is:

[0164]

[0165] Where Loss is the loss value; q is the sample number, q = 1, 2, ..., Q, Q is the number of training samples; cls is the category number, cls = 1, 2, ... C; is the true label of the qth labeled training sample. If the qth training sample input to the defect detection model belongs to the clsth class defect, it is 1, otherwise it is 0; The probability that the qth training sample input to the model belongs to the clsth class defect predicted by the defect detection model;

[0166] The parameters of the defect detection model are iteratively optimized using the stochastic gradient descent method to reduce the loss value Loss until the set number of iterations is reached to obtain the optimized model. In this embodiment, the number of iterations is 10,000 times.

[0167] Using plastic lens images and potential defect maps as input samples, the information after local enhancement and feature extraction is fused with the original image through channel dimension splicing to enhance the model's perception of defect features. At the same time, combined with the length and width information of the defect area, feature fusion of multimodal data is achieved to further improve the comprehensiveness and accuracy of detection.

[0168] Mapping the size information of the defect area to the same dimension as the image feature vector and adding it to the feature vector extracted by VGG16 can enrich the input features of the model. This fusion strategy helps the model better understand the shape, size, and spatial distribution of defects and improve the classification performance of different types of defects.

[0169] S5: Use the optimized model to detect the plastic lens images without labeled defect categories to obtain defect detection results:

[0170] S51: Get the model prediction results:

[0171] The plastic lens image without defect category labeling, the corresponding defect map generated by steps S1 to S3, and the length and width of the defect area obtained by the two-dimensional measuring instrument are input into the optimized model to obtain the probability vector predicted by the model.

[0172] S52: Determine the final detection category:

[0173] By predicting the probability vector of the model Perform the maximum value operation and select the category with the highest probability as the final defect category, specifically:

[0174]

[0175] in, The defect category number predicted by the defect detection model; The model predicts the probability that the sample input to the model belongs to the cls class of defects.

[0176] Embodiment 2: The present invention also discloses a plastic optical lens surface defect detection system, comprising the following five modules:

[0177] Edge detection module: performs phase consistency multi-scale edge detection on plastic lens images;

[0178] Optical zone division module: Fitting an ellipse model based on the edge point set, and using the fitting results to divide the optical zone and non-optical zone;

[0179] Potential defect extraction module: enhances and extracts features from pixels in the optical area, and screens potential defect areas through binarization to obtain potential defect maps, and uses a two-dimensional measuring instrument to obtain the length and width of the defect area;

[0180] Model building module: build a defect detection model based on VGG16, and use labeled training samples to train and optimize the defect detection model;

[0181] Model application module: Use the optimized model to detect plastic lens images without labeled defect categories.

[0182] It should be noted that the serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising" or any other variants thereof in this article are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "including a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.

[0183] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0184] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for detecting surface defects of a plastic optical lens, characterized in that: The following steps are involved: S1: Perform phase consistency multi-scale edge detection on the plastic lens image to obtain a set of plastic lens edge point coordinates; S2: Fitting an ellipse model based on the edge point set, dividing the optical area and the non-optical area using the fitting result, and generating an optical area mask; S3: Enhance and extract features of pixels in the optical area, and screen potential defect areas through binarization to obtain a potential defect map, and use a two-dimensional measuring instrument to obtain the length and width of the defect area; S4: Build a defect detection model based on VGG16, use the labeled training samples to train and optimize the defect detection model, and obtain the optimized model; S5: Use the optimized model to detect the plastic lens image without labeled defect categories to obtain defect detection results.

2. The method for detecting surface defects of a plastic optical lens according to claim 1, characterized in that: The step S1 includes the following steps: S11: Preprocessing the plastic lens image I using Gaussian filtering, specifically: Wherein, π is the circumference of a circle; e is a natural constant; σ is the standard deviation of the Gaussian kernel; i = -a, -a+1, ..., 0, ..., a-1, a; j = -a, -a+1, ..., 0, ..., a-1, a; a is the radius of the Gaussian kernel; x and y are the horizontal and vertical coordinates of the pixel of the plastic lens image I, respectively; I (xi, yj) is the pixel value of the plastic lens image I at the pixel position (xi, yj); The preprocessed image The pixel value at pixel location (x,y); S12: Perform edge point extraction based on phase consistency.

3. The method for detecting surface defects of a plastic optical lens according to claim 2, characterized in that: The step S12 includes the following steps: S121: Preprocessed image Perform a multi-scale Fourier transform, specifically: Where M and N are the horizontal and vertical lengths of the plastic lens image, respectively; δ is an imaginary unit, satisfying δ 2 = -1; u and v are the frequency domain positions in the horizontal and vertical directions respectively; F(u,v) is the pixel value of the Fourier transform result image F at the frequency domain position (u,v); The multi-scale Fourier transform result image is extracted based on the Fourier transform result image, specifically: Among them, f n is the center frequency of the nth scale, is the number of scales; is the bandwidth control parameter; F n (u,v) is the Fourier transform result image F at the nth scale n The pixel value at position (u,v) in the frequency domain; S122: Calculate multi-scale phase map: Perform inverse Fourier transform on the multi-scale Fourier transform result image to obtain a multi-scale phase image, specifically: in, is the inverse Fourier transform; arg is the complex phase extraction function; θ n (x,y) is the phase image θ of the nth scale n The phase value at the pixel location (x,y); S123: Calculate phase consistency: The phase consistency result diagram is calculated using a multi-scale phase diagram, specifically: in, is the average phase value of the phase image at the pixel position (x, y) under all scales; PC(x, y) is the pixel value of the phase consistency result image PC at the pixel position (x, y); W n (x,y) is the weight of the pixel position (x,y) at the nth scale, specifically: S124: Extract edge points: Filter the pixels in the phase consistency result map PC to obtain the edge point set, specifically: Wherein, T is the edge point extraction threshold; E is the coordinate set of the edge points of the plastic lens; are the horizontal and vertical coordinates of the lth edge point; The phase consistency result PC is at the pixel position The pixel value at .

4. The method for detecting surface defects of a plastic optical lens according to claim 2, characterized in that: The step S2 includes the following steps: S21: Fitting an ellipse model using the plastic lens edge point coordinate set: Using the least squares method, the sum of square errors of the edge points of the plastic lens is taken as the optimization target, specifically: Where Z is the error function; |E| is the total number of edge points of the plastic lens in E; is the center coordinate of the ellipse model; a and b are the major axis and minor axis of the ellipse model respectively; The parameters of the ellipse model are Take partial derivatives of a and b, set them to 0, and solve for the parameters of the fitted ellipse model a′ and b′; among them, is the center coordinate of the fitted ellipse model; a′ and b′ are the major axis and minor axis of the fitted ellipse model respectively; S22: Divide the inner and outer regions of the fitted elliptical model to obtain an optical zone mask: S221: Constructing the conditions for determining the area division: Through the fitted ellipse model, if the pixel is in the fitted ellipse model, it is in the optical area, otherwise it is in the non-optical area, and the pixel set R of the optical area is obtained. optical ; S222: Generate optical zone mask: The pixel values ​​of the pixels in the optical zone are set to 1, and the pixel values ​​of the pixels in the non-optical zone are set to 0, to generate the optical zone mask Mask.

5. The method for detecting surface defects of a plastic optical lens according to claim 4, characterized in that: The step S3 includes the following steps: S31: Perform image enhancement: The pixels in the optical zone of the plastic lens image I are enhanced using a local contrast enhancement method, wherein the local contrast enhancement method is: Among them, I enh (x,y) is the enhanced image I enh The pixel value at the pixel position (x, y); mean 5×5 (x,y) and std 5×5 (x, y) are the mean and standard deviation of the pixel values ​​in a local window of size 5×5 centered at the pixel position (x, y) of the plastic lens image I; Mask(x, y) is the pixel value of the optical zone mask Mask at the pixel position (x, y); S32: Feature extraction: Use the Laplace operator to extract features from the enhanced image and obtain the Laplace feature map I hp ; S33: Use binarization to screen potential defect areas: For Laplace characteristic graph I hp Apply the threshold τ for binarization, specifically: Wherein, B(x,y) is the pixel value of the potential defect image B at the pixel position (x,y); S34: Measure the length and width of the defect area: The length and width of the defect area are obtained using a two-dimensional measuring instrument, where the length and width of the defect area are the long side and the short side of the minimum circumscribed rectangle containing the defect area.

6. The method for detecting surface defects of a plastic optical lens according to claim 5, characterized in that: The step S4 includes the following steps: S41: Building a defect detection model: The VGG16 architecture is used as the defect detection model; VGG16 uses the plastic lens image I and the potential defect map B as input to obtain the input feature vector, specifically: Fea VGG =VGG16([I,B]) Among them, Fea VGG is the input feature vector, obtained before the fully connected layer of the VGG16 architecture, with a dimension of 4096; [I, B] is the input sample obtained by concatenating the plastic lens image I and the potential defect image B in the channel dimension; The length and width of the defect area are input into a separate fully connected layer and mapped to the input feature vector Fea VGG Same feature dimension and same as Fea VGG Add together to obtain the fused feature vector Fea fusion ; The fusion feature vector Fea fusion Input to the fully connected layer of the VGG16 architecture and use the normalized exponential function to calculate the defect probability vector, specifically: P=Softmax(MLP(Fea fusion )) Where P is a C-dimensional defect probability vector, each dimension of the vector corresponds to the probability of defects of different categories, and C is the total number of categories; Softmax is a normalized exponential function; MLP is the fully connected layer of the VGG16 architecture; S42: Training model: The model is trained using the cross entropy loss function, which is: Where Loss is the loss value; q is the sample number, q = 1, 2, ..., Q, Q is the number of training samples; cls is the category number, cls = 1, 2, ... C; is the true label of the qth labeled training sample. If the qth training sample input to the defect detection model belongs to the clsth class defect, it is 1, otherwise it is 0; The probability that the qth training sample input to the model belongs to the clsth class defect predicted by the defect detection model; The stochastic gradient descent method is used to iteratively optimize the parameters of the defect detection model to reduce the loss value Loss until the set number of iterations is reached to obtain the optimized model.

7. The method for detecting surface defects of a plastic optical lens according to claim 6, characterized in that: The step S5 includes the following steps: S51: Get the model prediction results: The plastic lens image without defect category labeling, the corresponding defect map generated by steps S1 to S3, and the length and width of the defect area obtained by the two-dimensional measuring instrument are input into the optimized model to obtain the probability vector predicted by the model. S52: Determine the final detection category: By predicting the probability vector of the model Perform the maximum value operation and select the category with the highest probability as the final defect category, specifically: in, The defect category number predicted by the defect detection model; The model predicts the probability that the sample input to the model belongs to the cls class of defects.

8. A system for detecting surface defects of plastic optical lenses, characterized in that: include: Edge detection module: performs phase consistency multi-scale edge detection on plastic lens images; Optical zone division module: Fitting an ellipse model based on the edge point set, and using the fitting results to divide the optical zone and non-optical zone; Potential defect extraction module: enhances and extracts features from pixels in the optical area, and screens potential defect areas through binarization to obtain potential defect maps, and uses a two-dimensional measuring instrument to obtain the length and width of the defect area; Model building module: build a defect detection model based on VGG16, and use labeled training samples to train and optimize the defect detection model; Model application module: Use the optimized model to detect plastic lens images without labeled defect categories; To realize a method for detecting surface defects of a plastic optical lens as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Static progressive surface region in optical communication with a dynamic optic

    CN101501552A

  • Method for calibrating cameras on basis of single-picture three-circle template

    CN103544699A

  • High-resolution remote sensing image segmentation method combining phase and spectrum

    CN109859219A

  • Contact lens edge defect detection method based on deep learning

    CN111062961A

  • VR lens defect detection method and system based on image cube and deep learning

    CN117197550A