Method for detecting defects on surfaces of various lenses
By collecting lens surface image data, pre-processing of lighting and environmental characteristics, building a multi-classifier model and using the region connection method to fill in subtle defects, the problem of model learning imbalance and overfitting in lens surface defect detection is solved, and efficient subtle defect detection is achieved.
Patent Information
- Application Number
- CN202510843740.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-08-12
AI Technical Summary
In the detection of lens surface defects, the model learns too much of normal lens samples, resulting in insufficient learning of defective lens samples and inability to effectively detect subtle defects. In addition, traditional methods have problems such as overfitting the model and high cost of data processing.
Image data on the lens surface is collected, different lighting and environmental characteristics are considered for preprocessing, and multi-classifier models are constructed, and undetected subtle defects are filled with the area connection method. The loss function optimization model training is used to alleviate the problems of overfitting and sample imbalance.
It improves the accuracy and practicality of lens surface defect detection, reduces data processing costs, can effectively detect subtle defects and balance sample learning, and improves the applicability of the model.
Smart Images

Figure CN120471908A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine vision processing technology, and in particular to a method for detecting defects on the surfaces of multiple types of lenses. Background Art
[0002] Computer vision is one of the hottest research topics today. It's a multidisciplinary field encompassing computer science (graphics, algorithms, theoretical research), mathematics (information retrieval, machine learning), engineering (robotics, natural language processing, etc.), biology (neuroscience), and psychology (cognitive science). Computer vision encompasses five main areas: image classification, object detection, object tracking, semantic segmentation, and object segmentation.
[0003] Currently, lens materials can be broadly categorized into glass, resin, crystal, PC, and MR lenses. Each material has its own advantages and disadvantages, and is used for various purposes. In daily life, the lens surface and the lens itself can easily develop defects such as scratches, oxidation, particle adhesion, and color aberration through long-term use or during the manufacturing process. Therefore, a method for detecting multiple types of lens surface defects has been developed.
[0004] Traditional methods for detecting lens surface defects typically employ neural networks or state-of-the-art YOLO models from machine vision technology, training the neural network or model to detect defects. However, using the YOLO model alone can lead to the model over-learning from normal lens samples and under-learning from defective lens samples, severely impacting its defect detection performance. Furthermore, YOLO is not adept at detecting subtle defects. While using neural networks alone can address subtle defect detection, it also requires addressing the issues of model overfitting and excessive data processing costs. Summary of the Invention
[0005] The purpose of this section is to summarize some aspects of the embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the abstract and title of this application to avoid obscuring the purpose of this section, the abstract and the title of the invention, and such simplifications or omissions should not be used to limit the scope of the present invention.
[0006] In view of the above existing problems, the present invention is proposed. Therefore, the present invention provides a method for detecting defects on the surface of multiple types of lenses to solve the problems mentioned in the background art.
[0007] To solve the above technical problems, the present invention provides the following technical solutions: a method for detecting defects on the surface of multiple types of lenses, comprising:
[0008] Collecting image data of the lens surface, considering the lens surface and environmental characteristics under different lighting conditions, and pre-processing the lens features;
[0009] Extracting pre-processed lens features, classifying lens surface defects contained in the features, and constructing a number of classifiers corresponding to the classification results;
[0010] Establishing a lens surface defect detection model, training the corresponding number of classifiers, judging each defect category during the training process, and obtaining all defect locations and defect severity levels under each category;
[0011] The defect positions are connected by using a region connection method, and undetected minor defects are filled, thereby obtaining a defect detection method for the lens surface.
[0012] As a preferred embodiment of the method for detecting defects on the surfaces of multiple types of lenses of the present invention, the lens features are pre-processed taking into account the lens surface and environmental characteristics under different lighting conditions, including:
[0013] According to the color deviation under different lighting conditions, the image data of the lens surface is divided into a white area and a black area, the pixel values in the image data of the lens surface in the white area are obtained, and white balance correction is performed;
[0014] The pixel value in the image data of the lens surface obtained from the black area for the first time is used as the reference value of the black area. The difference between the reference value and the pixel value in the image data of the lens surface obtained from the black area for the next time is calculated to obtain the color offset of the black area, and black balance correction is performed.
[0015] As a preferred embodiment of the method for detecting defects on the surfaces of multiple types of lenses of the present invention, the method further comprises:
[0016] Before obtaining pixel values in the image data of the lens surface in the white area and the black area, an ambient light removal algorithm is used to remove ambient light in the image data.
[0017] As a preferred embodiment of the method for detecting defects on multiple types of lens surfaces according to the present invention, the lens surface defects contained in the features are classified, and a number of classifiers corresponding to the classification results are constructed, including:
[0018] A convolutional neural network is defined, wherein the convolutional neural network includes several convolutional layers, wherein three of the convolutional layers include a pooling layer, and two softmax layers are added to the convolutional neural network;
[0019] Using a deepening hierarchical approach, the number of convolution kernels in each convolutional layer is expanded, and an RMSprop multi-classification optimizer is constructed to process lens surface defects. The last layers of the convolutional layers are connected through a fully connected layer to output all lens surface defect categories.
[0020] As a preferred embodiment of the method for detecting defects on multiple types of lens surfaces according to the present invention, a lens surface defect detection model is established, and the corresponding number of classifiers is trained, including:
[0021] Using the output of all lens surface defect categories as the input of a lens surface defect detection model, setting the working thread of the model and the number of epochs for model training, where N epochs constitute a training cycle T;
[0022] Define a model loss function, calculate the model loss value once after reaching the training cycle T, use the loss value together with the next training cycle T as the result of the current model training and update the model parameters.
[0023] As a preferred embodiment of the method for detecting defects on multiple lens surfaces of the present invention, the following steps are performed: judging each defect category during the training process, obtaining all defect locations and defect severity levels for each category, including:
[0024] The judgment method is to segment the defect categories in the current training process into several small defect detection areas and convert them into corresponding pixel matrix;
[0025] Assume that the defect-free position of the pixel is 0; take the pixel matrix as the original matrix, if the pixel in the converted pixel matrix is smaller than the original matrix size but does not exceed the original pixel size, it is marked as a surface physical defect, and the defect-free position of the corresponding pixel is modified to 1; if the pixel in the converted pixel matrix exceeds twice the size of the original matrix and does not exceed the boundary of the pixel matrix, it is marked as a surface contamination defect, and the defect-free position of the corresponding pixel is modified to 1; if the pixel in the converted pixel matrix exceeds the boundary of the original matrix, it is marked as a surface particle attachment defect, and the defect-free position of the corresponding pixel is modified to 1;
[0026] The surface physical defects are defined as severe defects, the surface contamination defects are defined as moderate defects, and the surface particle attachment is defined as slight defects.
[0027] As a preferred embodiment of the method for detecting defects on the surface of multiple types of lenses of the present invention, a region connection method is used to connect the defect locations and fill in the undetected minor defects, including:
[0028] The pixel point marked with the defect is used as the current starting point, and the left and right directions of the pixel point at the current starting point are connected respectively. If the adjacent directions to the left and right of the current pixel point do not contain 1, the defect detection is complete; otherwise, the defect-free position of the corresponding direction pixel point is modified to 1, and the left and right directions of the adjacent pixel points containing 1 are used as the next detection target. This process is repeated until all undetected minor defects are filled.
[0029] Compared with the prior art, the present invention has the following beneficial effects: by collecting image data of the lens surface, the present invention considers the lens surface and environmental characteristics under different lighting conditions, and pre-processes the lens features; extracts the pre-processed lens features, classifies the lens surface defects contained in the features, and constructs a number of classifiers corresponding to the classification results; establishes a lens surface defect detection model, trains the corresponding number of classifiers, judges each defect category during the training process, and obtains all defect locations and defect severity levels under each category; utilizes a region connection method to connect defect locations and fill in undetected minor defects, thereby obtaining a defect detection method for the lens surface; the present invention fully considers ambient lighting and color deviation and distributes lens surface defect detection; replaces the original optimizer with a loss function and constructs multiple classifiers through model training, thereby alleviating model overfitting, balancing the problem of too many or too few sample learning, and changing the model application limitations caused by the traditional automatic setting of working threads; by defining defect categories and region connections, all minor defects not detected by the classifier during model training are filled, reducing data processing costs and improving the practicality of the method. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort. Among them:
[0031] Figure 1 This is an overall flow chart of a method for detecting defects on surfaces of multiple types of lenses according to an embodiment of the present invention;
[0032] Figure 2 Schematic diagram of the overall processing of a method for detecting defects on surfaces of multiple types of lenses according to an embodiment of the present invention;
[0033] Figure 3 This is a comparison chart of different methods for detecting defects on multiple types of lens surfaces according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in this field without creative work should fall within the scope of protection of the present invention.
[0035] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0036] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0037] The present invention is described in detail with reference to schematic diagrams. For ease of illustration, cross-sectional views of device structures may be partially enlarged and not to scale when describing embodiments of the present invention. Furthermore, the schematic diagrams are merely illustrative and should not limit the scope of the present invention. Furthermore, in actual production, the three-dimensional dimensions of length, width, and depth should be included.
[0038] In the description of the present invention, it should be noted that the terms "upper, lower, inner, and outer" and other references to orientations or positional relationships are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first, second, or third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0039] In this disclosure, unless otherwise specified or limited, the terms "mounted," "connected," and "connected" should be interpreted broadly. For example, they may refer to fixed, removable, or integral connections. They may also refer to mechanical, electrical, or direct connections, indirect connections through an intermediary, or internal communication between two components. Those skilled in the art will understand the specific meanings of these terms in this disclosure.
[0040] Example 1
[0041] Reference Figure 1 and Figure 2, which is the first embodiment of the present invention, provides a method for detecting defects on the surface of multiple types of lenses, comprising:
[0042] S1. Collect image data of the lens surface, consider the lens surface and environmental characteristics under different lighting conditions, and pre-process the lens features;
[0043] Specifically, an industrial camera or a high-resolution sensor is used to collect image data of the lens surface;
[0044] Furthermore, considering the lens surface and environmental characteristics under different lighting conditions, it is necessary to divide the image data of the lens surface into white areas and black areas according to the color deviation under different lighting conditions, obtain the pixel values of the image data of the lens surface in the white areas, and perform white balance correction;
[0045] It should be noted that due to the different color temperatures under different lighting conditions, color deviation may occur in the image data of the lens surface. Therefore, it is necessary to perform white balance and black balance correction simultaneously to eliminate the color deviation in the image data, so that the subsequent pre-processing data is more realistic and accurate.
[0046] Furthermore, the pixel value in the first image data of the lens surface obtained from the black area is used as the black area reference value, and the difference between the reference value and the pixel value in the next image data of the lens surface obtained from the black area is calculated to obtain the color offset of the black area, and black balance correction is performed;
[0047] Furthermore, before obtaining pixel values in the image data of the lens surface in the white area and the black area, an ambient light removal algorithm is used to remove ambient light from the image data;
[0048] It should be noted that after eliminating the color deviation in the image data, the use of the environment removal algorithm can improve the overall brightness of the image data to highlight the defect features that can be identified by the naked eye in the image data, and send those that cannot be identified by the naked eye to the preprocessing of the lens surface defect image data;
[0049] S2. Extracting pre-processed lens features, classifying lens surface defects contained in the features, and constructing a number of classifiers corresponding to the classification results;
[0050] It should be noted that extracting the pre-processed lens features is equivalent to extracting the pre-processed lens surface defect image data;
[0051] Furthermore, a convolutional neural network is defined, where the convolutional neural network contains several convolutional layers, three of which have a pooling layer, and two softmax layers are added to the convolutional neural network;
[0052] Specifically, the two softmax functions form two branches in the neural network. The first branch extracts pre-processed lens features, while the second branch classifies the lens surface defects contained in the features.
[0053] Specifically, the following is an example of Python code defining the first branch and the second branch:
[0054] task1=Dense(num_classes1,activation='softmax',name='extractfeature')(x_task1);
[0055] task2=Dense(num_classes2,activation='softmax',name='classification')(x_task2);
[0056] Among them, task1 and task2 represent the first branch and the second branch respectively; num_classes1 and num_classes2 represent the number of tasks in the first branch and the second branch respectively; activation refers to the currently triggered action, that is, the current execution layer; x_task1 and x_task2 represent the outputs of the first branch and the second branch respectively;
[0057] It should be noted that the traditional RMSprop classifier is relatively simple in the design of the convolutional layer, with a small number of kernels and limited feature extraction capabilities; it is difficult to capture complex image features and structures, resulting in limited classification performance of the model;
[0058] Preferably, the classifier of the present invention expands the number of convolution kernels in the convolution layer based on the RMSprop classifier. This ensures the robustness of the subsequent model construction and the efficiency of the classifier in processing lens features. It also alleviates the overfitting caused by subsequent model training to a certain extent and balances the problem of too many or too few samples in learning.
[0059] Furthermore, we use a deeper layer approach to expand the number of convolution kernels in each convolutional layer, build an RMSprop multi-classification optimizer to process lens surface defects, and connect the last layers of several convolutional layers through a fully connected layer to output all lens surface defect categories.
[0060] Specifically, according to actual needs, the number of convolution kernels in each convolution layer can be expanded, for example, 1×1 can be expanded to 3×3, 3×3 can be expanded to 5×5, 5×5 can be expanded to 7×7, and so on;
[0061] S3. Establish a lens surface defect detection model, train the corresponding number of classifiers, judge each defect category during the training process, and obtain all defect locations and defect severity levels under each category;
[0062] Specifically, the following is an example of a lens surface defect detection model defined by Python code:
[0063] model=Model(inputs=outputs, outputs=[task1, task2]);
[0064] Furthermore, all lens surface defect categories are output as input to the lens surface defect detection model, and the model's working thread and the number of epochs for model training are set, with N epochs being a training cycle T.
[0065] It should be noted that traditional defect detection models usually do not directly set worker threads. Instead, they indirectly control the model's parallel computing by selecting appropriate deep learning frameworks and optimizers. However, this approach does not make the model applicable when it is improved or applied to other platforms.
[0066] Preferably, the lens surface defect detection model of the present invention is configured with 2 working threads, which can well match the two softmax functions mentioned above. This is because the value of the working thread should not be too large or too small, and only two softmax functions are added to the convolutional neural network. In addition, considering the portability of the model, no additional working threads are required, further reducing the memory usage of the model.
[0067] Furthermore, a model loss function is defined. After reaching the training cycle T, the model loss value is calculated once. The calculated model loss value and the next training cycle T are used as the result of the current model training and the model parameters are updated.
[0068] It should be noted that the loss function of the model is defined because only the classifier is defined in the previous section, but the optimizer is missing. In general defect detection models, classifiers and optimizers are indispensable. Therefore, the loss function of the model is defined here to replace the classifier, so that the subsequent model loss value and training cycle T can achieve the effect of optimizer iteration, that is, to obtain the minimum model loss value.
[0069] Furthermore, each defect category in the model training process is judged to obtain the locations and severity of all defects in each category. The judgment method is to segment the defect category in the current training process into several small defect detection areas and convert them into corresponding pixel matrix;
[0070] Furthermore, the defect-free position of the pixel is set to 0; the pixel matrix is used as the original matrix. If the pixel in the converted pixel matrix is smaller than the original matrix size but does not exceed the original pixel size, it is marked as a surface physical defect, and the defect-free position of the corresponding pixel is modified to 1; if the pixel in the converted pixel matrix exceeds twice the size of the original matrix and does not exceed the boundary of the pixel matrix, it is marked as a surface contamination defect, and the defect-free position of the corresponding pixel is modified to 1; if the pixel in the converted pixel matrix exceeds the boundary of the original matrix, it is marked as a surface particle attachment defect, and the defect-free position of the corresponding pixel is modified to 1;
[0071] It should be noted that the original matrix is the distance difference between the lens surface and its own defects (concave and convex) or particles attached to it; when the distance difference is 0, it means that the lens is defect-free, that is, the pixel position without defects is 0; when there is a distance difference, it means that the lens is defective, that is, the pixel position without defects is 1;
[0072] Specifically, if the pixels in the converted pixel matrix are smaller than the original matrix size but not larger than the original pixel size, it indicates that the defect is deep (possibly concave or irregularly lined), usually fragmentation, cracks, pits or scratches; if the pixels in the converted pixel matrix exceed twice the size of the original matrix and do not exceed the boundary of the pixel matrix, it indicates that the defect is large and does not involve (deformation, extrusion, pits or scratches, etc.), usually stains, water marks and oily substances; if the pixels in the converted pixel matrix exceed the boundary of the original matrix, it indicates that the defect is light, usually particles, dust and fibers attached to the lens surface;
[0073] Furthermore, surface physical defects are defined as severe defects, surface contamination defects as moderate defects, and surface particle attachment as minor defects;
[0074] S4. Using a region connection method, connecting defect locations and filling undetected minor defects, thereby obtaining a defect detection method for the lens surface;
[0075] It should be noted that surface physical defects may cause cracks and fragmentation, and the corresponding pixel matrix after conversion is not easy to identify these subtle defects, that is, there may be undetectable problems between adjacent pixels;
[0076] Furthermore, the pixel point marked with the defect is used as the current starting point, and the left and right directions of the pixel point at the current starting point are connected. If the adjacent directions to the left and right of the current pixel point do not contain 1, the defect detection is complete; otherwise, the non-defective position of the corresponding direction pixel point is modified to 1, and the left and right directions of the adjacent pixel points containing 1 are used as the next detection target. This process is repeated until all undetected minor defects are filled;
[0077] It should be noted that in the pixel matrix, the pixels are connected starting from the upper left corner. When the pixel reaches the upper right corner, it turns to the next row of the upper left corner for connection; and so on, left 1, right 1, left 2, right 2, ... left N, right N, and similarly, until the current pixel position is detected to be the lower right corner.
[0078] Example 2
[0079] Reference Figure 3 , which is a second embodiment of the present invention, provides a method for detecting defects on the surface of multiple types of lenses, comprising: further verifying the beneficial effects of the solution of the present invention through simulation experiments;
[0080] The sample set ObjectNet is used as a reference standard. ImageNet has 313 object classes, including 113 overlapping object classes. These overlapping object classes contain overlapping images. The sample set is randomly selected and captured at unusual angles. This is a test in a complex environment, which can accurately measure model performance and defect detection accuracy.
[0081] We obtained a test set of 30,000 as the lens defect detection test set for the model, loaded the lens surface defect detection model created in the solution, tested it using different classifiers and neural networks, and decoded the test results to obtain the model's classification and accuracy for lens surface defect testing, and presented the results; see Table 1;
[0082] Table 1. Accuracy of defect detection by different classifiers and neural networks
[0083]
[0084] As shown in Table 1, the method of the present invention outperforms the methods used in other models in the cases of deep defects, large defects, and light defects, with an average performance increase of 2% to 8%. This is because we discard the traditional optimizer and use the loss function in the model instead, without the need for further iteration. This eliminates the traditional model iteration step, fully alleviates model overfitting, and balances sample learning in model training.
[0085] refer to Figure 3 The accuracy of the method of the present invention is higher than that of other methods, and is 5% higher than the method with the highest accuracy. This is because through subsequent defect filling, the model overcomes the omission of large data or complex data, making the model method more practical.
[0086] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Furthermore, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present application may be implemented in various computer languages, for example, object-oriented programming language Java and interpreted scripting language JavaScript, etc.
[0087] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0088] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0089] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0090] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0091] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A method for detecting defects on the surface of multiple types of lenses, characterized in that: include: Collecting image data of the lens surface, considering the lens surface and environmental characteristics under different lighting conditions, and pre-processing the lens features; Extracting pre-processed lens features, classifying lens surface defects contained in the features, and constructing a number of classifiers corresponding to the classification results; Establishing a lens surface defect detection model, training the corresponding number of classifiers, judging each defect category during the training process, and obtaining all defect locations and defect severity levels under each category; The defect positions are connected by using a region connection method, and undetected minor defects are filled, thereby obtaining a defect detection method for the lens surface.
2. The method for detecting defects on the surfaces of multiple types of lenses according to claim 1, wherein: Considering the lens surface and environmental characteristics under different lighting conditions, the lens features are pre-processed, including: According to the color deviation under different lighting conditions, the image data of the lens surface is divided into a white area and a black area, the pixel values in the image data of the lens surface in the white area are obtained, and white balance correction is performed; The pixel value in the image data of the lens surface obtained from the black area for the first time is used as the reference value of the black area. The difference between the reference value and the pixel value in the image data of the lens surface obtained from the black area for the next time is calculated to obtain the color offset of the black area, and black balance correction is performed.
3. The method for detecting defects on the surfaces of multiple types of lenses according to claim 2, wherein: Also includes: Before obtaining pixel values in the image data of the lens surface in the white area and the black area, an ambient light removal algorithm is used to remove ambient light in the image data.
4. The method for detecting defects on the surfaces of multiple types of lenses according to claim 3, wherein: Classify the lens surface defects contained in the features, and construct a number of classifiers corresponding to the classification results, including: A convolutional neural network is defined, wherein the convolutional neural network includes several convolutional layers, wherein three of the convolutional layers include a pooling layer, and two softmax layers are added to the convolutional neural network; Using a deepening hierarchical approach, the number of convolution kernels in each convolutional layer is expanded, and an RMSprop multi-classification optimizer is constructed to process lens surface defects. The last layers of the convolutional layers are connected through a fully connected layer to output all lens surface defect categories.
5. The method for detecting defects on the surfaces of multiple types of lenses according to claim 4, wherein: Establish a lens surface defect detection model and train the corresponding number of classifiers, including: Using the output of all lens surface defect categories as the input of a lens surface defect detection model, setting the working thread of the model and the number of epochs for model training, where N epochs constitute a training cycle T; Define a model loss function, calculate the model loss value once after reaching the training cycle T, use the loss value together with the next training cycle T as the result of the current model training and update the model parameters.
6. The method for detecting defects on the surfaces of multiple types of lenses according to claim 5, wherein: Each defect category in the training process is judged to obtain all defect locations and defect severity in each category, including: The judgment method is to segment the defect categories in the current training process into several small defect detection areas and convert them into corresponding pixel matrix; Assume that the defect-free position of the pixel is 0; take the pixel matrix as the original matrix, if the pixel in the converted pixel matrix is smaller than the original matrix size but does not exceed the original pixel size, it is marked as a surface physical defect, and the defect-free position of the corresponding pixel is modified to 1; if the pixel in the converted pixel matrix exceeds twice the size of the original matrix and does not exceed the boundary of the pixel matrix, it is marked as a surface contamination defect, and the defect-free position of the corresponding pixel is modified to 1; if the pixel in the converted pixel matrix exceeds the boundary of the original matrix, it is marked as a surface particle attachment defect, and the defect-free position of the corresponding pixel is modified to 1; The surface physical defects are defined as severe defects, the surface contamination defects are defined as moderate defects, and the surface particle attachment is defined as slight defects.
7. The method for detecting defects on the surfaces of multiple types of lenses according to claim 6, wherein: Using the area connection method, the defect locations are connected and undetected minor defects are filled, including: The pixel point marked with the defect is used as the current starting point, and the left and right directions of the pixel point at the current starting point are connected respectively. If the adjacent directions to the left and right of the current pixel point do not contain 1, the defect detection is complete; otherwise, the defect-free position of the corresponding direction pixel point is modified to 1, and the left and right directions of the adjacent pixel points containing 1 are used as the next detection target. This process is repeated until all undetected minor defects are filled.
Citation Information
Patent Citations
Image color correction model training method and device and electronic equipment
CN112634143A
Part defect detection method and device, medium and computer program product
CN113421263A
Stripe detection method for optical glass prefabricated member
CN115147429A
Rail locomotive surface defect detection method and system
CN116416234A
Metal diaphragm surface defect detection method based on cross feature fusion
CN116452556A