An efficient multi-light field contact lens defect detection method and device based on cloud-machine vision
Through the multi-light field detection method of cloud-machine vision, defects in contact lenses can be automatically identified, solving the problem of low efficiency of manual inspection and improving inspection efficiency and yield rate.
Patent Information
- Application Number
- CN202411476715.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2044-10-22
AI Technical Summary
In the existing technology, defect detection of contact lenses relies on manual inspection, which leads to low efficiency and high cost, and it is difficult to accurately identify printed area and edge defects.
A multi-light field detection method based on cloud-machine vision is adopted. By obtaining the multi-light field original image of the printed contact lens immersed in a glass bowl, the geometric features of the glass bowl are extracted after preprocessing, and the contour and surface defects are detected based on these features, including lens edge adhesion, deformation, multiple lenses, and size abnormalities.
It realizes the automated detection of contact lens defects, reduces labor costs, and improves detection efficiency and production yield.
Smart Images

Figure CN119477816B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud and machine vision technology, and in particular to a cloud-machine vision-based efficient multi-light field contact lens defect detection method and device. Background Art
[0002] The main manufacturing methods for contact lenses include turning and molding. Due to the different lens materials, various types of defects are prone to occur during the production process, such as abnormal lens size and various surface defects.
[0003] In the prior art, printed areas and edges of printed contact lenses are generally detected manually, which is prone to various errors and omissions, and is inefficient and low-cost. Summary of the Invention
[0004] In view of this, an object of the present invention is to provide an efficient 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] The present invention provides an efficient multi-light field contact lens defect detection method based on cloud-machine vision, comprising the steps of:
[0007] Acquire a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and preprocess 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;
[0008] Performing glass bowl detection on the pre-processed image and extracting geometric features of the glass bowl when the glass bowl exists in the pre-processed 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. Surface defect detection based on multi-light fields is performed based on multiple characteristic images of the printed contact lenses to obtain detection results, wherein the multiple characteristic images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
[0010] This application also provides a cloud-machine vision-based efficient multi-light field contact lens defect detection device, comprising:
[0011] an acquisition and preprocessing module, configured to acquire a multi-light-field original image of a printed contact lens immersed in water in a glass bowl, and preprocess 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, configured to detect a glass bowl in the preprocessed image and, if a glass bowl exists in the preprocessed image, extract geometric features of the glass bowl; and extract contour features of the printed contact lens within the glass bowl region 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 multi-light field-based surface defect detection based on multiple characteristic images of the printed contact lenses to obtain detection results, wherein the multiple characteristic 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: The present invention provides an efficient multi-light field contact lens defect detection method and device based on cloud-machine vision. The method obtains a multi-light field original image of a printed contact lens immersed in water in a glass bowl and preprocesses 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; the preprocessed image is subjected to glass bowl detection, and when a glass bowl is present in the preprocessed image, the geometric features of the glass bowl are extracted; the contour features of the printed contact lens within the glass bowl area are extracted based on the geometric features of the glass bowl; and multi-light field-based surface defect detection is performed based on the multiple feature images of the printed contact lens. The present application preprocesses the multi-light field original image to obtain multiple feature images, thereby performing edge and print area defect detection from multiple aspects. The present application further utilizes the contact lens image captured by a high-resolution camera to automatically identify the image and determine whether the corresponding product is normal, thereby reducing labor costs, saving time, and improving production 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 the topological diagram of the technical solution in this application;
[0017] Figure 2 This is a schematic diagram of the computing algorithm in the cloud service of this application;
[0018] Figure 3 This is a schematic diagram of the parameter configuration process in the implementation of this application;
[0019] Figure 4 This is a flow chart of an efficient multi-light field contact lens defect detection method based on cloud-machine vision shown in one embodiment of the present application;
[0020] Figure 5 This is a schematic diagram of the preprocessing process in one embodiment of the present application;
[0021] Figure 6 Schematic diagram of the process of glass bowl detection in one embodiment of the present application;
[0022] Figure 7 A schematic diagram of the process of extracting the edge profile of the lens in this application;
[0023] Figure 8 This is a schematic diagram of the process of detecting obvious defects on lenses in this application. DETAILED DESCRIPTION
[0024] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed 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 unless they conflict.
[0025] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention. Therefore, the drawings only show the layers related to the present invention and are not 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 can be changed arbitrarily, and the layer layout type may also be more complicated.
[0026] In the following description, numerous details are set forth to provide a more thorough explanation of the embodiments of the present invention; however, it is apparent to one skilled in the art that the embodiments of the present invention may be practiced without these specific details.
[0027] Figure 1 This is the topological diagram of the technical solution in this application, such as Figure 1 As shown, 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 result is obtained and pushed to the industrial computer and subsequent data processing center.
[0028] Figure 2 This is a schematic diagram of the computing algorithm in the cloud service of this application, such as Figure 2 As shown, the algorithm of this application is mainly composed of 6 modules, including:
[0029] A. Initialization configuration module: responsible for initializing the configuration of the detection system, reading, loading, color space conversion, and noise reduction of the contact lens images collected by the camera to reduce the interference caused by environmental noise, and finally generating the process image;
[0030] B. Glass bowl detection module: responsible for extracting the small bowl ROI and determining the size of the small bowl.
[0031] C. Lens rough inspection module: Responsible for using edge extraction algorithms on the process image to extract the edge contour of the lens and detect obvious defects on the lens, including lens edge adhesion, deformation, multiple lenses, and size abnormalities;
[0032] D. Lens surface inspection module: This module is responsible for two functions: first, extracting ROIs from various regions of the lens surface; second, detecting lens surface defects based on combining ROIs with multi-light field images;
[0033] E. Result analysis and generation module: Integrate and process the results in modules B to D to obtain the final lens test results.
[0034] F. Output module: Package and output the results in step E.
[0035] Before conducting formal testing, this application needs to load relevant configuration parameters. Figure 3 This is a schematic diagram of the parameter configuration process in the implementation of this application. Figure 3 As shown in the figure, the parameter configuration process includes:
[0036] A1. The initialization configuration process is as follows.
[0037] A11. Import the configuration file. This parameter configuration file contains lens system parameters, light source configuration parameters, algorithm configuration parameters, system setting parameters, etc. Among them, loading system configuration parameters sets whether to enable the surface detection module and whether to output images; loading algorithm parameters includes extraction parameters and analysis parameters, etc. The details are as follows:
[0038] For module B: small bowl area BlisterArea; effective small bowl radius (BlisterRL, BlisterRU), the former is the lower bound, the latter is the upper bound;
[0039] For module C: lens edge determination threshold T touch , the major-minor axis difference judgment threshold T abdif , lens aspect ratio threshold T edge_asp, lens size diameter setting threshold range LensDiaRange;
[0040] For module D: minimum detectable surface size SMinL, minimum detectable bright field surface grayscale BSMinG, minimum detectable dark field surface grayscale DSMinG, minimum detectable point light source surface grayscale PSMinG;
[0041] For module E: defect priority configuration table Priority;
[0042] Read and load the light source configuration parameters and verify them. Load the light source parameters used by the system and compare them with the industrial computer light source system parameters. If the light source settings are inconsistent, return the corresponding error code and exit the system. Otherwise, enter A14.
[0043] Initialize the image object related data structure used by the algorithm. In this embodiment, it includes the following:
[0044] Input image group, ImagePacket;
[0045] Apply the image group, LensImageGroup;
[0046] Polar coordinate image group, LensPolarImageGroup;
[0047] Defect data group, Set;
[0048] Initialize the relevant result objects used by the algorithm. In this embodiment, it includes the following:
[0049] Step B, glass bowl detection result, BlisterResult;
[0050] Step C, edge extraction result, LensEdgeEctRes;
[0051] Step C, lens rough inspection result, LensRoughRes;
[0052] Step D, lens surface detection result, LensSurfaceInsRes;
[0053] Step E, detecting the final result, LensResult;
[0054] A12. Read and load the light source configuration parameters and verify them. Load the light source parameters used by the system and compare them with the industrial computer light source system parameters. If the light source settings are inconsistent, return the corresponding error code and exit the system. Otherwise, enter A14.
[0055] A13. Initialize the image object related data structure used by the algorithm. In this embodiment, the following is included:
[0056] Input image group, ImagePacket;
[0057] Apply the image group, LensImageGroup;
[0058] Polar coordinate image group, LensPolarImageGroup;
[0059] Defect data group, Set;
[0060] A14. Initialize the relevant result objects used by the algorithm. In this embodiment, the following is included:
[0061] Step B, glass bowl test result, BlisterResult
[0062] Step C, edge extraction result, LensEdgeExtRes;
[0063] Step C, Lens RoughRes
[0064] Step D, lens surface detection results, LensSurfaceInsRes
[0065] Step E: Detect the final result, LensResult
[0066] Figure 4 This is a flow chart of an efficient multi-light field contact lens defect detection method based on cloud-machine vision shown in one embodiment of the present application, such as Figure 4 As shown in the figure: An efficient multi-light field contact lens defect detection method based on cloud-machine vision in this embodiment may include the following steps:
[0067] S410, obtaining 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;
[0068] Figure 5 This is a schematic diagram of the preprocessing process in one embodiment of the present application, as shown in FIG. Figure 5 As shown, the process of preprocessing the multi-light field original image in this application includes:
[0069] A2, preprocessing:
[0070] A21 reads the image data passed in by the camera, segments the image data according to the multi-light field settings of bright field, dark field, and point light source, i.e., the multi-light field raw image, converts the image data from RAW to RGB format, and temporarily stores it in ImagePacket.
[0071] 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 LensImageGroup, specifically including bright field image BrightImage, dark field image DarkImage, and point light source image.
[0072] A23 performs Gaussian filtering with a kernel of 3×3 and normalization stretching on the bright field image BrightImage in the LensImageGroup in A22 to obtain a noise-reduced preprocessed image ProcessImage, the purpose of which is to reduce interference caused by environmental noise.
[0073] S420, performing glass bowl detection on the pre-processed image, and extracting geometric features of the glass bowl when the glass bowl exists in the pre-processed image; and extracting contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl;
[0074] Figure 6 This is a flow chart of glass bowl detection in one embodiment of the present application. Figure 6 As shown, glass bowl testing includes:
[0075] B. Glass bowl detection module: This module is responsible for applying a segmentation algorithm to the preprocessed image ProcessImage and determining whether the extracted pixels contain a glass bowl and whether the size matches the requirements. This module specifically includes:
[0076] 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;
[0077] B2, binarizing the pre-processed image and extracting the outline features of the glass bowl in the binarized pre-processed image; applying a segmentation algorithm to the pre-processed image ProcessImage in B1 to perform binarization segmentation and extract the corresponding region of interest (ROI);
[0078] B3. Fit a minimum inscribed circle to the glass bowl outline whose area is larger than the pre-configured BlisterArea to obtain the radius R and center C of the minimum inscribed circle. First, filter the area of the outline extracted in B2. If it is larger than BlisterArea in B1, fit a minimum inscribed circle to the outline and obtain the radius R and center C of the circle. Then proceed to B4. If neither of the conditions are met, terminate.
[0079] B4. Compare the radius R of the minimum inscribed circle with a preconfigured radius range (BlisterRL, BlisterRU). 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.
[0080] 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 the value "No Blister". Otherwise, this module is considered to have passed and BlisterResult is assigned the value "Pass" and the process proceeds to B5. The expression is as follows:
[0081]
[0082] B5. Store the radius R and center C obtained in B3 in BlisterResult.
[0083] S430, 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 multi-light field-based surface defect detection based on multiple characteristic images of the printed contact lens to obtain a detection result, wherein the multiple characteristic images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
[0084] Finally, detection is performed based on the multiple features extracted above. The detection content is as follows:
[0085] C. Lens rough inspection is responsible for: extracting the edge contour of the lens and detecting obvious defects of the lens, including lens edge adhesion, deformation, multiple lenses, and abnormal size, etc. Specifically including:
[0086] C1. Contour extraction, Figure 7 This is a schematic diagram of the process of extracting the edge profile of the lens in this application, such as Figure 7 Shown, including:
[0087] C11. Filter and binarize the preprocessed image to obtain a binary image C1a. Specifically, perform two low-pass filtering operations on the preprocessed image ProcessImage generated by A, wherein the first filtering kernel size is 5×5, and the second filtering kernel size is 3×3 Gaussian kernel, to obtain a filtered image Filtered. Then, perform an adaptive algorithm on the filtered image Filtered to obtain a binary image C1a.
[0088] C12. Construct a BlisterROI of the glass bowl region based on the geometric features of the glass bowl. Specifically, use the small bowl fitting circle information (radius R and center C) stored in BlisterResult in B to construct the small bowl ROI, BlisterROI.
[0089] C13. Construct 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:
[0090]
[0091] 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;
[0092] C14, extracting the contour features in the first feature image C1fea, and extracting the inner contour inner and outer contour outer of the printed contact lens based on pre-built lens parameters, wherein the lens parameters include the major and minor axis difference determination threshold T abdif , lens aspect ratio threshold T edge_asp , set the lens diameter threshold interval LensDiaRange; fit the outer contour of the printed contact lens to obtain the ellipse contour. Save it to the data structure corresponding to LensEdgeExtRes and 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;
[0093] 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.
[0094] C2, lens obvious defect detection, Figure 8 This is a schematic diagram of the process of obvious defects in the lens in this application, such as Figure 8 Shown, including:
[0095] C21. Using the BlisterROI and ellipse obtained by integrating LensEdgeExtRes in C15, the lens edge defect is determined. This includes generating a lens area image based on the ellipse outline, and using an AND operation to extract the intersection image C21Img of the glass bowl area BlisterROI and the lens area image. If the number of pixels in the intersection image C21Img exceeds a preset threshold, a lens edge defect is determined to exist.
[0096] 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 edge-fitted, the result item in LensRoughRes is assigned the value "Touvh" and exit, otherwise the next step, the expression is as follows;
[0097]
[0098] C22. When the printed contact lens only has an outer contour, determining that the lens has a large-scale edge defect;
[0099] Use edge_num in C15 to identify large-scale lens defects. If edge_num is not 2, that is, only the outer edge exists but not the inner edge, then the lens is considered to have large-scale edge defects. The result item in LensRoughRes is assigned to "EdgeDefect" and the process exits. Otherwise, the next step is as follows:
[0100]
[0101] C23. Extracting the major axis a and the minor axis b of the elliptical outline 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; if the difference is greater than a preset major-minor axis difference threshold, or if the aspect ratio is less than a preset aspect ratio threshold, determining that the lens has a deformation defect;
[0102] 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:
[0103]
[0104] C24, extracting the ellipse center and assumed radius r of the ellipse outline, wherein the assumed radius Performing polar coordinate expansion on the contour features in the first feature image Clfea based on the ellipse center and the assumed radius r, and calculating the average and variance of the polar diameters of all contour pixel points in the polar coordinates. A filtering range based on the 3sigma principle is established based on the average and variance of the polar diameters. Contour points that do not fall within the filtering range are considered outliers. When the number of outliers is greater than a preset multiple-lens determination threshold, it is determined that the lens has multiple defects.
[0105] Use C1fea and ellipse in C15 to detect whether the lens is "multi-piece". For C1fea, use the ellipse center EC in ellipse and the assumed radius of the major and minor axes. Polar coordinate expansion is performed, and a statistically-based outlier detection algorithm is used to detect "multi-pieces." This algorithm uses the mean and variance of the polar diameters of all contour pixels in polar coordinates to construct a filtering range based on the 3sigma principle. Contour points that do not fall within this filtering range are considered outliers. If the number of outliers exceeds the preset threshold for multi-piece determination, the image meets the "multi-piece" feature. If the detection meets the "multi-piece" feature, the result item in LensRoughRes is assigned to "MutilLens" and the algorithm exits. Otherwise, the next step is as follows:
[0106]
[0107] C25. Extract the major axis a and minor axis b of the ellipse outline, and use the major axis a and minor axis b in the 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 to be 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 "offsixe" and exit. Otherwise, the next step is as follows:
[0108]
[0109] D. 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 the combination of each ROI and multi-light field image and outputs the corresponding surface detection results. Specifically, it includes:
[0110] D1: Input the pre-processed image ProcessImage in A and determine 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, proceed to D2.
[0111] D2. Extraction of printed pattern area is as follows:
[0112] D21, downsampling and sharpening the preprocessed image ProcessImage to obtain a downsampled image sub_image; using downsampling to eliminate interference from the singular pattern, and performing image sharpening on the downsampled image to highlight information of the pattern area;
[0113] D22, performing binarization and morphological processing on the downsampled image sub_image to obtain a downsampled contour image sub_th;
[0114] D23. Filter the contours in the downsampled contour image sub_th based on a pre-configured empirical area threshold to obtain the inner contour and outer contour of the printing area; perform contour extraction and filtering on sub_th, and obtain the inner and outer contours of the corresponding printing area based on 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 starting area of the printing area.
[0115] D24, 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_first_region_roi_img;
[0116] D3, central optical zone extraction is as follows:
[0117] D31, 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;
[0118] D32, 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;
[0119] D33. 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 true 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;
[0120] D4. The surrounding transparent area is extracted as follows:
[0121] D41. Use the ellipse outline in C to draw an image (grayscale 255) to obtain the global image whole_surface_roi_img of the lens;
[0122] D42, using the outer outline of the printed area in the global image whole_surface_roi_img to draw (with a grayscale of 0) the outline of the transparent area around the lens surface_2nd_region_roi_img;
[0123] D43, fitting the outline of the peripheral transparent region of the lens to obtain the peripheral transparent region ellipse surface_2nd_region_outer_ellipse;
[0124] D5. 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.
[0125] The specific algorithm flow is as follows:
[0126] D51. Defect feature extraction, including:
[0127] D511, combining the optical zone image of interest and the peripheral transparent area ellipse to generate an optical detection region of interest ROI B ;
[0128] Specifically, the ROIs of each region obtained in D2-D4 are used to generate the effective detection areas in the bright field image, dark field image, and point light source image. For example, if it is a "printed color film", the corresponding bright field effective detection area is the optical zone ROI that combines the central optical area ROI and the peripheral transparent area ROI. The expression is as follows:
[0129] ROI B =(optical)or(surface 2nd )
[0130] D512, the optical detection region of interest ROI BPerform an AND operation with the pre-processed image ProcessImage to obtain valid image data ImageDate;
[0131] D513, performing adaptive binarization processing on 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; specifically, using an adaptive binarization algorithm to binarize ImageDate in D512, and performing contour extraction and filtering to filter out weak contours whose contour areas are less than A;
[0132] D514, drawing the remaining contour to the eighth feature image feature;
[0133] D52, central optical area defect detection, including:
[0134] D521, initialization of regional detection results: Initialize the defect storage dictionary Defect and the regional detection result opt_result to NG;
[0135] D522. 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 k on the first optical region image feature_opt to obtain a fourth optical region image feture_opt2, in order to filter out subtle features and improve computational efficiency.
[0136] D523, 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 mean, center grayscale, grayscale variance within the contour, and gradient within the contour; based on pre-configured geometric inspection parameters, grayscale inspection parameters, and the geometric information and grayscale information of the contour features, detect surface defects of the contact lens to obtain a surface defect detection result. If the corresponding defect type is met, the relevant contour data and defect type are retained and set to Defect; otherwise, they are discarded. The relevant expressions are as follows:
[0137] Geometric feature filtering:
[0138]
[0139] Grayscale feature filtering:
[0140]
[0141] Defect related:
[0142] Defect={f1,f2,f3,…f i}
[0143]
[0144]
[0145] f i_gray ={gray i ,var i ,min_g i ,max_g i ,gradient i ,center_g i}
[0146] D524, Feature Filtering: Update the regional detection results: Defect is judged. If the dictionary is empty, it is considered that the central optical area has no defects, and opt_rDsult is set to "Pass";
[0147] D53, printing area defect detection is similar to D52, so it will not be described in detail.
[0148] D54, peripheral transparent area defect detection is similar to D52, so it will not be described in detail.
[0149] D55. Summary of surface test results, including:
[0150] D551. Initialize surface inspection result: Initialize the surface defect storage set SurfaceDefectSet and the surface inspection result surface_result to "Pass";
[0151] D552. Comprehensively judge the detection results of the above surface areas. If the detection result of any area is NG, then surface_result is updated to "NG", otherwise no update is performed;
[0152] D553. Perform a comprehensive judgment on the Defect dictionary of each area. If the Defect dictionary of the area is not empty, copy the corresponding data to SurfaceDefectSet.
[0153] D554. Output the final comprehensive surface defect storage set SurfaceDefectSet and the surface detection result surface_result.
[0154] E. Result Analysis and Generation Module: This module is responsible for comprehensively judging the above-mentioned glass bowl inspection results, lens rough inspection results, lens edge inspection results, and surface inspection results by combining them with the project defect priority file, and outputting the final results and corresponding annotation information for the lens. Specifically, it includes:
[0155] E1. Initialize the result data in LensResult to "Pass";
[0156] E2. Search BlisterResult in module B, and LensEdgeExtRes and LensRough Res in module C. If any of the results in the three modules is not "Pass", assign the same defect code to LensResult.result and copy the relevant annotation data to the data structure corresponding to LensResult. Then go to E5. Otherwise, go to E3.
[0157] E3. Determine the length of SurfaceDefectSet in module D. If the length is 0, end this module, otherwise go to E4.
[0158] E4. Load the Priority data from A11, build a priority queue, prioritize the defect codes in Set, assign the highest-priority defect code to LensResult.result, and copy the relevant annotation data to the data structure corresponding to LensResult.
[0159] E5. According to the corresponding detection results, output the corresponding detection information and annotation information, and end this module.
[0160] F. Result output: Package and output the result in step E.
[0161] F1. 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.
[0162] F2. Output the product inspection result Res corresponding to the image analyzed in 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.
[0163] The invention discloses an efficient multi-light field contact lens defect detection method based on cloud-machine vision. 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 then 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. Based on the geometric features of the glass bowl, contour features of the printed contact lens within the glass bowl area are extracted. Furthermore, multi-light field-based surface defect detection is performed based on the multiple feature images of the printed contact lens. The present application pre-processes the multi-light field original image to obtain multiple feature images, thereby performing defect detection on the edge and printed area from multiple aspects. The present application further utilizes the contact lens image captured by a high-resolution camera to automatically identify the image and determine whether the corresponding product is normal or not, thereby reducing labor costs, saving time, and improving production yield.
[0164] This application also provides a cloud-machine vision-based efficient multi-light field contact lens defect detection device, comprising:
[0165] an acquisition and preprocessing module, configured to acquire a multi-light-field original image of a printed contact lens immersed in water in a glass bowl, and preprocess 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;
[0166] a feature extraction module, configured to detect a glass bowl in the preprocessed image and, if a glass bowl exists in the preprocessed image, extract geometric features of the glass bowl; and extract contour features of the printed contact lens within the glass bowl region based on the geometric features of the glass bowl;
[0167] 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 multi-light field-based surface defect detection based on multiple characteristic images of the printed contact lenses to obtain detection results, wherein the multiple characteristic images include contour features, point light source images, bright field images, dark field images, and pre-processed images.
[0168] The present invention discloses an efficient 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 preprocesses 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. The preprocessed image is then subjected to glass bowl detection, and when a glass bowl is present in the preprocessed image, the geometric features of the glass bowl are extracted. Based on the geometric features of the glass bowl, contour features of the printed contact lens within the glass bowl area are extracted. Furthermore, multi-light field-based surface defect detection is performed based on the multiple feature images of the printed contact lens. The present application preprocesses the multi-light field original image to obtain multiple feature images, thereby performing edge and print area defect detection from multiple perspectives. The present application further utilizes the contact lens image captured by a high-resolution camera to automatically identify the image and determine whether the corresponding product is normal, thereby reducing labor costs, saving time, and improving production yield.
[0169] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0170] The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory, so that the terminal executes any one of the methods in this embodiment.
[0171] Regarding the computer-readable storage medium in this embodiment, those skilled in the art will appreciate that all or part of the steps in the aforementioned method embodiments can be implemented using hardware associated with the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps in the aforementioned method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0172] 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 for communication, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes the various steps of the above method.
[0173] 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 storage.
[0174] 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, and discrete hardware components.
[0175] In the above embodiments, although the present invention has been described in conjunction with specific embodiments of the present invention, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. The embodiments of the present invention are intended to cover all such replacements, modifications and variations that fall within the broad scope of the appended claims.
[0176] 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 skilled in 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 one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. An efficient multi-light field contact lens defect detection method based on cloud-machine vision, characterized in that: Including steps: Acquire a multi-light field original image of a printed contact lens immersed in water in a glass bowl, and preprocess 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; 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; based on the geometric features of the glass bowl, the contour features of the printed contact lens in the glass bowl area are extracted; based on the geometric features of the glass bowl, the contour features of the printed contact lens in the glass bowl area are extracted, including: filtering and binarizing the pre-processed image to obtain a binarized image ; Constructing the glass bowl area based on the geometric features of the glass bowl ; Based on the glass bowl area And the binary image Construct the first feature image , wherein the first feature image The mathematical expression is: Where, The first feature image The median coordinate is Pixels, For the binary image The median coordinate is Pixels, For the glass bowl area The median coordinate is Pixel points; extract the first feature image The inner and outer contours of the printed contact lens are extracted based on the pre-built lens parameters, wherein the lens parameters include the major and minor axis difference determination thresholds. , lens aspect ratio threshold , lens size diameter setting threshold interval ; Fit the outer contour of the printed contact lens to obtain an elliptical contour ; Detecting obvious defects based on the contour features of printed contact lenses, including: Generate a lens area image and extract the glass bowl area Intersection image with the lens area image , in the intersecting image When the number of pixel points is greater than a preset threshold, it is determined that there is a lens edge defect; when the printed contact lens only has an outer contour, it is determined that there is a large-scale edge defect in the lens; extract the elliptical contour The long axis and short axis , calculate the major axis and the short axis The difference between the two and calculate the major axis and the short axis 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, it is determined that the lens has a deformation defect; extracting the elliptical contour The center and assumed radius of the ellipse , where the assumed radius , based on the ellipse center and the assumed radius For the first feature image The contour features in the polar coordinates are expanded, and the average value and variance of the polar diameters of all contour pixel points in the polar coordinates are calculated. A filtering range based on the 3sigma principle is constructed based on the average value and variance of the polar diameters. 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 threshold value for multiple lens determination, it is determined that there are multiple defects in the lens. The elliptical contour is extracted. The long axis and short axis , calculate the major axis and the short axis The mean of the long axis and the short axis The threshold interval is set by the mean of the lens size and the preset lens diameter For comparison, the long axis and the short axis The mean value is not within the preset lens size diameter threshold range When the lens is within the range of 0 to 100 nm, it is determined that the lens has a size non-conformity defect; and a surface defect detection based on multiple light fields is performed on the printed contact lens based on the multiple feature images to obtain a detection result, including: extracting the printing area feature, the central optical zone feature and the lens peripheral transparent area contour from the preprocessed image; detecting the surface defects of the contact lens based on the printing area feature, the central optical zone feature and the peripheral transparent area ellipse to obtain a detection result, wherein the multiple feature images include contour features, point light source images, bright field images, dark field images and preprocessed images, and the central optical zone feature includes a central optical zone fitting ellipse and an optical zone image of interest; detecting the surface defects of the contact lens based on the printing area feature, the central optical zone feature and the peripheral transparent area ellipse, including: generating an optical detection region of interest of a target feature image by combining the optical zone image of interest and the peripheral transparent area ellipse, wherein the target feature image is one of the bright field image, the dark field image and the point light source image; performing an AND operation on the optical detection region of interest and the preprocessed image to obtain valid image data; and performing surface defect detection based on the valid image data to obtain a detection result.
2. The method for detecting defects in contact lenses using a multi-light field method based on cloud-machine vision according to claim 1, wherein: Detecting a glass bowl in the preprocessed image and extracting geometric features of the glass bowl when the glass bowl exists in the preprocessed image includes: performing binarization processing on the pre-processed image, and extracting the contour features of the glass bowl in the binarized pre-processed image; 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 cloud-machine vision-based efficient multi-light field contact lens defect detection method according to claim 1, characterized in that: Extracting printing area features from the pre-processed image includes: Performing downsampling and sharpening processing on the preprocessed image to obtain a downsampled image; performing binarization and morphological processing on the downsampled image to obtain a downsampled contour image; Screening the contours in the downsampled contour image based on a pre-configured empirical area threshold to obtain a contour inside the printing area and a contour outside the printing area; The inner contour of the printing area and the outer contour of the printing area are fitted 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.
4. The method for detecting defects in contact lenses using a multi-light field method based on cloud-machine vision according to claim 3, wherein: Extracting central optical zone features and lens peripheral transparent area contours from the pre-processed image includes: The pre-configured central optical zone ratio is matched to the elliptical outline Multiply them to get the scaled ellipse outline; Drawing a first contour image based on the scaled ellipse contour, and drawing a second contour image based on the ellipse within the printing area; performing an AND operation on the first contour image and the second contour image to obtain a central optical zone feature; Based on the elliptical contour A global image of the lens is drawn, and the outer contour of the printed area is used in the global image to draw the outline of the peripheral transparent area of the lens. The outline of the peripheral transparent area of the lens is fitted to obtain an ellipse of the peripheral transparent area.
5. The method for detecting defects in contact lenses using a multi-light field method based on cloud-machine vision according to claim 4, wherein: Performing surface defect detection based on the valid image data to obtain a detection result includes: Performing adaptive binarization processing on 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; and performing a morphological closing operation on the third optical zone image to obtain a sixth optical zone image; Surface defects of the contact lens are detected based on preconfigured inspection parameters, the fourth optical zone image, the fifth optical zone image, and the sixth optical zone image to obtain a surface defect detection result.
6. The cloud-machine vision-based efficient multi-light field contact lens defect detection method according to claim 5, characterized in that: Detecting surface defects of the contact lens based on pre-configured inspection parameters, the fourth optical zone image, the fifth optical zone image, and the sixth optical zone image to obtain a surface defect detection result, including: 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; Surface defects of the contact lens are detected based on pre-configured geometric inspection parameters, grayscale inspection parameters, geometric information and grayscale information of the contour features to obtain surface defect detection results.
7. An efficient multi-light field contact lens defect detection device based on cloud-machine vision, characterized in that: include: an acquisition and preprocessing module, configured to acquire a multi-light-field original image of a printed contact lens immersed in water in a glass bowl, and preprocess 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 is used to detect a glass bowl in the preprocessed image and extract the geometric features of the glass bowl when the glass bowl exists in the preprocessed image; extract the contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl; extract the contour features of the printed contact lens in the glass bowl area based on the geometric features of the glass bowl, including: filtering and binarizing the preprocessed image to obtain a binarized image ; Constructing the glass bowl area based on the geometric features of the glass bowl ; Based on the glass bowl area And the binary image Construct the first feature image , wherein the first feature image The mathematical expression is: Where, The first feature image The median coordinate is Pixels, For the binary image The median coordinate is Pixels, For the glass bowl area The median coordinate is Pixel points; extract the first feature image The inner and outer contours of the printed contact lens are extracted based on the pre-built lens parameters, wherein the lens parameters include the major and minor axis difference determination thresholds. , lens aspect ratio threshold , lens size diameter setting threshold interval ; Fit the outer contour of the printed contact lens to obtain an elliptical contour ; The defect detection module is used to detect obvious defects based on the contour features of the printed contact lens, including: Generate a lens area image and extract the glass bowl area Intersection image with the lens area image , in the intersecting image When the number of pixel points is greater than a preset threshold, it is determined that there is a lens edge defect; when the printed contact lens only has an outer contour, it is determined that there is a large-scale edge defect in the lens; extract the elliptical contour The long axis and short axis , calculate the major axis and the short axis The difference between the two and calculate the major axis and the short axis 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, it is determined that the lens has a deformation defect; extracting the elliptical contour The center and assumed radius of the ellipse , where the assumed radius , based on the ellipse center and the assumed radius For the first feature image The contour features in the polar coordinates are expanded, and the average value and variance of the polar diameters of all contour pixel points in the polar coordinates are calculated. A filtering range based on the 3sigma principle is constructed based on the average value and variance of the polar diameters. 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 threshold value for multiple lens determination, it is determined that there are multiple defects in the lens. The elliptical contour is extracted. The long axis and short axis , calculate the major axis and the short axis The mean of the long axis and the short axis The threshold interval is set by the mean of the lens size and the preset lens diameter For comparison, the long axis and the short axis The mean value is not within the preset lens size diameter threshold range When the lens is within the range of 0 to 100 nm, it is determined that the lens has a size non-conformity defect; and a surface defect detection based on multiple light fields is performed on the printed contact lens based on the multiple feature images to obtain a detection result, including: extracting the printing area feature, the central optical zone feature and the lens peripheral transparent area contour from the preprocessed image; detecting the surface defects of the contact lens based on the printing area feature, the central optical zone feature and the peripheral transparent area ellipse to obtain a detection result, wherein the multiple feature images include contour features, point light source images, bright field images, dark field images and preprocessed images, and the central optical zone feature includes a central optical zone fitting ellipse and an optical zone image of interest; detecting the surface defects of the contact lens based on the printing area feature, the central optical zone feature and the peripheral transparent area ellipse, including: generating an optical detection region of interest of a target feature image by combining the optical zone image of interest and the peripheral transparent area ellipse, wherein the target feature image is one of the bright field image, the dark field image and the point light source image; performing an AND operation on the optical detection region of interest and the preprocessed image to obtain valid image data; and performing surface defect detection based on the valid image data to obtain a detection result.
Citation Information
Patent Citations
Contact lens edge defect detection method
CN112529876A
High-precision contact lens edge defect detection method and system based on machine vision
CN117269179A