Lens defect detection method and system, readable storage medium and computer
Through image preprocessing, feature extraction and contour feature algorithms, combined with intersection ratio analysis, lens defect prediction frames and regions are generated, which solves the problems of weak generalization ability and slow detection speed of existing lens defect detection methods, and achieves efficient lens Defect detection.
Patent Information
- Application Number
- CN202410678869.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-09-03
AI Technical Summary
Existing lens defect detection methods have weak generalization capabilities, slow detection speed, and cannot effectively handle different types of defects.
Using image preprocessing, feature extraction, anchor frame prediction, edge detection and contour feature algorithms, combined with intersection and union ratio analysis, the lens defect prediction frame and area are generated to determine the real defect information.
It improves the efficiency and accuracy of lens defect detection, can quickly extract defect feature information, visually presents the location and size of defects, and improves detection efficiency.
Smart Images

Figure CN118587177A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a lens defect detection method, system, readable storage medium and computer. Background Art
[0002] With the rapid development of science and technology and the improvement of people's living standards, electronic products have gradually changed people's lifestyles, which has a great impact on people's eye health, thus making glasses.
[0003] The market for glasses is gradually growing.
[0004] There are many varieties of glasses at present, such as reading glasses, myopia glasses, polarized glasses, decorative glasses, etc. The most important component of glasses is the lens, and the integrity of its surface is the criterion for determining the quality of its optical characteristics. However, during the production and processing process, technical or environmental factors may cause scratches, abrasions and other defects, which will seriously damage the optical properties of the lens and thus affect the use value of the glasses.
[0005] The current lens defect detection method uses an adaptive threshold algorithm to perform binary segmentation on the lens defect image and classifies and detects defects based on relevant information such as the location and size of the defects. However, manually designed feature extraction algorithms are required for different types of defects, and their generalization ability is weak and the detection speed is slow. Summary of the invention
[0006] Based on this, an object of the present invention is to provide a lens defect detection method, system, readable storage medium and computer to at least solve the deficiencies in the above-mentioned technology.
[0007] The present invention provides a lens defect detection method, comprising: Acquire a lens image to be tested, and perform image preprocessing on the lens image to be tested to eliminate noise in the lens image to be tested to obtain a preprocessed image; Performing feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image; Perform anchor frame prediction on each of the feature images and the lens image to be tested, and generate a defect prediction frame of the lens image to be tested based on the anchor frame prediction result; Performing edge detection on each of the feature images, and calculating the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and constructing a defect area of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result; The defect prediction frame and the defect area are subjected to an intersection-and-union analysis, and real defect information of the lens image to be tested is determined based on the intersection-and-union analysis result, and the defect type of the lens image to be tested is determined using the real defect information.
[0008] Furthermore, the step of performing image preprocessing on the lens image to be tested to eliminate noise in the lens image to be tested to obtain a preprocessed image includes: Acquire the size data of the lens image to be tested, and perform filtering processing on the lens image to be tested according to the size data to obtain a preliminary filtered image; A convolution operation is performed on the preliminary filtered image, and a mean filtering process is performed according to the convolution operation result to obtain a filtered image.
[0009] Furthermore, the step of performing feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image includes: Performing interlaced sampling on the preprocessed image, and performing image stitching based on the channel dimension of the preprocessed image to obtain a plurality of channel images; A convolutional neural network model is used to extract features from each of the channel images to obtain feature images corresponding to each of the channel images.
[0010] Furthermore, the step of performing anchor frame prediction on each of the feature images and the lens image to be tested, and generating a defect prediction frame of the lens image to be tested based on the anchor frame prediction result includes: Generate an anchor frame for the lens image to be tested according to each of the feature images, and predict the corresponding prediction frame according to the generated anchor frame; A mapping relationship between the anchor frame and the prediction frame is constructed, and the prediction frame is cyclically corrected until the error between the prediction frame and the anchor frame is less than a preset threshold, so as to obtain a defect prediction frame of the lens image to be tested.
[0011] Furthermore, the step of performing edge detection on each of the feature images, calculating the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and constructing the defect area of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result includes: Performing edge detection on each of the feature images to identify edge information of each of the feature images; Defining rotation parameters, and calculating the bounding rectangle of each of the feature images according to the rotation parameters, and taking the bounding rectangle with the smallest rectangular area as the minimum bounding rectangle of each of the feature images; The defect area of the lens image to be tested is constructed according to the edge information and the minimum circumscribed rectangle.
[0012] The present invention also provides a lens defect detection system, characterized in that it comprises: An image preprocessing module, used for acquiring an image of the lens to be tested, and performing image preprocessing on the image of the lens to be tested to eliminate noise in the image of the lens to be tested to obtain a preprocessed image; A feature processing module, used for performing feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image; An anchor frame prediction module, used for performing anchor frame prediction on each of the feature images and the lens image to be tested, and generating a defect prediction frame of the lens image to be tested based on the anchor frame prediction result; A region construction module, used to perform edge detection on each of the feature images, calculate the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and construct the defect region of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result; The type judgment module is used to perform an intersection-and-union analysis on the defect prediction frame and the defect area, determine the real defect information of the lens image to be tested based on the intersection-and-union analysis result, and determine the defect type of the lens image to be tested using the real defect information.
[0013] Furthermore, the image preprocessing module includes: A filtering processing unit, used for acquiring the size data of the lens image to be tested, and filtering the lens image to be tested according to the size data to obtain a preliminary filtered image; The convolution operation unit is used to perform a convolution operation on the preliminary filtered image and perform mean filtering according to the convolution operation result to obtain a filtered image.
[0014] Furthermore, the feature processing module includes: An interlaced sampling unit, used for performing interlaced sampling on the preprocessed image, and performing image stitching based on the channel dimension of the preprocessed image to obtain a plurality of channel images; The feature extraction unit is used to extract features from each of the channel images using a convolutional neural network model to obtain a feature image corresponding to each of the channel images.
[0015] Furthermore, the anchor box prediction module includes: An anchor frame generating unit, used for generating anchor frames for the lens image to be tested according to each of the feature images, and performing prediction according to the generated anchor frames to obtain corresponding prediction frames; The anchor frame prediction unit is used to construct a mapping relationship between the anchor frame and the prediction frame, and cyclically correct the prediction frame until the error between the prediction frame and the anchor frame is less than a preset threshold, so as to obtain a defect prediction frame of the lens image to be tested.
[0016] Furthermore, the regional construction module includes: An edge detection unit, used to perform edge detection on each of the feature images to identify edge information of each of the feature images; A rectangle construction unit, used to define rotation parameters, and calculate the bounding rectangle of each of the feature images according to the rotation parameters, and take the bounding rectangle with the smallest rectangular area as the minimum bounding rectangle of each of the feature images; The region construction unit is used to construct the defect region of the lens image to be tested according to the edge information and the minimum circumscribed rectangle.
[0017] The present invention also provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned lens defect detection method is implemented.
[0018] The present invention also provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned lens defect detection method when executing the computer program.
[0019] The lens defect detection method, system, readable storage medium and computer of the present invention pre-process the lens image to be tested to eliminate the noise in the lens image to be tested; perform anchor frame prediction on the feature image, and generate a defect prediction frame of the lens image to be tested based on the anchor frame prediction result, so as to more intuitively present information such as the location and size of the defect; use the contour feature algorithm to calculate the minimum circumscribed rectangle of each feature image, so as to quickly extract the feature information of the defect in the lens image to be tested, and use the intersection-union analysis method to determine the real defect information of the lens image to be tested, thereby improving the efficiency of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of a lens defect detection method in a first embodiment of the present invention; Figure 2 for Figure 1 Detailed flow chart of step S101; Figure 3 for Figure 1 Detailed flow chart of step S102; Figure 4 for Figure 1 Detailed flow chart of step S103; Figure 5 for Figure 1 Detailed flow chart of step S104; Figure 6 is a structural block diagram of a lens defect detection system in a second embodiment of the present invention; Figure 7 FIG. 4 is a structural block diagram of a computer in a third embodiment of the present invention.
[0021] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0022] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0024] Embodiment 1 See also Figure 1 , which shows a lens defect detection method in a first embodiment of the present invention, the method specifically comprises steps S101 to S105: S101, acquiring an image of a lens to be tested, and performing image preprocessing on the image of the lens to be tested to eliminate noise in the image of the lens to be tested to obtain a preprocessed image; For further information, see Figure 2 , the step S101 specifically includes steps S1011~S1012: S1011, acquiring the size data of the lens image to be tested, and filtering the lens image to be tested according to the size data to obtain a preliminary filtered image; S1012, performing a convolution operation on the preliminary filtered image, and performing mean filtering processing according to the convolution operation result to obtain a filtered image.
[0025] In a specific implementation, the lens image of the lens to be tested is collected by a pre-installed image acquisition device, wherein the image acquisition device has a data communication function and uploads the collected image data to the corresponding server. The size data of the lens image to be tested obtained above is read, and each pixel point in the digital sequence of the lens image to be tested is replaced with the median value of the point in the point field according to the size data, so as to smooth the lens image to be tested and eliminate the noise therein, and obtain the corresponding preliminary filtered image; Furthermore, a convolution operation is performed on the preliminary filtered image, the grayscale values of the pixels around each pixel in the preliminary filtered image are weighted averaged, the obtained grayscale value replaces the pixel, and the preliminary filtered image is subjected to secondary filtering to obtain a corresponding filtered image. S102, performing feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image; For further information, see Figure 3 , the step S102 specifically includes steps S1021~S1022: S1021, performing interlaced sampling on the preprocessed image, and performing image stitching based on the channel dimension of the preprocessed image to obtain a plurality of channel images; S1022, using a convolutional neural network model to perform feature extraction on each of the channel images to obtain a feature image corresponding to each of the channel images.
[0026] In a specific implementation, the pre-processed image obtained above is subjected to interlaced sampling, and image splicing is performed according to the channel dimension of the pre-processed image, the pre-processed image is reduced to half of the original in terms of height and width, and expanded to four times of the original in terms of channel dimension, and interlaced sampling is performed on this basis to obtain a plurality of channel images; Furthermore, the channel image is input into the convolutional neural network model, and its features are extracted using the two convolutional layers of the convolutional neural network model. A residual edge is added, and the extracted feature data is added to the channel image to output the corresponding feature image.
[0027] In this embodiment, the convolutional neural network model includes two convolutional layers, wherein the first convolutional layer is composed of 1*1 convolutional blocks, and the second convolutional layer is composed of 3*3 convolutional blocks.
[0028] S103, performing anchor frame prediction on each of the feature images and the lens image to be tested, and generating a defect prediction frame of the lens image to be tested based on the anchor frame prediction result; For further information, see Figure 4 , the step S103 specifically includes steps S1031~S1032: S1031, generating an anchor frame for the lens image to be tested according to each of the feature images, and performing prediction according to the generated anchor frame to obtain a corresponding prediction frame; S1032, constructing a mapping relationship between the anchor frame and the prediction frame, and cyclically correcting the prediction frame until the error between the prediction frame and the anchor frame is less than a preset threshold, so as to obtain a defect prediction frame of the lens image to be tested.
[0029] In a specific implementation, in order to accurately express the defects of the detected lens image, a prediction frame is generated to reflect the location, size and other information of the defects. An anchor frame is generated for the lens image to be tested according to the characteristic images obtained above, wherein a number of anchor frames are preset based on the actual size of the defects in the lens image to be tested, and the lens image to be tested is predicted according to the anchor frames to obtain the corresponding prediction frames. At the same time, a mapping relationship between the anchor frames and the prediction frames is constructed, and the prediction frames are cyclically corrected according to the mapping relationship until the error between the prediction frame and the anchor frame is less than a preset threshold (in this embodiment, the preset threshold is 10%). The smaller the error, the closer the size of the prediction frame is to the size of the anchor frame, which means that the prediction frame is closer to the size of the actual defect, thereby obtaining a defect prediction frame of the lens image to be tested.
[0030] S104, performing edge detection on each of the feature images, and calculating the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and constructing a defect area of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result; For further information, see Figure 5 , the step S104 specifically includes steps S1041 to S1043: S1041, performing edge detection on each of the feature images to identify edge information of each of the feature images; S1042, defining rotation parameters, and calculating the bounding rectangle of each of the feature images according to the rotation parameters, and taking the bounding rectangle with the smallest rectangular area as the minimum bounding rectangle of each of the feature images; S1043: construct a defect area of the lens image to be tested according to the edge information and the minimum circumscribed rectangle.
[0031] In a specific implementation, edge detection is performed on each feature image to identify edge information of each feature image, wherein the edge information is information related to the defect position in the feature image, a rotation parameter is defined, and the rotation parameter is a rotation angle. A rectangular frame is first constructed according to the calculated edge information, and the center point of the rectangular frame is defined as the origin. The rectangular frame is rotated at the rotation angle, and the rectangle is circumscribed with the edge information each time it rotates, thereby obtaining multiple circumscribed rectangles of each feature image. The area of the obtained rectangle is calculated each time it rotates, and the circumscribed rectangle with the smallest area among the rectangular areas is used as the minimum circumscribed rectangle of each feature image. The obtained minimum circumscribed rectangle is combined with the edge information obtained above to construct the defect area of the real defect in the lens image to be tested.
[0032] S105, performing an intersection-and-union analysis on the defect prediction frame and the defect region, determining real defect information of the lens image to be tested based on the intersection-and-union analysis result, and determining the defect type of the lens image to be tested using the real defect information.
[0033] In the specific implementation, the confidence level is defined, and the intersection-and-union ratio of the defect prediction box and the defect area is calculated. In this embodiment, the calculation formula of the intersection-and-union ratio is: ; ; ; ; In the formula, represents the defect prediction box; Indicates defective area; Represents the independent intersection-union ratio between the defect prediction box and the defect area; Indicates the difference in aspect ratio between the defect prediction box and the defect area, The larger the value, the greater the difference in aspect ratio; , Respectively represent the width and height of the defect prediction box; , Respectively represent the width and height of the defect area; represents the weight parameter; Represents the complete intersection-union ratio of the defect prediction box and the defect area; ,, Represent the center points of the defect prediction box and defect area respectively; Represents the center point of the defect prediction box and the center point of the defect area The Euclidean distance between Represents the diagonal distance between the defect prediction box and the minimum convex closed box of the defect area.
[0034] Furthermore, a corresponding confidence score is calculated based on the calculated complete intersection-over-union ratio, and real defect information of the lens image to be tested is determined based on the confidence score, and the defect type of the lens image to be tested is determined using the real defect information.
[0035] In summary, the lens defect detection method in the above-mentioned embodiment of the present invention pre-processes the lens image to be tested to eliminate the noise in the lens image to be tested; performs anchor frame prediction on the feature image, and generates a defect prediction frame of the lens image to be tested according to the anchor frame prediction result, so as to more intuitively present information such as the location and size of the defect; uses the contour feature algorithm to calculate the minimum circumscribed rectangle of each feature image, so as to quickly extract the feature information of the defect in the lens image to be tested, and uses the intersection-union analysis method to determine the real defect information of the lens image to be tested, thereby improving the efficiency of defect detection.
[0036] Embodiment 2 Another aspect of the present invention is to provide a lens defect detection system. Figure 6 , which is a lens defect detection system in a second embodiment of the present invention, the system comprises: An image preprocessing module 11 is used to obtain an image of the lens to be tested, and perform image preprocessing on the image of the lens to be tested to eliminate noise in the image of the lens to be tested to obtain a preprocessed image; Furthermore, the image preprocessing module 11 includes: A filtering processing unit, used for acquiring the size data of the lens image to be tested, and filtering the lens image to be tested according to the size data to obtain a preliminary filtered image; The convolution operation unit is used to perform a convolution operation on the preliminary filtered image and perform mean filtering according to the convolution operation result to obtain a filtered image.
[0037] A feature processing module 12 is used to perform feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image; Furthermore, the feature processing module 12 includes: An interlaced sampling unit, used for performing interlaced sampling on the preprocessed image, and performing image stitching based on the channel dimension of the preprocessed image to obtain a plurality of channel images; The feature extraction unit is used to extract features from each of the channel images using a convolutional neural network model to obtain a feature image corresponding to each of the channel images.
[0038] An anchor frame prediction module 13, used for performing anchor frame prediction on each of the feature images and the lens image to be tested, and generating a defect prediction frame of the lens image to be tested based on the anchor frame prediction result; Furthermore, the anchor box prediction module 13 includes: An anchor frame generating unit, used for generating anchor frames for the lens image to be tested according to each of the feature images, and performing prediction according to the generated anchor frames to obtain corresponding prediction frames; The anchor frame prediction unit is used to construct a mapping relationship between the anchor frame and the prediction frame, and cyclically correct the prediction frame until the error between the prediction frame and the anchor frame is less than a preset threshold, so as to obtain a defect prediction frame of the lens image to be tested.
[0039] The region construction module 14 is used to perform edge detection on each of the feature images, and calculate the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and construct the defect region of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result; Furthermore, the area construction module 14 includes: An edge detection unit, used to perform edge detection on each of the feature images to identify edge information of each of the feature images; A rectangle construction unit, used to define rotation parameters, and calculate the bounding rectangle of each of the feature images according to the rotation parameters, and take the bounding rectangle with the smallest rectangular area as the minimum bounding rectangle of each of the feature images; The region construction unit is used to construct the defect region of the lens image to be tested according to the edge information and the minimum circumscribed rectangle.
[0040] The type judgment module 15 is used to perform an intersection-and-union analysis on the defect prediction frame and the defect area, determine the real defect information of the lens image to be tested based on the intersection-and-union analysis result, and determine the defect type of the lens image to be tested using the real defect information.
[0041] The functions or operation steps implemented when the above modules and units are executed are generally the same as those in the above method embodiments, and will not be repeated here.
[0042] The lens defect detection system provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0043] Embodiment 3 The present invention also provides a computer, see Figure 7 , shown is a computer in the third embodiment of the present invention, including a memory 10, a processor 20, and a computer program 30 stored in the memory 10 and executable on the processor 20. When the processor 20 executes the computer program 30, the above-mentioned lens defect detection method is implemented.
[0044] The memory 10 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 10 may be an internal storage unit of a computer, such as a hard disk of the computer. In other embodiments, the memory 10 may also be an external storage device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Further, the memory 10 may also include both an internal storage unit of the computer and an external storage device. The memory 10 may be used not only to store application software and various types of data installed in the computer, but also to temporarily store data that has been output or is to be output.
[0045] Among them, in some embodiments, the processor 20 can be an electronic control unit (Electronic Control Unit, abbreviated as ECU, also known as a vehicle computer), a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor or other data processing chip, used to run the program code stored in the memory 10 or process data, such as executing access restriction programs, etc.
[0046] It should be pointed out that Figure 7 The structure shown does not constitute a limitation on the computer. In other embodiments, the computer may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0047] The embodiment of the present invention further provides a readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the lens defect detection method as described above is implemented.
[0048] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0049] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0050] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0051] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0052] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A lens defect detection method, characterized in that: include: Acquire a lens image to be tested, and perform image preprocessing on the lens image to be tested to eliminate noise in the lens image to be tested to obtain a preprocessed image; Performing feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image; Perform anchor frame prediction on each of the feature images and the lens image to be tested, and generate a defect prediction frame of the lens image to be tested based on the anchor frame prediction result; Performing edge detection on each of the feature images, and calculating the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and constructing a defect area of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result; The defect prediction frame and the defect area are subjected to an intersection-and-union analysis, and real defect information of the lens image to be tested is determined based on the intersection-and-union analysis result, and the defect type of the lens image to be tested is determined using the real defect information.
2. The lens defect detection method according to claim 1, characterized in that: The step of performing image preprocessing on the lens image to be tested to eliminate noise in the lens image to be tested to obtain a preprocessed image comprises: Acquire the size data of the lens image to be tested, and perform filtering processing on the lens image to be tested according to the size data to obtain a preliminary filtered image; A convolution operation is performed on the preliminary filtered image, and a mean filtering process is performed according to the convolution operation result to obtain a filtered image.
3. The lens defect detection method according to claim 1, characterized in that: The step of sequentially performing feature processing on the preprocessed image to obtain a feature image corresponding to the preprocessed image comprises: Performing interlaced sampling on the preprocessed image, and performing image stitching based on the channel dimension of the preprocessed image to obtain a plurality of channel images; A convolutional neural network model is used to extract features from each of the channel images to obtain feature images corresponding to each of the channel images.
4. The lens defect detection method according to claim 1, characterized in that: The steps of performing anchor frame prediction on each of the feature images and the lens image to be tested, and generating a defect prediction frame of the lens image to be tested based on the anchor frame prediction result include: Generate an anchor frame for the lens image to be tested according to each of the feature images, and predict the corresponding prediction frame according to the generated anchor frame; A mapping relationship between the anchor frame and the prediction frame is constructed, and the prediction frame is cyclically corrected until the error between the prediction frame and the anchor frame is less than a preset threshold, so as to obtain a defect prediction frame of the lens image to be tested.
5. The lens defect detection method according to claim 1, characterized in that: The steps of performing edge detection on each of the feature images, calculating the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and constructing the defect area of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result include: Performing edge detection on each of the feature images to identify edge information of each of the feature images; Defining rotation parameters, and calculating the bounding rectangle of each of the feature images according to the rotation parameters, and taking the bounding rectangle with the smallest rectangular area as the minimum bounding rectangle of each of the feature images; The defect area of the lens image to be tested is constructed according to the edge information and the minimum circumscribed rectangle.
6. A lens defect detection system, characterized in that: include: An image preprocessing module, used for acquiring an image of the lens to be tested, and performing image preprocessing on the image of the lens to be tested to eliminate noise in the image of the lens to be tested to obtain a preprocessed image; A feature processing module, used for performing feature processing on the preprocessed image in sequence to obtain a feature image corresponding to the preprocessed image; An anchor frame prediction module, used for performing anchor frame prediction on each of the feature images and the lens image to be tested, and generating a defect prediction frame of the lens image to be tested based on the anchor frame prediction result; A region construction module, used to perform edge detection on each of the feature images, calculate the minimum bounding rectangle of each of the feature images using a contour feature algorithm, and construct the defect region of the lens image to be tested based on the minimum bounding rectangle of each of the feature images and the edge detection result; The type judgment module is used to perform an intersection-and-union analysis on the defect prediction frame and the defect area, determine the real defect information of the lens image to be tested based on the intersection-and-union analysis result, and determine the defect type of the lens image to be tested using the real defect information.
7. The lens defect detection system according to claim 6, characterized in that: The image preprocessing module comprises: A filtering processing unit, used for acquiring the size data of the lens image to be tested, and filtering the lens image to be tested according to the size data to obtain a preliminary filtered image; The convolution operation unit is used to perform a convolution operation on the preliminary filtered image and perform mean filtering according to the convolution operation result to obtain a filtered image.
8. The lens defect detection system according to claim 6, characterized in that: The feature processing module comprises: An interlaced sampling unit, used for performing interlaced sampling on the preprocessed image, and performing image stitching based on the channel dimension of the preprocessed image to obtain a plurality of channel images; The feature extraction unit is used to extract features from each of the channel images using a convolutional neural network model to obtain a feature image corresponding to each of the channel images.
9. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the lens defect detection method as described in any one of claims 1 to 5 is implemented.
10. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the lens defect detection method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Product defect detection method, device and equipment and computer readable storage medium
CN112712513A
Defect detection method for LED and storage medium
CN113160128A
Feature detection method and device based on anchor frame
CN115690399A
Insulator defect detection method, device and equipment and storage medium
CN115953371A
PCB surface defect detection method based on improved YOLOv5 algorithm
CN116258707A
