High-precision multi-light-field contact lens flaw detection method and device based on cloud-machine vision
Through the multi-light field technology based on cloud-machine vision, multiple defects of contact lenses are detected, and the problems of low detection accuracy and insufficient universality in the prior art are solved, and high-precision automatic detection of contact lenses is achieved.
Patent Information
- Application Number
- CN202411476782.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art cannot effectively detect various defects in contact lenses, resulting in low detection accuracy and insufficient universality.
Using a high-precision multi-light field contact lens defect detection method based on cloud-machine vision, the geometric features of the glass bowl and the contour features of the printed contact lens are extracted to detect obvious defects and multi-light by acquiring and pre-processing the original image of the multi-light field, and extracting the geometric features of the glass bowl and the contour features of the printed contact lenses to perform obvious defect detection and multi-light Field surface defect detection.
It improves the accuracy and universality of the contour of contact lenses and the detection of multiple defects on the surface, reduces the cost of manual re-inspection, improves production efficiency and improves product yield.
Smart Images

Figure CN119477817A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud and machine vision technology, and in particular to a high-precision multi-light field contact lens defect detection method and device based on cloud-machine vision. Background Art
[0002] The main manufacturing methods of contact lenses include turning, casting, etc. Due to the different lens materials, various types of defects are prone to occur during the production process. For example, lens edge adhesion, deformation, multiple lenses, abnormal size, surface defects, etc.
[0003] In the prior art, detection is generally performed by using recognition models or template comparison, but the above detection methods are unable to fully detect a variety of defects. At the same time, there are problems such as low detection accuracy and low universality. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a high-precision multi-light field contact lens defect detection method and device based on cloud-machine vision to solve the problems in the background technology.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A high-precision multi-light field contact lens defect detection method based on cloud-machine vision of the present invention comprises the steps of:
[0007] Acquire a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and pre-process the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a pre-processed image, wherein the pre-processed image is obtained by filtering the bright field image;
[0008] Performing glass bowl detection on the preprocessed image, and extracting geometric features of the glass bowl when the glass bowl exists in the preprocessed image; performing contour feature extraction on the printed contact lens in the glass bowl area based on the geometric features of the glass bowl;
[0009] Obvious defect detection is performed based on the contour features of the printed contact lenses, wherein the obvious defects include lens edge contact, deformation, multiple lenses, and abnormal size; and edge bubble defect detection, edge defect detection in a Cartesian coordinate system and edge defect detection in a polar coordinate system, and surface defect detection based on multiple light fields are performed based on multiple characteristic images of the printed contact lenses, wherein the multiple characteristic images include contour features, point light source images, bright field images, dark field images, and preprocessed images.
[0010] The present application also provides a high-precision multi-light field contact lens defect detection device based on cloud-machine vision, comprising:
[0011] An acquisition and preprocessing module, used for acquiring a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and preprocessing the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a preprocessed image, wherein the preprocessed image is obtained by filtering the bright field image;
[0012] A feature extraction module, used to detect a glass bowl in the preprocessed image, and extract geometric features of the glass bowl when the glass bowl exists in the preprocessed image; and extract contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl;
[0013] The defect detection module is used to detect obvious defects based on the contour features of the printed contact lenses, wherein the obvious defects include lens edge contact, deformation, multiple lenses, and abnormal size; and to perform edge bubble defect detection, edge defect detection in a Cartesian coordinate system and edge defect detection in a polar coordinate system, and surface defect detection based on multiple light fields based on multiple feature images of the printed contact lenses, wherein the multiple feature images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
[0014] The beneficial effects of the present invention are as follows: a high-precision multi-light field contact lens defect detection method and device based on cloud-machine vision of the present invention obtains a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and pre-processes the multi-light field original image to obtain a point light source image, a bright field image, a dark field image and a pre-processed image; the pre-processed image is subjected to glass bowl detection, and when a glass bowl exists in the pre-processed image, the geometric features of the glass bowl are extracted; the printed contact lens in the glass bowl area is subjected to contour feature extraction based on the geometric features of the glass bowl; obvious defect detection is performed based on the contour features of the printed contact lens; and edge bubble defect detection, edge defect detection in a Cartesian coordinate system, edge defect detection in a polar coordinate system, and surface defect detection based on multi-light fields are performed based on multiple feature images of the printed contact lens. The present application performs multiple defect detection on the contour and surface of the printed contact lens, which has a corresponding improvement effect on the problems of low detection accuracy and low universality of the existing detection methods. At the same time, it can be widely used in the contact lens automated detection system, reducing the cost of manual re-inspection, improving production efficiency, and thus improving the final product yield. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0016] Figure 1 This is a schematic diagram of the computing algorithm in the cloud service of this application;
[0017] Figure 2is a flow chart of a high-precision multi-light field contact lens defect detection method based on cloud-machine vision shown in one embodiment of the present application;
[0018] Figure 3 A schematic diagram of the process of extracting the edge profile of the lens in this application;
[0019] Figure 4 A schematic diagram of the process of edge bubble detection in this application;
[0020] Figure 5 This is a schematic diagram of the process of lens lace detection in this application;
[0021] Figure 6 A schematic diagram of the process of detecting severe defects on the edge of a lens in this application;
[0022] Figure 7 This is a schematic diagram of the process of lens edge tear detection in this application;
[0023] Figure 8 This is a schematic diagram of the process of detecting excess material defects on the edge of the lens in this application;
[0024] Fig. 9 A schematic diagram of the process of detecting slight defects on the edge of a lens in this application;
[0025] Fig.10 This is a schematic diagram of the process of detecting slight defects on the edge of a lens based on bright field images in this application;
[0026] Fig.11 This is a schematic diagram of the process of detecting residual material defects on the edge of a lens based on bright field images in this application;
[0027] Fig.12 Schematic diagram of the process of edge roughness detection based on multi-light field images in this application. DETAILED DESCRIPTION
[0028] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0029] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show the layers related to the present invention rather than being drawn according to the number, shape and size of the layers in actual implementation. In actual implementation, the type, quantity and proportion of each layer may be changed arbitrarily, and the layer layout may also be more complicated.
[0030] In the following description, numerous details are discussed to provide a more thorough explanation of embodiments of the present invention; however, it is apparent to one skilled in the art that embodiments of the present invention may be practiced without these specific details.
[0031] In this application, the printed contact lens product is photographed by an industrial camera to obtain a corresponding grayscale image; the image is transmitted to an industrial computer and forwarded to a cloud server via the industrial computer for defect detection; the product inspection results are obtained and pushed to the industrial computer and subsequent data processing center.
[0032] Figure 1 This is a schematic diagram of the computing algorithm in the cloud service of this application, such as Figure 1 As shown, the algorithm of this application is mainly composed of 6 modules, including:
[0033] A. Initialization configuration module: responsible for initializing the configuration of the detection system, and reading, loading, color space conversion, noise reduction and other operations on the contact lens images collected by the camera to reduce the interference caused by environmental noise, and finally generate the Process Image;
[0034] B. Glass bowl detection module: responsible for extracting the small bowl ROI and determining the size of the small bowl.
[0035] C. Lens rough inspection module: responsible for using edge extraction algorithm on process image to extract lens edge contour and detect obvious defects of lens, including lens edge adhesion, deformation, multiple lenses, size abnormality, etc.
[0036] D. Lens edge detection module: responsible for three functions, namely edge bubble extraction, edge defect detection in Cartesian coordinate system and edge defect detection in polar coordinate system;
[0037] E. Lens surface detection module: responsible for two functions. First, ROI division and extraction of each area on the lens surface, and second, lens surface defect detection based on combining each ROI and multi-light field image;
[0038] F. Result analysis and generation module: Integrate the results in modules B to F to obtain the final lens test results.
[0039] G. Output module: Package and output the results in step F.
[0040] Before conducting formal testing, this application needs to load relevant configuration parameters. The parameter configuration process includes:
[0041] A1. The initialization configuration process is as follows.
[0042] A11. Import the configuration table file. This parameter configuration file contains lens system parameters, light source configuration parameters, algorithm configuration parameters, system setting parameters, etc. Among them, load the system configuration parameters to set whether to enable the surface detection module and whether to output images; load the algorithm parameters, including extraction parameters and analysis parameters, etc. The details are as follows:
[0043] For module B: small bowl area BlisterArea; effective small bowl radius (BlisterRL, BlisterRU), the former is the lower bound and the latter is the upper bound;
[0044] For module C: lens edge determination threshold T touch , the major and minor axis difference judgment threshold T abdif , lens aspect ratio threshold T edge_asp , lens size diameter setting threshold range LensDiaRange;
[0045] For module D: Lace threshold T flower , polar coordinate sampling angle deg, minimum edge detection size EMinL, minimum bright field edge detection grayscale BEMinG, minimum dark field edge detection grayscale DEMinG, minimum point light source edge detection grayscale PEMinG;
[0046] For module E: minimum surface detection size SMinL, minimum bright field surface detection grayscale BSMinG, minimum dark field surface detection grayscale DSMinG, minimum point light source surface detection grayscale PSMinG;
[0047] For module F: defect priority configuration table Priority;
[0048] Read and load the light source configuration parameters and verify them, load the light source parameters used by the system, and compare the parameters with the industrial computer light source system. If the light source settings are inconsistent, return the corresponding error code and exit the system, otherwise enter A14.
[0049] Initialize the image object related data structure used by the algorithm. In this embodiment, it includes the following:
[0050] Input image group, ImagePacket;
[0051] Apply the image group, LensImageGroup;
[0052] Polar coordinate image group, LensPolarImageGroup;
[0053] Defect data group, Set;
[0054] Initialize the relevant result objects used by the algorithm. This embodiment includes the following:
[0055] Step B, glass bowl detection result, BlisterResult;
[0056] Step C, edge extraction result, LensEdgeExtRes;
[0057] Step C, lens rough inspection result, LensRoughRes;
[0058] Step D, lens edge detection result, LensEdgeRes;
[0059] Step E, lens surface detection result, LensSurfaceInsRes;
[0060] Step F, detecting the final result, LensResult;
[0061] A12, read and load the light source configuration parameters and verify, load the light source parameters used by the system, and compare the parameters with the industrial computer light source system. If the light source settings are inconsistent, return the corresponding error code and exit the system, otherwise enter A14.
[0062] A13. Initialize the image object related data structure used by the algorithm. In this embodiment, the following is included:
[0063] Input image group, ImagePacket;
[0064] Apply the image group, LensImageGroup;
[0065] Polar coordinate image group, LensPolarImageGroup;
[0066] Defect data group, Set;
[0067] A14. Initialize the relevant result objects used by the algorithm. In this embodiment, the following is included:
[0068] Step B, glass bowl test result, BlisterResult
[0069] Step C, edge extraction result, LensEdgeExtRes;
[0070] Step C, lens rough inspection results, LensEdgeRes
[0071] Step D, lens edge detection result, LensEdgeRes
[0072] Step E: Lens surface detection result, LensSurfaceInsRes
[0073] Step F, detect the final result, LensResult
[0074] Figure 2 is a flow chart of a high-precision multi-light field contact lens defect detection method based on cloud-machine vision shown in an embodiment of the present application, such as Figure 2 As shown in the figure, a high-precision multi-light field contact lens defect detection method based on cloud-machine vision in this embodiment may include the following steps:
[0075] S210, acquiring a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and preprocessing the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a preprocessed image, wherein the preprocessed image is obtained by filtering the bright field image;
[0076] The process of preprocessing the multi-light field original image in this application includes:
[0077] A2, pre-processing:
[0078] A21 reads the image data transmitted by the camera, and according to the multi-light field settings of bright field, dark field, and point light source, that is, the multi-light field original image, splits the image data and converts it from RAW to RGB format, and temporarily stores it in imagePacket.
[0079] A22, transforms all light field image data in ImagePackett in A21 into grayscale space, obtains grayscale images and stores them in the corresponding array in LensImagrGroup, specifically including bright field image BrightImage, dark field image DarkImage, and point light source image.
[0080] A23, performs Gaussian filtering with a kernel of 3×3 and normalization stretching processing on the bright field image BrighImage in the LensImageGroup in A22 to obtain a denoised preprocessed image ProcessImage, the purpose of which is to reduce the interference caused by environmental noise.
[0081] S220, performing glass bowl detection on the preprocessed image, and extracting geometric features of the glass bowl when the glass bowl exists in the preprocessed image; and extracting contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl;
[0082] Glass bowl testing includes:
[0083] B. Glass bowl detection module: It is responsible for applying the segmentation algorithm to the preprocessed image ProcessImage and determining whether there is a glass bowl and whether the size is consistent based on the extracted relevant pixel content. Specifically, it includes:
[0084] B1, load the pre-processed image ProcessImage obtained in A23, the effective small bowl radius (BlisterRL, BlisterRU) and the glass bowl area BlisterArea configured in A11;
[0085] B2, binarizing the preprocessed image and extracting the contour features of the glass bowl in the binarized preprocessed image; applying a segmentation algorithm to the preprocessed image ProcessImage in B1 to perform binarization segmentation and extract the corresponding region of interest ROI;
[0086] B3. Fit the minimum inscribed circle of the glass bowl contour whose area is larger than the pre-configured glass bowl area BlisterArea to obtain the radius R and center C of the minimum inscribed circle. First, filter the contours extracted in B2 in turn by area. If it is larger than BlisterArea in B1, fit the minimum inscribed circle to the contour and obtain the radius R and center C of the circle, and then proceed to B4. If none of them are satisfied, end.
[0087] B4. Compare the radius R of the minimum inscribed circle with a preconfigured radius range (BlisterRL, BlisterRU), and when the radius of the minimum inscribed circle falls within the preconfigured radius range, determine that a glass bowl exists in the preprocessed image, and use the radius and center of the minimum inscribed circle as geometric features of the glass bowl.
[0088] Specifically, the radius R obtained in B3 is judged using (BlisterRL, BlisterRU) in B1. If R is not within the range, the result item in the glass bowl detection result BlisterResult is assigned "No Blister"; otherwise, it is considered that this module has passed and BlisterResult is assigned "Pass" and enters B5. The expression is as follows:
[0089]
[0090] B5. Store the radius R and center C obtained in B3 in BlisterResult.
[0091] S230, performing obvious defect detection based on the contour features of the printed contact lens, wherein the obvious defects include lens edge contact, deformation, multiple lenses, and abnormal size; and performing edge bubble defect detection, edge defect detection in a Cartesian coordinate system and edge defect detection in a polar coordinate system, and surface defect detection based on multiple light fields based on multiple feature images of the printed contact lens, wherein the multiple feature images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
[0092] Finally, detection is performed based on the various features extracted above. The detection content is as follows:
[0093] C. Lens rough inspection, responsible for: extraction of lens edge contour and detection of obvious lens defects, including lens edge adhesion, deformation, multiple lenses, abnormal size, etc., including:
[0094] C1. Contour extraction, Figure 3 The schematic diagram of the process of extracting the edge profile of the lens in this application is as follows: Figure 3 As shown, including:
[0095] C11, filtering and binarizing the preprocessed image to obtain a binary image C1a; specifically, performing two low-pass filtering processes on the preprocessed image ProcessImage generated by A, wherein the first filtering kernel size is 5×5, and the second filtering kernel size is a Gaussian kernel of 3×3, to obtain a filtered image Filtered; then performing an adaptive algorithm on the filtered image Filtered to obtain a binary image C1a;
[0096] C12. Constructing a glass bowl region BlisterROI based on the geometric features of the glass bowl; specifically, constructing a small bowl ROI, BlisterROI, using the small bowl fitting circle information (radius R and center C) stored in BlisterResult in B;
[0097] C13, constructing a first feature image C1fea based on the glass bowl region BlisterROI and the binary image C1a, wherein the mathematical expression of the first feature image C1fea is:
[0098]
[0099] Where, C1Fea i,j is the pixel with coordinates (i, j) in the first feature image C1fea, C1a i,j is the pixel with coordinates (i, j) in the binary image C1a, BlisterROI i,j is the pixel with coordinates (i, j) in the glass bowl region BlisterROI;
[0100] C14, extracting the contour features in the first feature image C1fea, and extracting the inner contour inner and the outer contour outer of the printed contact lens based on the pre-constructed lens parameters, wherein the lens parameters include the major and minor axis difference determination threshold T abdif , lens aspect ratio threshold T edge_asp , the lens size diameter sets the threshold interval LensDiaRange; fit the outer contour of the printed contact lens to obtain the ellipse contour ellipse. And save it to the data structure corresponding to LensEdgeExtRes, enter C15; if both the inner and outer contours do not exist, it is considered that there is no lens, and the result item in LensEdgeExtRes is assigned the value "NoLens" and exit;
[0101] C15, verify and integrate the internal and external contours saved in C14, and supplement the relevant data in LensEdgeExtRes, including the effective ROI area BlisterROI, the lens edge fitting ellipse ellipse, the number of detected contours edge_num, the edge feature data C1fea, etc.;
[0102] C2. Detection of obvious defects on lenses, including:
[0103] C21, using BlisterROI and ellipse integrated by LengsEdgeExtRes in C15 to judge the edge of the lens. It includes generating a lens area image based on the ellipse outline ellipse, and extracting the intersection image C21Img of the glass bowl area BlisterROI and the lens area image by "and" operation. When the number of pixels in the intersection image C21Img is greater than a preset number threshold, it is determined that there is a lens edge defect;
[0104] If the number of pixel values at the intersection is greater than the lens edge parameter threshold T in A12 touch , then the lens is considered to be touching the edge, the result item in LensRoughRes is assigned the value of "Touch" and exit, otherwise the next step, the expression is as follows;
[0105]
[0106] C22. When the printed contact lens only has an outer contour, it is determined that the lens has a large-scale edge defect;
[0107] Use edge_num in C15 to identify large-scale defects in the lens. If edge_num is not 2, that is, only the outer edge exists but not the inner edge, the lens is considered to have large-scale edge defects, and the result item in LensRoughRes is assigned the value "EdgeDefect" and exits. Otherwise, the next step is as follows:
[0108]
[0109] C23, extracting the major axis a and the minor axis b of the ellipse profile ellipse, calculating the difference between the major axis a and the minor axis b, and calculating the aspect ratio of the major axis a and the minor axis b; when the difference is greater than a preset major-minor axis difference threshold, or when the aspect ratio is less than a preset aspect ratio threshold, determining that the lens has a deformation defect;
[0110] The lens deformation is judged by using the major axis a and minor axis b in the ellipse in C15. If the difference between the major axis and the minor axis is greater than the difference between the major axis and the minor axis in A13, the threshold T is set. abdif , the lens is considered deformed; in addition, the aspect ratio of a and b is checked. If the aspect ratio is less than the preset lens aspect ratio threshold T edge_asp , the lens is considered deformed. If the lens is deformed, the result item in LensRoughRes is assigned the value "Distort" and exits, otherwise the next step is as follows:
[0111]
[0112] C24, extracting the ellipse center and assumed radius r of the ellipse outline, wherein the assumed radius Based on the ellipse center and the assumed radius r, the contour features in the first feature image Clfea are expanded in polar coordinates, and the average value and variance of the polar diameters of all contour pixel points in the polar coordinates are calculated, and a filtering range based on the 3sigma principle is constructed based on the average value and variance of the polar diameters, and contour points that do not fall into the filtering range are regarded as abnormal points. When the number of abnormal points is greater than a preset multiple-piece determination number threshold, it is determined that the lens has multiple defects;
[0113] Use C1fea and ellipse in C15 to detect whether the lens is "multiple". For C1fea, use the center of the ellipse EC in ellipse and the assumed radius of the major and minor axes. Polar coordinates are expanded, and the "multi-piece" detection is performed using an outlier detection algorithm based on mathematical statistics. That is, the mean and variance of the polar diameters of all contour pixel points in polar coordinates are used to construct a filtering range based on the 3sigma principle. Contour points that do not fall into the filtering range are regarded as outliers. When the number of outliers is greater than the preset multi-piece judgment threshold, it is considered to meet the "multi-piece" feature. The result item in LensRoughRes is assigned to "MutiLens" and exits. Otherwise, the next step is expressed as follows:
[0114]
[0115] C25, extract the major axis a and minor axis b of the ellipse, and use the major axis a and minor axis b in ellipse in C15 to determine the lens size. Calculate the mean d=mean(a,b) of the major axis a and the minor axis b, consider d as the lens diameter, and compare the mean d of the major axis a and the minor axis b with the preset lens size diameter setting threshold interval LensDiaRange. When the mean of the major axis a and the minor axis b is not within the preset lens size diameter setting threshold interval LensDiaRange, it is determined that the lens has a size non-compliant defect. If it is not within this size range, it is considered that the size does not match, and the result item in LensRoughRes is assigned to "Offsize" and exit, otherwise the next step, the expression is as follows:
[0116]
[0117] D. Lens edge detection module: responsible for using the edge extraction algorithm on the pre-processed image ProcessImage generated by A. It is mainly responsible for three functions, namely edge bubble extraction, edge defect detection in Cartesian coordinate system, and edge defect detection in polar coordinate system.
[0118] D1. Edge bubble detection, Figure 4 Schematic diagram of the process of edge bubble detection in this application, such as Figure 4 As shown, including:
[0119] D11, extracting the lens edge area of the bright field image based on the ellipse outline ellipse; specifically, constructing the lens edge area D1ROI by combining the ellipse information in LensRoughRes in C15 and the bright field image BrightImage in LensImageGroup, using parameters of the major axis a, the minor axis b, and the ellipse center EC;
[0120] D12, sequentially filtering, morphologically processing and binarizing the bright field image to obtain a bright field binary image D1bin;
[0121] D13, extracting edge features D1feature in the bright field binary image based on the edge area of the lens;
[0122] D14, extract edge features in the bright field binary image that meet the bubble features, and obtain edge bubble defect detection results. Specifically, it is necessary to combine the bright field image data BrightImage in LensImageGroup and the dark field image data DarkImage to perform feature analysis and filtering on the edge feature D1feature, and store the features that meet the edge bubble in D1EB. The bubble features include the roundness of the edge being greater than the preset roundness threshold, the length and width of the edge being greater than the preset bubble aspect ratio threshold, and the grayscale of the contour being less than the preset bubble grayscale threshold;
[0123] D15, reconstructing the outline of the bubble feature to obtain an edge bubble template image. Finally, using D1EB in D14 to reconstruct the edge bubble template image EdgeBubble in LensImageGroup, generating a corresponding edge bubble template image EdgeBubble.
[0124] D2. Defect detection based on Cartesian coordinates:
[0125] D21, Lens edge detection based on profile statistics, Figure 5 The flowchart of the lens lace detection in this application is as follows: Figure 5 As shown, including:
[0126] D211, use the convex hull extraction algorithm for the inner contour and outer contour of the printed contact lens to obtain the inner contour convex hull vertex inner_pt and the outer contour convex hull vertex outter_p;
[0127] D212, calculating the Euclidean distance between the vertices of the inner contour convex hull and the vertices of the outer contour convex hull one by one, and when the Euclidean distance is greater than a preset lace threshold, determining that the printed contact lens has a lace defect and storing the lace position;
[0128] Specifically, inner_pt and outer_pt are looped, and the Euclidean distance between them is judged. If the lace threshold T in A11 is met, flower , consider this point as the location of the "lace" and store it in Set;
[0129] D22, severe defect detection of lens edge, Figure 6 The schematic diagram of the process of detecting severe defects on the edge of the lens in this application is as follows: Figure 6 As shown, including:
[0130] D221, use the convex hull extraction algorithm for the inner contour inner stored in LensEdgeExtRes in C15 to obtain the inner contour convex hull image inner_hull;
[0131] D221, performing morphological processing on the inner contour convex hull image inner_hull to obtain an inner edge image inner_edg; performing a difference operation on the inner edge image inner_edg and the outer contour outter to obtain a first severe edge feature D22feature;
[0132] D223. Extract the minimum circumscribed rectangle of the first serious edge feature D22feature, and when the length of the minimum circumscribed rectangle of the first serious edge feature D22feature is greater than the preset minimum edge detection size, determine that the printed contact lens has serious defects on the lens edge; if satisfied, store to Set; otherwise, next one.
[0133] D23, lens edge tear detection, Figure 7 The schematic diagram of the process of detecting the tear at the edge of the lens in this application is as follows: Figure 7 As shown, including:
[0134] D231, use the convex hull extraction algorithm for the inner contour inner stored in LensEdgeExtRes in C15 to obtain the inner contour convex hull image inner_hull;
[0135] D232, performing morphological processing on the inner contour convex hull image inner_hull to obtain an inner edge image inner_edg;
[0136] D233, performing a median filter of size 3 on the inner edge image to obtain a median filter image to eliminate noise; and performing bubble interference elimination on the median filter image based on the edge bubble template image EdgeBubble to obtain a second severe edge feature D23feature;
[0137] When performing bubble interference elimination, the features in the edge bubble template image EdgeBublle in the median filter image can be eliminated. The same is true for the bubble interference elimination in the following text.
[0138] D234. Extract the geometric features of the second severe edge feature D23feature, wherein the geometric features of the second severe edge feature D23feature include length, width, aspect ratio, roundness, convexity, sharpness, and rectangularity. When the geometric features of the second severe edge feature meet a preset edge tearing condition, it is determined that the printed contact lens has an edge tearing defect; if the edge tearing condition is met, store the corresponding minimum circumscribed rectangle in Set, otherwise discard it.
[0139] The edge tearing conditions include:
[0140]
[0141] This means that for the feature image to be judged, its following geometric features satisfy:
[0142] The length is greater than the preset minimum tear detection length Min_spL;
[0143] The width width is greater than the preset minimum tear detection width Min_spW;
[0144] The aspect ratio aspect is within the preset aspect ratio tear detection interval (Min_spASP, Max_spASP), where Min_spASP is the lower limit of the aspect ratio tear detection interval and Max_spASP is the upper limit of the aspect ratio tear detection interval;
[0145] The roundness is within the preset roundness tear detection interval (Min_spRD, Max_spRD), where Min_spRD is the lower limit of the roundness tear detection interval and Max_spRD is the upper limit of the roundness tear detection interval;
[0146] The density convexity is within the preset density tear detection interval (Min_spConv, Max_spConv), where Min_spConv is the lower limit of the density tear detection interval and Max_spConv is the upper limit of the density tear detection interval;
[0147] The sharpness is within the preset sharpness tear detection interval (Min_spsharp, max_spsharp), Min_spsharp is the lower limit of the sharpness tear detection interval, and max_spsharp is the upper limit of the sharpness tear detection interval;
[0148] The rectangularity is within the preset rectangularity tear detection interval (Min_spRL, Max_spRL), Min_spRL is the lower limit value of the rectangularity tear detection interval, and max_spRL is the upper limit value of the rectangularity tear detection interval.
[0149] D24, lens edge residual material defect detection, Figure 8 The schematic diagram of the process of detecting residual material defects on the edge of the lens in this application is as follows: Figure 8 As shown, including:
[0150] D241, fitting the outer contour outter of the printed contact lens to obtain the outer contour ellipse outter_ellipse;
[0151] D242, calculate the Euclidean distance dis between the center D24EC (x, y) of the outer contour ellipse and all points of the outer contour i and angle i , where the Euclidean distance dis and the angle angle i The mathematical expression is:
[0152] dis i =sqrt((xp ix ) 2 +(yp iy ) 2 )
[0153]
[0154] In the formula, (i≤n), where (p ix ,p iy ) is the coordinate of each outer contour point, n is the length of the outer contour point, and finally the arrays dis and angle are obtained;
[0155] dis=(dis1,dis2,…,dis i )
[0156] angle=(angle1,angle2,…,angle i )
[0157] D243, Euclidean distance dis based on all points i and angle i Generate a Euclidean distance set dis and an angle set angle, perform normalization filtering and smoothing processing on the Euclidean distance set and the angle set, and generate a normalized, filtered and smoothed Euclidean distance set norm_dis;
[0158] D244, Euclidean distance set norm_dis and angle set angle based on normalized filtering and smoothing i Generate outer contour image fit img ;
[0159] D245, fitting the outer contour image based on the edge bubble template image EdgeBibble img Eliminate bubbles to obtain a second feature image D24feature;
[0160] D246, extracting contour features from the second feature image, the contour features including length', width', aspect', roundness', convexity', sharpness', and rectangularity'. When the contour features of the second feature image meet the preset edge residual material defect condition, it is determined that the printed contact lens has residual material defect (FLASH defect). If the edge residual material defect condition is met, the corresponding minimum circumscribed rectangle is stored in Set, otherwise it is discarded.
[0161] Residue defects refer to defects such as burrs and curling that occur on the edges of contact lenses when they are cut.
[0162] Among them, the edge material defect conditions include:
[0163]
[0164] This means that for the feature image to be judged, its following geometric features satisfy:
[0165] The length 'length' is greater than the preset minimum residual material detection length Min_flL;
[0166] The width width' is greater than the preset minimum residual material detection width Min_flW;
[0167] The aspect ratio aspect' is within the preset aspect ratio residual material detection interval (Min_flASP, Max_flASP), Min_fLASP is the lower limit value of the aspect ratio residual material detection interval, and Max_flASP is the upper limit value of the aspect ratio residual material detection interval;
[0168] Roundness' is within the preset roundness residual material detection interval (Min_flRD, Max_flRD), Min_flRD is the lower limit of the roundness residual material detection interval, and Max_fLRD is the upper limit of the roundness residual material detection interval;
[0169] Density convexity' is within the preset density residual material detection interval (Min_flConv, Max_flConv), Min_flConv is the lower limit of the density residual material detection interval, and Max_flConv is the upper limit of the density residual material detection interval;
[0170] Sharpness' is within the preset sharpness residual material detection interval (Min_flsharp, Max_flsharp), Min_flsharp is the lower limit value of the sharpness residual material detection interval, and Max_flsharp is the upper limit value of the sharpness residual material detection interval;
[0171] The rectangularity' is within a preset rectangularity residual material detection interval (Min_flRL, Max_flRL), where Min_flRL is the lower limit value of the rectangularity residual material detection interval, and Max_flRL is the upper limit value of the rectangularity residual material detection interval.
[0172] D3, defect detection based on polar coordinates;
[0173] D31. Generation of polar coordinate data set, including:
[0174] D311, perform secondary construction on the ellipse outline stored in LensEdgeExtRes in C16 to obtain the corresponding circle data, where the center of the circle is the ellipse center EC and the radius is Extract the ellipse center and radius of the ellipse outline ellipse;
[0175] D312, based on the center and radius of the ellipse, the point light source image, the bright field image, the dark field image, the inner contour of the printed contact lens and the outer contour of the printed contact lens are converted into polar coordinates to obtain a point light source polar coordinate image, a bright field polar coordinate image LensPolarImageGroup.bright, a dark field polar coordinate image LensPolarImageGroup.dark, an inner contour polar coordinate image LensPolarImageGroup.ineer and an outer contour polar coordinate image LensPolarImageGroup.outter;
[0176] Specifically, combined with EC and r in D331 and the polar coordinate sampling angle deg=0.2 configured in A11, the outer contour image, inner contour image, bright field, dark field, point light source image, etc. in LensImageGroup are transformed into polar coordinates. The corresponding image space coordinate system and polar coordinate system conversion is specifically to perform radial scanning with EC as the center point. In the polar coordinate system, the horizontal axis is the polar angle and the vertical axis is the polar diameter. The transformation formula is: The number of samples is The interpolation method is nearest neighbor interpolation. In specific implementation, the interpolation method can be replaced by bilinear interpolation, cubic interpolation, etc.
[0177] D313, according to the polar coordinate images generated in D332, the polar coordinate data group LensPolarImageGroup is respectively assigned corresponding values and supplemented.
[0178] D32, detection of slight defects on the edge of the lens, Fig. 9 The schematic diagram of the process of detecting slight defects on the edge of the lens in this application is as follows: Fig. 9 As shown, including:
[0179] D321, performing morphological processing on the outer contour polar coordinate image LensPolarImageGroup.outter to obtain a processed image D321outter_image;
[0180] D322, performing difference processing on the processed image D321outter_image and the outer contour polar coordinate image LensPolarImageGroup.outter to obtain a third feature image D32feature;
[0181] D323, extracting the minimum circumscribed rectangle of the third feature image D32feature, and performing lens edge slight defect detection based on the size of the minimum circumscribed rectangle of the third feature image and a preset minimum detection size; if the preset minimum detection size is met, storing it in Set; otherwise, the next one.
[0182] D33, Detection of slight defects on the edge of the lens based on bright field images, Fig.10 This is a schematic diagram of the process of detecting slight defects on the edge of a lens based on bright field images in this application. Fig.10 As shown, including:
[0183] D331, performing morphological processing on the outer contour polar coordinate image LensPolarImageGroup.outter to obtain the edge region of interest edgeRoI, and storing it in LensPolarImageGroup;
[0184] D332, merging the edge region of interest edgeRoI with the bright field polar coordinate image LenPolarImageGroup.bright to obtain a bright field edge image bright_edge, and storing it in LensPolarImageGroup;
[0185] D333, performing mean projection on the bright field edge image to obtain one-dimensional bright field data bright_data;
[0186] D334, using an outlier search algorithm to perform outlier detection on the one-dimensional bright field data bright_data, and obtain each outlier point p i =(x i ,y i ); the outlier search algorithm includes:
[0187] Step 1: Use 3sigma check based on statistical distribution for the one-dimensional bright field data bright_data. If the number of singular points N is large enough, that is, N>Tn, go to step 2; otherwise exit;
[0188] Step 2: Calculate the variance Var for the singular point data in step 1. If the variance Var>BrVar, go to step 3; otherwise exit, where BrVar is the detection variance threshold of the defect;
[0189] Step 3: Smooth filter the one-dimensional bright field data bright_data to construct the filtered data smooth_data;
[0190] Step 4: Calculate the absolute difference between the one-dimensional bright field data bright_data and the filtered data smooth_data in step 3, mark the part where the absolute difference abs_sub>Tsub, and obtain the labeled image label;
[0191] Step 5: Perform morphological close calculation on the label, with the kernel being a rectangle and the size being k;
[0192] Step 6: Extract the contour of the label image and calculate the corresponding contour length L. If L meets the defect length threshold cmL, the contour is retained and drawn, otherwise it is discarded;
[0193] Step 7: Match the retained contour with the original bright_data to obtain the corresponding data points, i.e., the outliers;
[0194] D335, converting the abnormal points into a Cartesian coordinate system, and removing the abnormal points belonging to the edge bubbles in the Cartesian coordinate system based on the edge bubble template image, to obtain a fourth feature image D33feature, removing interference belonging to the edge bubbles;
[0195] D336. Extract the minimum circumscribed rectangle of the fourth feature image, and perform a bright field image-based detection of slight defects on the edge of the lens based on the size of the minimum circumscribed rectangle of the fourth feature image and a preset minimum detection size; if the minimum detection size is met, store it in Set; otherwise, the next one.
[0196] D34, lens edge slight defect detection based on dark field image, including:
[0197] D341, performing morphological processing on the outer contour polar coordinate image to obtain an edge region of interest;
[0198] D342, merging the edge region of interest with the dark field polar coordinate image to obtain a dark field edge image;
[0199] D343, performing mean projection on the dark field edge image to obtain one-dimensional dark field data;
[0200] D344, performing outlier detection on the one-dimensional dark field data to obtain outliers; the outliers here also use the outlier search algorithm as described above, which will not be repeated here.
[0201] D345, converting the abnormal points into a Cartesian coordinate system, and removing the abnormal points belonging to the edge bubbles in the Cartesian coordinate system based on the edge bubble template image, to obtain a fifth feature image;
[0202] D346, extracting the minimum circumscribed rectangle of the fifth characteristic image, and performing a dark field image-based slight defect detection on the edge of the lens based on the size of the minimum circumscribed rectangle of the fifth characteristic image and a preset minimum detection size;
[0203] The principle is consistent with the detection of slight defects on the edge of the lens based on bright field images, so it will not be described in detail.
[0204] D35, lens edge residual material defect detection based on bright field image, Fig.11 Schematic diagram of the process of detecting residual material defects on the edge of the lens based on bright field images in this application, as shown in FIG. Fig.11 As shown, including:
[0205] D351, performing a gradient operation on the bright field edge image bright_edge in LensPolarImageGroup to obtain a bright field binary image b_canny; this embodiment uses the canny operator to perform the gradient operation.
[0206] D352, performing morphological processing on the edge region of interest edgeRoI to obtain an edge target region of interest D35edgeRoI;
[0207] D353, merging the edge target region of interest D35edgeRoI with the bright field binary image D_canny and converting them to a Cartesian coordinate system to obtain a bright field merged image; removing edge bubble interference from the bright field merged image based on an edge bubble template image to obtain a sixth feature image D35feature;
[0208] D354, extract the geometric information of each contour in the sixth characteristic image, wherein the geometric information of the contour includes length', width', aspect', roundness', density', sharpness', and rectangularity', and perform bright field residual material defect detection based on the pre-built residual material defect detection conditions and the geometric information of each contour in the sixth characteristic image. If the residual material defect detection standard is met, store it in Set; otherwise, the next one.
[0209] The conditions for detecting residual material defects are the same as those in the previous article and will not be repeated here.
[0210] D36, edge roughness detection based on multi-light field images, Fig.12 FIG. 1 is a flow chart of edge roughness detection based on multi-light field images in this application. Fig.12 As shown, including:
[0211] D361, performing an adaptive binarization algorithm on the bright field edge image bright_edge in LensPolarImageGroup to obtain a bright field edge binarization image b_th;
[0212] D362, extracting contours of the bright field edge binary image, and screening out target contours with an aspect ratio less than a target value (0.2), and constructing an edge region of interest D36EdgeRoI based on the target contours in the bright field edge binary image;
[0213] D363, performing an adaptive binarization algorithm on the dark field edge image dark_edge in LensPolarImageGroup to obtain a dark field edge binarization image d_th;
[0214] D364, merging the dark field edge binary image d_th and the edge region of interest D36EdgeRoI and converting them into a Cartesian coordinate system to obtain a seventh feature image D36feature;
[0215] D365. Extract geometric information of each contour in the seventh feature image, the geometric information including length", width", aspect ratio", roundness", convexity", sharpness" and rectangularity", and perform edge roughness defect detection based on the pre-constructed edge roughness detection condition and the geometric information of each contour in the seventh feature image; if the edge roughness detection standard is met, store it in Set; otherwise, next one.
[0216] Among them, edge roughness detection conditions include:
[0217]
[0218] This means that for the feature image to be judged, its following geometric features satisfy:
[0219] The length "length" is greater than the preset minimum roughness detection length Min_ERL;
[0220] The width "width" is greater than the preset minimum roughness detection width Min_ERW;
[0221] "Aspect ratio" is within the preset roughness detection range of aspect ratio (Min_ERASP, Max_ERASP), Min_ERASP is the lower limit of the roughness detection range of aspect ratio, and Max_ERASP is the upper limit of the roughness detection range of aspect ratio;
[0222] "Roundness" is within the preset roundness roughness detection interval (Min_ERRD, Max_ERRD), Min_ERRD is the lower limit of the roundness roughness detection interval, and Max_ERRD is the upper limit of the roundness roughness detection interval;
[0223] Density convexity" is within the preset density rough detection interval (Min_ERConv, Max_ERConv), Min_ERConv is the lower limit of the density rough detection interval, and Max_ERConv is the upper limit of the density rough detection interval;
[0224] "Sharpness" is within the preset sharpness and roughness detection interval (Min_ERsharp, Max_ERsharp), Min_ERsharp is the lower limit of the sharpness and roughness detection interval, and Max_ERsharp is the upper limit of the sharpness and roughness detection interval;
[0225] "Rectangularity" is within the preset rectangularity rough detection interval (Min_ERRL, Max_ERRL), Min_ERRL is the lower limit value of the rectangularity rough detection interval, and Max_ERRL is the upper limit value of the rectangularity rough detection interval.
[0226] D37, defect restoration, since step D3 is performed in the polar coordinate system, the data in the corresponding Set needs to be inversely transformed to the original Cartesian coordinate system, and when there is a defect in any of the lens edge slight defect detection results, the lens edge slight defect detection results based on the bright field image, the lens edge slight defect detection results based on the dark field image, the bright field residual material defect detection results, and the edge roughness defect detection results, the defect is restored to the Cartesian coordinate system. The specific process is as follows:
[0227] Specifically, the feature data in the stored Set is traversed, and for each stored minimum bounding rectangle min_rect, the four vertices of the rectangle (p1, p2, p3, p4) are found, and the above four vertices are inversely transformed in polar coordinates so that they can correspond to the image coordinate system to obtain (p1', p2', p3', p4'). The transformation formula is as follows:
[0228]
[0229] Among them, (cx, cy), r are the geometric parameters of the fitted ellipse obtained in C, cnt is the number of samples in C, (x i ,y i ) is the vertex p i Coordinates, (x i ',y i ') is the corresponding vertex transformed to the image coordinate system p i ''s coordinates.
[0230] Use the newly obtained p i ', reconstruct the contour to generate the corresponding min_rect', and replace min_rect in Set with min_rect'.
[0231] E. Surface defect detection based on multi-light field: It is mainly responsible for two functions. First, it divides the ROI of each area on the lens surface and extracts relevant area parameters. Second, it detects lens surface defects based on combining each ROI and multi-light field image, and outputs the corresponding surface detection results. Specifically, it includes:
[0232] E1. Input the pre-processed image ProcessImage in A and judge whether there is a pattern in it. If it is a transparent lens, use the configuration method based on empirical parameters to set and extract the lens ROI. Otherwise, go to E2.
[0233] E2. The extraction of printed pattern area is as follows:
[0234] E21, downsampling and sharpening the preprocessed image ProcessImage to obtain a downsampled image sub_image; using downsampling to eliminate the interference of the singular pattern, and performing image sharpening on the downsampled image to highlight the pattern area information;
[0235] E22, performing binarization and morphological processing on the downsampled image sub_image to obtain a downsampled contour image sub_th;
[0236] E23. Based on the pre-configured empirical area threshold, the contours in the downsampled contour image sub_th are screened to obtain the inner contour and the outer contour of the printing area; sub_th is contour extracted and filtered, and the inner and outer contours of the corresponding printing area are obtained according to the empirical area threshold sub_area. The outer contour outer is used as the end area of the printing area, and the inner contour inner is used as the start area of the printing area;
[0237] E24, fitting the inner contour of the printing area and the outer contour of the printing area respectively to obtain printing area features, wherein the printing area features include the inner ellipse of the printing area print_inner_ellipse, the outer ellipse of the printing area print_outer_ellipse and the printing area surface_1st_region_roi_img;
[0238] E3. The extraction of the central optical zone is as follows:
[0239] E31, multiplying the pre-configured central optical zone ratio optical_pct by the ellipse profile ellipse to obtain a scaled ellipse profile opt_ellipse after major and minor axis compression;
[0240] E32, drawing a first contour image cfg_opt based on the scaled ellipse contour opt_ellipse, and drawing a second contour image print_opt based on the printing area inner ellipse print_inner_ellipse;
[0241] E33. Performing an AND operation on the first contour image cfg_opt and the second contour image print_opt to obtain central optical zone features of the real central optical zone, wherein the central optical zone features include the central optical zone fitting ellipse opt_ellipse and the optical zone image of interest optical_region_roi_img;
[0242] E4, the surrounding transparent area is extracted as follows:
[0243] E41. Use the ellipse outline in C to draw an image (grayscale 255) to obtain the global image whole_surface_roi_img of the lens;
[0244] E42, using the outer contour of the printed area to draw (with a grayscale of 0) the contour of the transparent area around the lens surface_2nd_region_roi_img in the global image whole_surface_roi_img;
[0245] E43, fitting the outline of the peripheral transparent region of the lens to obtain a peripheral transparent region ellipse surface_2nd_region_outer_ellipse;
[0246] E5. Surface defect detection. Surface defect detection includes defect feature extraction, weak feature filtering, optical area defect detection, printing area defect detection, peripheral transparent area defect detection and surface result integration.
[0247] The specific algorithm flow is as follows:
[0248] E51. Defect feature extraction, including:
[0249] E511, combining the optical zone image of interest and the peripheral transparent area ellipse to generate an optical detection region of interest ROI B ;
[0250] Specifically, the corresponding effective detection area is generated using the ROI of each area obtained in E2-E4. For example, if it is a "printed color film", the corresponding bright field effective detection area is the optical zone ROI combined with the central optical area ROI and the peripheral transparent area ROI. The expression is as follows:
[0251] ROI B =(optical)or(surface 2nd )
[0252] E512, the optical detection region of interest ROI B Performing an AND operation with the preprocessed image ProcessImage to obtain valid image data ImageData;
[0253] E513, performing adaptive binarization processing on the effective image data to obtain effective image binarization data; extracting contours in the effective image binarization data, and removing contours whose contour areas are smaller than a preset area threshold, to obtain remaining contours; specifically, using an adaptive binarization algorithm to binarize the ImageData in E512, and performing contour extraction and filtering, filtering out weak contours whose contour areas are less than 25;
[0254] E514, drawing the remaining contour to an eighth feature image feature;
[0255] E52, central optical area defect detection, including:
[0256] E521, initialization of regional detection results: Initialize the defect storage dictionary Defect and the regional detection result opt_result to NG;
[0257] E522, regional feature acquisition: performing an AND operation on the optical region image of interest optical_region_roi_img and the eighth feature image feature to obtain a first optical region image feature_opt; performing a morphological "closing" operation with a kernel of 3 on the first optical region image feature_opt to obtain a fourth optical region image feature_opt2, in order to filter subtle features and improve computational efficiency.
[0258] E523, feature filtering: extract the contour features of the fourth optical zone image feature_opt2, and extract the geometric information and grayscale information of the contour features of the fourth optical zone image feature_opt2, wherein the geometric information includes the length, width, aspect ratio, roundness, contour area and density of the circumscribed rotated rectangle of the contour, and the grayscale information includes the maximum grayscale value, minimum grayscale value, grayscale value mean, center grayscale, grayscale variance within the contour and gradient within the contour; based on the pre-configured geometric inspection parameters, grayscale inspection parameters, geometric information and grayscale information of the contour features, the surface defects of the contact lens are detected to obtain the surface defect detection result. If the corresponding defect type is met, the relevant contour data and defect type are retained to Defect, otherwise discarded, and the relevant expressions are as follows:
[0259] Geometry feature filtering:
[0260]
[0261] Grayscale feature filtering:
[0262]
[0263] Defect related:
[0264] Defect={f1,f2,f3,…f i}
[0265]
[0266] f i_gray = {gray i ,var i ,min_g i ,max_g i ,gradient i ,center_g i}
[0267] E524, Feature Filtering: Update of Area Detection Result: Make a judgment on Defect. If the dictionary is empty, it is considered that the central optical area is flawless and opt_result is set to "Pass".
[0268] E53, printing area defect detection is similar to E52, no further description is given;
[0269] E54, peripheral transparent area defect detection is similar to E52, no further description is given;
[0270] E55. Summary of surface test results, including:
[0271] E551. Initialize the surface detection result: initialize the surface defect storage set SurfaceDefectSet and the surface detection result surface_result to "Pass";
[0272] E552. Comprehensively judge the detection results of the above surface areas. If the detection result of any area is NG, surface_result is updated to "NG", otherwise no update is performed;
[0273] E553. Perform a comprehensive judgment on the Defect dictionary of each region. If the Defect dictionary of the region is not empty, copy the corresponding data to SurfaceDefectSet.
[0274] E554. Output the final comprehensive surface defect storage set SurfaceDefectSet and the surface detection result surface_result.
[0275] F. Result analysis and generation module: It is mainly responsible for making a comprehensive judgment on the above-mentioned glass bowl inspection results, lens rough inspection results, lens edge inspection and surface inspection results by combining the project defect priority file, and outputting the final result of the lens and the corresponding annotation information, including:
[0276] F1. Initialize the result data in LensResult to "Pass";
[0277] F2. Search BlisterResult in module B, LensEdgeExtRes and LensRoughRes in module C. If any of the results in the above three modules is not "Pass", assign the same defect code to LensResult.result, copy the relevant annotation data to the data structure corresponding to LensResult, and enter F5. Otherwise, enter F3.
[0278] F3. Determine the length of the defect Set in modules D and E. If the length is 0, end this module, otherwise go to F4;
[0279] F4. Load the Priority data in A11, build a priority queue, prioritize the defect codes in Set, assign the defect code with the highest priority to LensResult.result, and copy the related annotation data to the data structure corresponding to LensResult.
[0280] F5. According to the corresponding detection results, output the corresponding detection information and marking information to end this module.
[0281] G. Result output: Package and output the result in step F.
[0282] G1. Combine the system parameters in A14 to package the output results. If you need to draw an image to mark the location of the defect, use the relevant position coordinates of module F, such as min_rect.
[0283] G2. Output the product detection result Res corresponding to the image analyzed in the detection step F through the relevant API, and present the result to the corresponding front-end display interface and related data processing center, such as physical software, Web, mobile APP, etc.
[0284] A high-precision multi-light field contact lens defect detection method based on cloud-machine vision is invented. The method obtains a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and pre-processes the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a pre-processed image; the pre-processed image is detected by a glass bowl, and when a glass bowl exists in the pre-processed image, the geometric features of the glass bowl are extracted; the contour features of the printed contact lens in the glass bowl area are extracted based on the geometric features of the glass bowl; obvious defects are detected based on the contour features of the printed contact lens; and edge bubble defect detection, edge defect detection in a Cartesian coordinate system, edge defect detection in a polar coordinate system, and surface defect detection based on multi-light fields are performed based on multiple feature images of the printed contact lens. The present application performs multiple defect detection on the contour and surface of the printed contact lens, which has a corresponding improvement effect on the problems of low detection accuracy and low universality of the existing detection methods. At the same time, it can be widely used in the contact lens automated detection system to reduce the cost of manual re-inspection, improve production efficiency, and thus improve the final product yield.
[0285] The present application also provides a high-precision multi-light field contact lens defect detection device based on cloud-machine vision, comprising:
[0286] An acquisition and preprocessing module, used for acquiring a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and preprocessing the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a preprocessed image, wherein the preprocessed image is obtained by filtering the bright field image;
[0287] A feature extraction module, used to detect a glass bowl in the preprocessed image, and extract geometric features of the glass bowl when the glass bowl exists in the preprocessed image; and extract contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl;
[0288] The defect detection module is used to detect obvious defects based on the contour features of the printed contact lenses, wherein the obvious defects include lens edge contact, deformation, multiple lenses, and abnormal size; and to perform edge bubble defect detection, edge defect detection in a Cartesian coordinate system and edge defect detection in a polar coordinate system, and surface defect detection based on multiple light fields based on multiple feature images of the printed contact lenses, wherein the multiple feature images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
[0289] The present invention discloses a high-precision multi-light field contact lens defect detection device based on cloud-machine vision. The device obtains a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and pre-processes the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a pre-processed image; performs glass bowl detection on the pre-processed image, and extracts the geometric features of the glass bowl when the glass bowl exists in the pre-processed image; extracts the contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl; performs obvious defect detection based on the contour features of the printed contact lens; and performs edge bubble defect detection, edge defect detection in a Cartesian coordinate system, edge defect detection in a polar coordinate system, and surface defect detection based on multi-light fields based on multiple feature images of the printed contact lens. The present application performs multiple defect detection on the contour and surface of the printed contact lens, and has a corresponding improvement effect on the problems of low detection accuracy and low universality of the existing detection methods. At the same time, it can be widely used in the contact lens automated detection system, reducing the cost of manual re-inspection, improving production efficiency, and thus improving the final product yield.
[0290] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0291] The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal executes any one of the methods in this embodiment.
[0292] The computer-readable storage medium in this embodiment can be understood by ordinary technicians in this field: all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0293] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes each step of the above method.
[0294] In this embodiment, the memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0295] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0296] In the above-mentioned embodiments, although the present invention has been described in conjunction with the specific embodiments of the present invention, many replacements, modifications and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. The embodiments of the present invention are intended to cover all such replacements, modifications and variations falling within the broad scope of the appended claims.
[0297] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A high-precision multi-light field contact lens defect detection method based on cloud-machine vision, characterized in that: Includes steps: Acquire a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and pre-process the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a pre-processed image, wherein the pre-processed image is obtained by filtering the bright field image; Performing glass bowl detection on the preprocessed image, and extracting geometric features of the glass bowl when the glass bowl exists in the preprocessed image; performing contour feature extraction on the printed contact lens in the glass bowl area based on the geometric features of the glass bowl; Obvious defect detection is performed based on the contour features of the printed contact lenses, wherein the obvious defects include lens edge contact, deformation, multiple lenses, and abnormal size; and edge bubble defect detection, edge defect detection in a Cartesian coordinate system and edge defect detection in a polar coordinate system, and surface defect detection based on multiple light fields are performed based on multiple characteristic images of the printed contact lenses, wherein the multiple characteristic images include contour features, point light source images, bright field images, dark field images, and preprocessed images.
2. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 1, characterized in that: Performing glass bowl detection on the preprocessed image and extracting geometric features of the glass bowl when the glass bowl exists in the preprocessed image includes: Binarizing the preprocessed image and extracting the contour features of the glass bowl in the preprocessed image after the binarization process; Fitting the minimum inscribed circle of the glass bowl contour whose area is larger than the pre-configured glass bowl area to obtain the radius and center of the minimum inscribed circle; The radius of the minimum inscribed circle is compared with a preconfigured radius range, and when the radius of the minimum inscribed circle falls within the preconfigured radius range, it is determined that a glass bowl exists in the preprocessed image, and the radius and center of the minimum inscribed circle are used as geometric features of the glass bowl.
3. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 1, characterized in that: Based on the geometric features of the glass bowl, contour features of the printed contact lens in the glass bowl area are extracted, including: Filtering and binarizing the preprocessed image to obtain a binarized image C1a; Constructing a glass bowl region BlisterROI based on the geometric features of the glass bowl; A first feature image C1fea is constructed based on the glass bowl region BlisterROI and the binary image C1a, wherein the mathematical expression of the first feature image C1fea is: Where, C1fea i,j is the pixel with coordinates (i, j) in the first feature image C1fea, C1a i,j is the pixel with coordinates (i, j) in the binary image C1a, BlisterROI i,j is the pixel with coordinates (i, j) in the glass bowl region BlisterROI; Extract the contour features in the first feature image Clfea, and extract the inner contour and outer contour of the printed contact lens based on the pre-constructed lens parameters, wherein the lens parameters include the major and minor axis difference determination threshold T abdif , lens aspect ratio threshold T edge_asp , lens size diameter setting threshold range LensDiaRange; The outer contour of the printed contact lens is fitted to obtain an ellipse contour.
4. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 3, characterized in that: Detect obvious defects based on the contour features of printed contact lenses, including: Generate a lens area image based on the ellipse outline, and extract an intersection image C21Img between the glass bowl area BlisterROI and the lens area image, and determine that there is a lens edge defect when the number of pixel points in the intersection image C21Img is greater than a preset number threshold; When the printed contact lens only has an outer contour, it is determined that the lens has a large-scale edge defect; Extracting the major axis a and the minor axis b of the ellipse profile ellipse, calculating the difference between the major axis a and the minor axis b, and calculating the aspect ratio of the major axis a and the minor axis b; when the difference is greater than a preset major-minor axis difference threshold, or when the aspect ratio is less than a preset aspect ratio threshold, determining that the lens has a deformation defect; Extract the ellipse center and assumed radius r of the ellipse outline ellipse, where the assumed radius Based on the ellipse center and the assumed radius r, the contour features in the first feature image Clfea are expanded in polar coordinates, and the average value and variance of the polar diameters of all contour pixel points in the polar coordinates are calculated, and a filtering range based on the 3sigma principle is constructed based on the average value and variance of the polar diameters, and contour points that do not fall into the filtering range are regarded as abnormal points. When the number of abnormal points is greater than a preset multiple-piece determination number threshold, it is determined that the lens has multiple defects; The major axis a and the minor axis b of the ellipse outline ellipse are extracted, the mean of the major axis a and the minor axis b are calculated, and the mean of the major axis a and the minor axis b are compared with a preset lens size diameter setting threshold interval LensDiaRange. When the mean of the major axis a and the minor axis b is not within the preset lens size diameter setting threshold interval LensDiaRange, it is determined that the lens has a size non-compliance defect.
5. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 3, characterized in that: The edge bubble defect detection is performed based on multiple characteristic images of the printed contact lens, including: Extracting the lens edge area of the bright field image based on the ellipse outline; The bright field image is sequentially filtered, morphologically processed and binarized to obtain a bright field binary image; Extracting edge features in the bright field binary image based on the lens edge region; Extract edge features in the bright field binary image that meet the bubble characteristics to obtain edge bubble defect detection results, wherein the bubble characteristics include edge roundness greater than a preset roundness threshold, edge length and width greater than a preset bubble aspect ratio threshold, and contour grayscale less than a preset bubble grayscale threshold; The contour of the bubble feature is reconstructed to obtain an edge bubble template image.
6. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 5, characterized in that: The edge defect detection in a Cartesian coordinate system is performed based on the multiple characteristic images of the printed contact lens, including: Using a convex hull extraction algorithm for the inner contour and the outer contour of the printed contact lens respectively, obtaining the vertices of the inner contour convex hull and the vertices of the outer contour convex hull, calculating the Euclidean distance between the vertices of the inner contour convex hull and the vertices of the outer contour convex hull one by one, and when the Euclidean distance is greater than a preset lace threshold, determining that the printed contact lens has lace defects and storing the lace position; Performing morphological processing on the inner contour convex hull image to obtain an inner edge image; performing a differential operation on the inner edge image and the outer contour to obtain a first severe edge feature; extracting a minimum circumscribed rectangle of the first severe edge feature, and determining that the printed contact lens has a severe defect on the lens edge when the length of the minimum circumscribed rectangle of the first severe edge feature is greater than a preset minimum edge detection size; Performing median filtering on the inner edge image to obtain a median filtered image; performing bubble interference elimination on the median filtered image based on the edge bubble template image to obtain a second severe edge feature; extracting geometric features of the second severe edge feature, and determining that the printed contact lens has an edge tear defect when the geometric features of the second severe edge feature meet a preset edge tear condition; Fit the outer contour of the printed contact lens to obtain an outer contour ellipse; calculate the Euclidean distance dis between the center of the outer contour ellipse and all points of the outer contour i and angle i , where the Euclidean distance dis and the angle angle i The mathematical expression is: dis i =sqrt((xp ix ) 2 +(yp iy ) 2 ) In the formula, (p ix ,p iy ) is the coordinate of the outer contour point, (x, y) is the coordinate of the center of the outer contour ellipse; based on the Euclidean distance dis of all points i and angle i Generate a Euclidean distance set and an angle set, perform normalization filtering and smoothing on the Euclidean distance set and the angle set, and generate an outer contour image fit based on the normalized, filtered and smoothed Euclidean distance set and the angle set img , fit the outer contour image based on the edge bubble template image img Bubbles are eliminated to obtain a second characteristic image, contour features are extracted from the second characteristic image, and when the contour features of the second characteristic image meet a preset edge residual material defect condition, it is determined that the printed contact lens has a residual material defect.
7. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 5, characterized in that: The edge defect detection in polar coordinates is performed based on multiple characteristic images of the printed contact lens, including: Extracting the ellipse center and radius of the ellipse outline ellipse, and performing polar coordinate transformation on the point light source image, the bright field image, the dark field image, the inner contour of the printed contact lens, and the outer contour of the printed contact lens based on the ellipse center and radius, to obtain a point light source polar coordinate image, a bright field polar coordinate image, a dark field polar coordinate image, an inner contour polar coordinate image, and an outer contour polar coordinate image; Performing morphological processing on the outer contour polar coordinate image to obtain a processed image; performing differential processing on the processed image and the outer contour polar coordinate image to obtain a third feature image; extracting the minimum circumscribed rectangle of the third feature image, and performing slight defect detection on the edge of the lens based on the size of the minimum circumscribed rectangle of the third feature image and a preset minimum detection size; Performing morphological processing on the outer contour polar coordinate image to obtain an edge region of interest; merging the edge region of interest with the bright field polar coordinate image to obtain a bright field edge image; performing mean projection on the bright field edge image to obtain one-dimensional bright field data; performing outlier detection on the one-dimensional bright field data to obtain outliers; converting the outliers to a Cartesian coordinate system, and removing outliers belonging to edge bubbles in the Cartesian coordinate system based on the edge bubble template image to obtain a fourth feature image; extracting a minimum circumscribed rectangle of the fourth feature image, and performing a bright field image-based detection of slight defects on the edge of the lens based on the size of the minimum circumscribed rectangle of the fourth feature image and a preset minimum detection size; Performing morphological processing on the outer contour polar coordinate image to obtain an edge region of interest; merging the edge region of interest with the dark field polar coordinate image to obtain a dark field edge image; performing mean projection on the dark field edge image to obtain one-dimensional dark field data; performing outlier detection on the one-dimensional dark field data to obtain outliers; converting the outliers to a Cartesian coordinate system, and removing outliers belonging to edge bubbles in the Cartesian coordinate system based on the edge bubble template image to obtain a fifth feature image; extracting a minimum circumscribed rectangle of the fifth feature image, and performing dark field image-based detection of slight defects on the edge of the lens based on the size of the minimum circumscribed rectangle of the fifth feature image and a preset minimum detection size; Performing gradient operation on the bright field edge image to obtain a bright field binary image; performing morphological processing on the edge region of interest to obtain an edge target region of interest; merging the edge target region of interest with the bright field binary image and converting them to a Cartesian coordinate system to obtain a bright field merged image; removing edge bubble interference of the bright field merged image based on an edge bubble template image to obtain a sixth feature image; extracting geometric information and bright field grayscale information of each contour in the sixth feature image, and performing bright field residual material defect detection based on pre-constructed residual material defect detection conditions, geometric information and bright field grayscale information of each contour in the sixth feature image; An adaptive binarization algorithm is performed on the bright field edge image to obtain a bright field edge binarization image; contour extraction is performed on the bright field edge binarization image, and target contours with an aspect ratio less than a target value are screened out, and an edge region of interest is constructed based on the target contours in the bright field edge binarization image; an adaptive binarization algorithm is performed on the dark field edge image to obtain a dark field edge binarization image; the dark field edge binarization image is combined with the edge region of interest and then converted to a Cartesian coordinate system to obtain a seventh feature image; geometric information and bright field grayscale information of each contour in the seventh feature image are extracted, and edge roughness defect detection is performed based on pre-constructed edge roughness detection conditions, geometric information and bright field grayscale information of each contour in the seventh feature image; When there is a defect in any of the lens edge slight defect detection result, the lens edge slight defect detection result based on the bright field image, the lens edge slight defect detection result based on the dark field image, the bright field residual material defect detection result, and the edge roughness defect detection result, the defect is restored to the Cartesian coordinate system.
8. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 6, characterized in that: Based on the multiple characteristic images of the printed contact lens, surface defect detection based on multi-light fields is performed, including: Downsampling and sharpening the preprocessed image to obtain a downsampled image; binarizing and morphologically processing the downsampled image to obtain a downsampled contour image; screening contours in the downsampled contour image based on a preconfigured empirical area threshold to obtain an inner contour of the printing area and an outer contour of the printing area; fitting the inner contour of the printing area and the outer contour of the printing area respectively to obtain printing area features, wherein the printing area features include an inner ellipse of the printing area, an outer ellipse of the printing area, and a printing area; The pre-configured central optical zone ratio is multiplied by the ellipse outline ellipse to obtain a scaled ellipse outline; a first outline image is drawn based on the scaled ellipse outline, and a second outline image is drawn based on the ellipse in the printing area; and the first outline image and the second outline image are ANDed to obtain central optical zone features, wherein the central optical zone features include a central optical zone fitting ellipse and an optical zone image of interest; Draw a global image of the lens based on the ellipse outline ellipse, draw the outline of the peripheral transparent area of the lens using the outer outline of the printed area in the global image, and fit the outline of the peripheral transparent area of the lens to obtain the peripheral transparent area ellipse; Surface defects of the contact lens are detected based on the printed area features, the central optical zone features and the peripheral transparent area ellipse.
9. The high-precision multi-light field contact lens defect detection method based on cloud-machine vision according to claim 8, characterized in that: Detecting surface defects of a contact lens based on the printed area features, the central optical zone features, and the peripheral transparent area ellipse, comprising: Combining the optical zone image of interest and the peripheral transparent area ellipse to generate an optical detection region of interest; Performing an AND operation on the optical detection region of interest and the preprocessed image to obtain valid image data; Adaptively binarizing the effective image data to obtain effective image binarized data; extracting contours from the effective image binarized data, and removing contours whose contour areas are smaller than a preset area threshold to obtain remaining contours; drawing the remaining contour to an eighth feature image; Performing an AND operation on the optical zone image of interest and the eighth characteristic image to obtain a first optical zone image; performing an AND operation on the printed area and the eighth characteristic image to obtain a second optical zone image; and performing an AND operation on the peripheral transparent area ellipse and the eighth characteristic image to obtain a third optical zone image; Performing a morphological closing operation on the first optical zone image to obtain a fourth optical zone image; performing a morphological closing operation on the second optical zone image to obtain a fifth optical zone image; performing a morphological closing operation on the third optical zone image to obtain a sixth optical zone image; Extracting contour features of the fourth optical zone image, the fifth optical zone image and the sixth optical zone image, and extracting geometric information and grayscale information of the contour features of the fourth optical zone image, the fifth optical zone image and the sixth optical zone image, wherein the geometric information includes the length, width, aspect ratio, roundness, contour area and density of a circumscribed rotated rectangle of the contour, and the grayscale information includes the maximum grayscale value, the minimum grayscale value, the mean grayscale value, the central grayscale, the grayscale variance within the contour and the gradient within the contour; The surface defects of the contact lens are detected based on the pre-configured geometric inspection parameters, grayscale inspection parameters, geometric information and grayscale information of the contour features to obtain a surface defect detection result.
10. A high-precision multi-light field contact lens defect detection device based on cloud-machine vision, characterized in that: include: An acquisition and preprocessing module, used for acquiring a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and preprocessing the multi-light field original image to obtain a point light source image, a bright field image, a dark field image, and a preprocessed image, wherein the preprocessed image is obtained by filtering the bright field image; A feature extraction module, used to detect a glass bowl in the preprocessed image, and extract geometric features of the glass bowl when the glass bowl exists in the preprocessed image; and extract contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl; The defect detection module is used to detect obvious defects based on the contour features of the printed contact lenses, wherein the obvious defects include lens edge contact, deformation, multiple lenses, and abnormal size; and to perform edge bubble defect detection, edge defect detection in a Cartesian coordinate system and edge defect detection in a polar coordinate system, and surface defect detection based on multiple light fields based on multiple feature images of the printed contact lenses, wherein the multiple feature images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
Citation Information
Cited By
High-precision multi-light-field contact lens edge defect detection method and device based on cloud-machine vision
CN119399232A
Process feedback system of contact lens production line
CN120931633A
Process feedback system for contact lens production lines
CN120931633B
Digital projection measurement system and method for detecting tiny transparent sample
CN121558774A