A real-time detection method and system for online contact lens color mold pad printing quality
Through the real-time detection method and system of color mold pad printing quality of online contact lenses, image sequence alignment, feature extraction and registration are used to solve the problem of difficult to detect color mold pad printing quality of contact lenses in the prior art, efficient and accurate automatic detection is achieved, and product yield and production efficiency are improved.
Patent Information
- Application Number
- CN202411076433.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-08-07
AI Technical Summary
The prior art is difficult to effectively detect the quality of contact lens color mold pad printing, resulting in missed inspection of defective products and increased production costs.
The real-time detection method and system of online contact lens color mold pad printing quality is adopted. By obtaining the color image sequence of the contact lens casting mold, it is aligned, area features and color features are extracted, and the printing area is registered, and the pad printing quality is finally detected based on these features.
It realizes automatic detection of color mold pad printing quality of contact lenses, accurate and efficient detection, avoids the limitations of artificial quality inspection, and improves product yield and production efficiency.
Smart Images

Figure CN119090811B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of machine vision, in particular to an online contact lens color mold pad printing quality real-time detection method and system. Background Art
[0002] In recent years, colored contact lenses (cosmetic lenses) printed with colorful and diverse patterns have been very popular among consumers. Major contact lens manufacturers have begun to use cosmetic contact lenses as their main products. Compared with the production process of transparent contact lenses, the production process of cosmetic contact lenses has added a printing process. The designed pattern is transferred by pad printing equipment and printed in different colors onto the mold, and then the pattern is transferred to the lens through processes such as color fixing, filling and mold closing.
[0003] The pad printing process is a flexible printing process, which will inevitably produce a variety of printing defects, affecting the final appearance quality of the contact lenses. Traditional pad printing equipment only has a printing module, but lacks a quality inspection module. After printing, the mold can only be inspected by the production line quality inspectors to determine whether there are defects. If the quality inspectors pursue labor efficiency, they may only have a short time to roughly observe the entire tray of molds, or can only conduct random inspections. This inspection method is very likely to cause defective products to be missed, affecting the final product yield. Secondly, if a certain characteristic defect is continuously produced, manual quality inspection will usually not be discovered until a period of time, and batch waste has already occurred, resulting in a huge increase in production costs. Summary of the invention
[0004] In view of this, an object of the present invention is to provide an online contact lens color mold pad printing quality real-time detection method and system to solve the problem that it is difficult to detect the contact lens color mold pad printing quality in the prior art.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] The present invention provides a real-time detection method for the quality of online contact lens color mold pad printing, comprising:
[0007] Acquire a color image sequence of the contact lens casting mold, wherein the color image sequence includes multiple frames of color images of the contact lens casting mold;
[0008] Aligning the mold areas in the color image sequence, and calculating the average image of the aligned color image sequence to obtain an enhanced image, wherein the enhanced image includes the mold edge of the contact lens;
[0009] Extracting regional features and color features from the enhanced image, wherein the regional features include a printed area;
[0010] Registering the printing area to obtain a registered printing area;
[0011] The color mold pad printing quality of the contact lens is detected based on the area features, the color features and the registered printing area.
[0012] In one embodiment of the present application, aligning the mold area in the color image sequence includes:
[0013] Converting the color image sequence into a grayscale image sequence;
[0014] Taking the last frame of the grayscale image sequence as a reference image, performing binarization processing on the reference image and other images in the color image sequence to obtain a plurality of binarized images;
[0015] Performing median filtering on the multiple binary reference images to obtain an intermediate image;
[0016] Continue to perform contour extraction on the intermediate image to obtain multiple contours;
[0017] Filtering candidate contours that meet a preset area threshold from the multiple contours;
[0018] Fitting the candidate contour to obtain a circular contour, and extracting the center coordinates and radius of the circular contour;
[0019] Based on the center coordinates of the reference image, the radius of the reference image, the center coordinates of other images in the color image sequence, and the radius of other images in the color image sequence, the other images in the color image sequence are aligned to the reference image to obtain an aligned color image sequence.
[0020] In one embodiment of the present application, extracting the center coordinates and radius of the circular contour includes:
[0021] Calculate the zero-order moment M of the binary image where the circular contour is located 00 , first-order moment M 10 and the first-order moment M 01 ;
[0022] Among them, M 00 =∑ I ∑ J V(i,j),M 10 =∑ I ∑ J i·V(i,j),M 01 =∑ I ∑ Jj·V(i,j), (i,j) is the pixel coordinate of the binary image where the circular contour is located, V(i,j) is the grayscale value of the pixel (i,j), I is the number of pixels in the horizontal coordinate of the binary image where the circular contour is located, and J is the number of pixels in the vertical coordinate of the binary image where the circular contour is located;
[0023] Based on the zero-order moment M of the binary image where the circular contour is located 00 , first-order moment M 10 and the first moment M 01 Calculate the center coordinates (x, y) of the circular contour, where: And based on the zero-order moment M of the binary image where the circular contour is located 00 Calculate the radius r of the circular profile, where
[0024] In an embodiment of the present application, based on the center coordinates of the reference image, the radius of the reference image, the center coordinates of other images in the color image sequence, and the radius of other images in the color image sequence, the other images in the color image sequence are aligned to the reference image to obtain an aligned color image sequence, including:
[0025] For any color image in the color image sequence, construct an initial mask image, wherein the height of the initial mask image Mask is h0 and the width is w0;
[0026] Based on the center coordinates (x c ,y c ) and the center coordinates of the color image (x i ,y i ) Calculate the size padding of the edge filling area of the initial mask image to obtain the mask image Mask; wherein the height of the mask image Mask is h m , the width of the mask image Mask is w m ; The size of the edge filling area padding, the height of the mask image Mask h m And the width w of the mask image Mask m The mathematical expression is:
[0027] padding=max((abs(y i -y c ),abs(x i -x c ))
[0028] h m =h0+2×padding
[0029] w m=w0+2×padding
[0030] The color image is sliced based on the mask image Mask to obtain an aligned image newImg, wherein the mathematical expression of the aligned image newImg is:
[0031] newImg=Mask[start y :start y +h0,start x :start x +w0]
[0032] Mask[padding:-padding,padding:-padding]=I j,j=0,1,…N-2
[0033] start y =padding-y c +y i
[0034] start x =padding-x c +x i
[0035] Among them, start x is the row coordinate of the 0th row of the aligned image on the mask image, start y is the column coordinate of the 0th column of the aligned image on the mask image, I j,j=0,1,…N-2 is the jth aligned image;
[0036] Construct an aligned color image sequence based on all aligned images newImg.
[0037] In one embodiment of the present application, extracting regional features from the enhanced image includes:
[0038] Converting the enhanced image to an HSV color space to obtain an HSV image, wherein the HSV image includes a saturation channel image and a brightness channel image;
[0039] Subtracting the saturation channel image from the brightness channel image to obtain a difference image, wherein the difference image represents a background area with low saturation and high brightness;
[0040] The difference image is negated to obtain a color enhanced image, which is the foreground area; and the negated image is binarized to obtain a binary image, thereby extracting an area with a high color span as a printing area;
[0041] Performing morphological judgment on the printed area; and when the printed area is annular, determining the central optical zone and the outer optical zone of the contact lens based on the mold edge and the printed area of the contact lens, wherein the central optical zone is located within the printed area, and the outer optical zone is located outside the printed area.
[0042] In one embodiment of the present application, extracting color features from the enhanced image includes:
[0043] Converting the enhanced image to LAB color space to obtain a LAB image;
[0044] Preprocessing the LAB image to obtain an intermediate image, wherein the preprocessing method includes Gaussian filtering and morphological corrosion operations;
[0045] Calculating a histogram of the intermediate image, and performing sliding window smoothing processing on the histogram to obtain histogram information;
[0046] Clustering the intermediate image to obtain color centers of multiple colors; and performing color threshold segmentation based on the color centers of the multiple colors and preset upper and lower thresholds to obtain pixel points of multiple classes and the number of pixel points of the multiple classes;
[0047] Calculate the proportion and color density of each color based on the number of pixels in multiple classes;
[0048] Performing morphological determination on the printing area; and when the printing area is annular, dividing the printing area into a plurality of color ring areas based on a plurality of classes, and calculating the color moment of each color ring area;
[0049] A color feature is constructed based on the proportion of each color, the color density of each color, and a plurality of color moments.
[0050] In one embodiment of the present application, registering the printing area to obtain the registered printing area includes:
[0051] Converting the target area in the printing area and the pre-built registration template into polar coordinates to obtain the target area in polar coordinates and the registration template in polar coordinates, wherein the target area includes an inner layer area, a middle layer area and an outer layer area;
[0052] Calculating the translation of the target area in the polar coordinates and the registration template in the polar coordinates, and converting the translation into a rotation angle in Cartesian coordinates;
[0053] Construct a two-dimensional transformation matrix M based on the rotation angle w , and based on the two-dimensional transformation matrix M wThe target area is rotated to obtain a rotated target area, wherein the two-dimensional transformation matrix M w The mathematical expression is:
[0054]
[0055] Among them, α = s × cosφ, β = s × sinφ, φ is the rotation angle, s is the scaling factor, α is the product of the scaling factor s and the cosine function of the rotation angle φ, and β is the product of the scaling factor s and the sine function of the rotation angle φ;
[0056] Construct the registered print region based on all rotated target regions.
[0057] In one embodiment of the present application, the color mold pad printing quality of the contact lens is detected based on the regional features, the color features and the registered printing area, including:
[0058] Based on the regional features, the color mold pad printing quality of the contact lens is subjected to pad printing offset detection, optical area stain detection and non-contrast ink lack detection; and based on the regional features, the color features and the registered printing area, contrast ink lack detection, color difference detection and printing area stain detection are performed;
[0059] The process of detecting the pad printing offset includes: taking the area within the edge of the mold as a reference range, comparing the reference range with the registered printing area, and determining that there is a pad printing offset when the registered printing area exceeds the reference range and the deviation between the center of the registered printing area and the center of the reference range exceeds a threshold; determining that there is a pad printing offset when the ratio of the maximum spacing and the minimum spacing between the edge of the registered printing area and the edge of the mold is greater than a threshold;
[0060] The process of optical zone stain detection includes: determining a preset pupil area, wherein the pupil area is a circle formed by a fixed diameter; determining the shape of a printing area; if the printing area is non-circular, performing optical stain detection on the pupil area based on pre-constructed detection conditions, wherein the detection conditions include an area screening threshold and a grayscale screening threshold; if the printing area is circular, extracting an inner contour of the printing area; judging whether the printing area is printed into the pupil area based on the inner contour; and performing optical stain detection on the circular area between the inner contour of the printing area and the pupil area and the pupil area based on the pre-constructed detection conditions;
[0061] The process of the non-contrastive ink shortage detection includes: identifying ink shortage features in the regional features based on a pre-constructed neural network to obtain an ink shortage detection result.
[0062] In one embodiment of the present application, comparative ink shortage detection, color difference detection and printing area stain detection are performed based on the regional features, the color features and the registered printing area, including:
[0063] The comparative ink shortage detection process includes: comparing the area and radius of the registered printing area with the area and radius of the preset printing area template respectively, and determining that there is an ink shortage defect when they are inconsistent; and performing ink shortage detection on the target area of the registered printing area to obtain the ink shortage position when the ink shortage defect is not an overall ink shortage defect;
[0064] The color difference detection process includes: constructing a histogram based on the color feature, and comparing the histogram with a preset histogram template to obtain an overall color difference, and comparing each single color with a preset corresponding single color to obtain the color difference of each single color; constructing color similarity based on the color difference of each single color; when the color similarity is greater than or equal to a preset similarity threshold, determining that there is no overall color difference and local color difference; when there is no overall color difference and local color difference, performing color moment detection on the color feature to obtain a single-layer color difference; when the color similarity is less than a preset similarity threshold, calculating the directivity of the histogram with the preset histogram template; Histogram correlation, when the histogram correlation is less than a preset correlation threshold, it is determined that there is an overall color difference and a single color with color difference is determined; when the histogram correlation is greater than or equal to the preset correlation threshold, the histogram distance between the histogram and a preset histogram template is calculated, when the histogram distance is less than a preset distance threshold, the overall color difference index between the histogram and the preset histogram template is calculated, when the overall color difference index is less than a preset color difference threshold, it is determined that only a single color color difference exists; when the histogram distance is greater than or equal to the preset distance threshold, it is determined that there is an overall color difference and a single color with color difference is determined;
[0065] The process of detecting stains in the printing area includes: identifying the area features, the color features and the registered printing area based on a pre-built neural network to obtain the detection result of stains in the printing area.
[0066] The present application also provides an online contact lens color mold pad printing quality real-time detection system, comprising:
[0067] An acquisition module, used for acquiring a color image sequence of a contact lens casting mold, wherein the color image sequence includes a plurality of frames of color images of the contact lens casting mold;
[0068] An alignment module, used for aligning the mold area in the color image sequence, and calculating the average image of the aligned color image sequence to obtain an enhanced image, wherein the enhanced image includes the mold edge of the contact lens;
[0069] A feature extraction module, used to extract regional features and color features from the enhanced image, wherein the regional features include a printed area;
[0070] A registration module, used for registering the printing area to obtain a registered printing area;
[0071] A detection module is used to detect the color mold pad printing quality of the contact lens based on the regional features, the color features and the registered printing area.
[0072] The beneficial effects of the present invention are as follows: an online contact lens color mold pad printing quality real-time detection method and system of the present invention obtains a color image sequence of the contact lens mold; aligns the mold area in the color image sequence, and calculates the average image of the aligned color image sequence to obtain an enhanced image; extracts regional features and color features from the enhanced image; registers the printing area to obtain the registered printing area; and detects the color mold pad printing quality of the contact lens based on the regional features, color features, and registered printing area. This application collects a color graphic sequence, calculates the average image after alignment, and then extracts the regional features and color features, thereby detecting the color mold pad printing quality of the contact lens, thereby achieving automatic detection, accurate detection, and high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0074] Figure 1 This is a diagram of a collection device for real-time detection of online contact lens color mold pad printing quality shown in an embodiment of the present application;
[0075] Figure 2 It is a flow chart of a method for real-time detection of the quality of online contact lens color mold pad printing in one embodiment of the present invention;
[0076] Figure 3 A schematic diagram of the process of image alignment in one embodiment of the present application;
[0077] Figure 4 A schematic diagram of the process of extracting regional features in one embodiment of the present application;
[0078] Figure 5 A schematic diagram of a color feature extraction process in one embodiment of the present application;
[0079] Figure 6 A schematic diagram of a process of printing area registration in an embodiment of the present application;
[0080] Figure 7 Schematic diagram of the process of pad printing offset detection in one embodiment of the present application;
[0081] Figure 8 Schematic diagram of the process of optical zone stain detection in one embodiment of the present application;
[0082] Fig. 9 A schematic diagram of a flow chart of non-comparative ink shortage detection in one embodiment of the present application;
[0083] Fig.10 A schematic diagram of a flow chart of non-comparative ink shortage detection in one embodiment of the present application;
[0084] Fig.11 The structure diagram of an online contact lens color mold pad printing quality real-time detection system in one embodiment of the present invention. DETAILED DESCRIPTION
[0085] 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.
[0086] 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.
[0087] 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.
[0088] Figure 1 1 is a diagram of an online contact lens color mold pad printing quality real-time detection acquisition device shown in an embodiment of the present application, such as Figure 1 As shown, the contact lenses are placed on the edge of a tray 1, the tray 1 is rotatable, and a camera 2 is arranged above the tray 1 through a bracket. The camera 2 is used to collect images of the contact lenses and provide them to relevant equipment for defect analysis.
[0089] Before starting defect detection, this application checks the interface parameters and images through the input module; since the configuration parameters include template binding configuration parameters and algorithm general configuration parameters, the former are set by the user and the latter are managed by the algorithm, this application sets a configuration file reading and conversion module to read the two parts of the configuration parameters and convert them into the algorithm's internal data format Config, making data management safer and more efficient;
[0090] In addition, the present application also sets up a template data reading and writing module and an interactive image storage module, and the template data reading and writing module is responsible for performing operations of writing and reading template data according to the modeling or detection process;
[0091] The interactive image storage module is responsible for writing the template and sample ROI (region of interest) processed by the algorithm for front-end display.
[0092] Figure 2 FIG. 1 is a flow chart of a method for real-time detection of the quality of online contact lens color mold pad printing shown in an embodiment of the present application. Figure 2 As shown, the overall process of this application includes:
[0093] S210, acquiring a color image sequence of a contact lens casting mold, wherein the color image sequence includes a plurality of frames of color images of the contact lens;
[0094] S220, aligning the mold regions in the color image sequence, and calculating an average image of the aligned color image sequence to obtain an enhanced image, wherein the enhanced image includes the mold edge of the contact lens;
[0095] The characteristics of online machine vision inspection require fast inspection speed and inevitable vibration between the modules of the equipment, which may lead to slight displacement between the multiple frames of images collected. Direct image averaging will cause image blur, reduce image resolution and affect inspection accuracy. Alignment of multiple frames of images is responsible for solving this problem.
[0096] S230, extracting regional features and color features from the enhanced image, wherein the regional features include the printing area; wherein the regional features divide various areas in the enhanced image, including the printing area, the central optical area, and the outer optical area. The color features are mainly color histograms and color moments of multiple color categories;
[0097] S240, registering the printing area to obtain a registered printing area;
[0098] Through image registration, the rotation angle of the printed area is made consistent with that of the template, facilitating subsequent high-precision matching.
[0099] S250, detecting the color mold pad printing quality of the contact lens based on the area feature, the color feature and the registered printing area.
[0100] Finally, it is necessary to integrate the detection results according to the given rules and output the final detection information according to the interface design.
[0101] Figure 3 FIG. 1 is a flow chart of image alignment in an embodiment of the present application. Figure 3 As shown, in one embodiment of the present application, aligning the mold area in the color image sequence includes:
[0102] A. Input parameter verification: determine whether the image data and parameters meet the requirements. If they meet the requirements, proceed to B. If they do not meet the requirements, the algorithm ends.
[0103] B. Initialize configuration parameters: read the template binding configuration and general configuration, store them in specific member variables respectively, and initialize the image data member variables and template data member variables;
[0104] C. Main branch selection: According to the input parameter is_template, if the value is True, it will enter the modeling process, and if the value is False, it will enter the sample detection process, load the template data, and initialize the sample data member variables;
[0105] D. Preprocessing: Initialize the region positioning operator and enter D1: multi-frame image alignment module. The color camera takes a total of N frames of images {Ij, j = 0, 1...N-1}, and aligns the first N-1 frames to the Nth frame. For the online detection scene, a fast registration method for mold images is proposed, which includes the following steps:
[0106] D1, converting the color image sequence into a grayscale image sequence;
[0107] D2, taking the last frame (Nth frame) of the grayscale image sequence as a reference image, and performing binarization processing on the reference image and other images in the color image sequence to obtain a plurality of binarized images;
[0108] D3, performing median filtering on the multiple binary reference images to obtain an intermediate image; specifically, performing denoising processing using a median filter with a kernel of 3;
[0109] D4, continuing to extract contours from the intermediate image to obtain multiple contours;
[0110] D5. Filtering out candidate contours that meet a preset area threshold from the multiple contours;
[0111] D6. Fit the candidate contour to obtain a circular contour, and extract the coordinates of the center and radius of the circular contour; the present application performs a centroid method to fit a circle (an ellipse can also be fitted), and this method has a strong ability to resist interference from tiny dirt near the contour.
[0112] Specifically, the present application obtains the center and radius of the centroid circle by calculating the image moment, and the principle is as follows:
[0113] D61, calculate the zero-order moment M of the binary image where the circular contour is located 00 , first-order moment M 10 and the first moment M 01 ;
[0114] Among them, M 00 =∑ I ∑ J V(i,j),M 10 =∑ I ∑ J i·V(i,j),M 01 =∑ I ∑ J j·V(i,j), (i,j) is the pixel coordinate of the binary image where the circular contour is located, V(i,j) is the grayscale value of the pixel (i,j), I is the number of pixels in the horizontal coordinate of the binary image where the circular contour is located, and J is the number of pixels in the vertical coordinate of the binary image where the circular contour is located;
[0115] D62, based on the zero-order moment M of the binary image where the circular contour is located 00 , first-order moment M 10 and the first moment M 01 Calculate the center coordinates (x, y) of the circular contour, where: And based on the zero-order moment M of the binary image where the circular contour is located 00 Calculate the radius r of the circular profile, where
[0116] D7. Align the other images in the color image sequence to the reference image based on the center coordinates of the reference image, the radius of the reference image, the center coordinates of other images in the color image sequence, and the radius of other images in the color image sequence to obtain an aligned color image sequence.
[0117] The specific process includes:
[0118] D71. For any color image in the color image sequence, construct an initial mask image, wherein the height of the initial mask image Mask is h0 and the width is w0;
[0119] D72, based on the center coordinates (x c ,y c ) and the center coordinates of the color image (x i ,y i ) Calculate the size padding of the edge filling area of the initial mask image to obtain the mask image Mask; wherein the height of the mask image Mask is h m , the width of the mask image Mask is w m ; The size of the edge filling area padding, the height of the mask image Mask h m And the width w of the mask image Mask m The mathematical expression is:
[0120] padding=max((abs(y i -y c ),abs(x i -x c ))
[0121] h m =h0+2×padding
[0122] w m =w0+2×padding
[0123] D73. Slice the color image based on the mask image Mask to obtain an aligned image newImg, wherein the mathematical expression of the aligned image newImg is:
[0124] newImg=Mask[start y :start y +h0,start x :start x +w0]
[0125] Mask[padding:-padding,padding:-padding]=I j,j=0,1,…N-2
[0126] start y =padding-y c +y i
[0127] start x =padding-x c +x i
[0128] Among them, start xis the row coordinate of the 0th row of the aligned image on the mask image, start y is the column coordinate of the 0th column of the aligned image on the mask image, I j,j=0,1,…N-2 is the jth aligned image;
[0129] D74. Construct an aligned color image sequence based on all aligned images newImg.
[0130] After alignment, the average image is calculated and then converted into a grayscale image. The above data is stored in the image data variable ImagesInfo.
[0131] Finally, the mold edge detection is performed. If the mold edge exists, the mold area information is further obtained.
[0132] After the above process, severe defect detection is carried out to determine whether the product has any defects.
[0133] In this application, the center area of the mold product is white. When there is no product placed, the center of the base is black. By setting the upper and lower limits of the color threshold, the binary image of the black area can be extracted, and the number of non-zero pixels in the binary image is counted. If it exceeds the given threshold, it is determined that there is no product and the algorithm ends. Otherwise, it means that there is a product and subsequent feature extraction is performed.
[0134] Figure 4 FIG. 1 is a schematic diagram of a process for extracting regional features in an embodiment of the present application. Figure 4 As shown, in one embodiment of the present application, extracting regional features from the enhanced image includes:
[0135] S410, converting the enhanced image into an HSV color space to obtain an HSV image, wherein the HSV image includes a saturation channel image and a brightness channel image;
[0136] S420, performing subtraction on the saturation channel image and the brightness channel image to obtain a difference image, where the difference image can represent a background area with low saturation and high brightness;
[0137] S430, negating the difference image to obtain a color enhanced image, which is the foreground area; and binarizing the negated image to obtain a binary image, thereby extracting an area with a high color span as a printing area;
[0138] S440, performing morphological judgment on the printed area; and when the printed area is annular, determining the central optical zone and the outer optical zone of the contact lens based on the mold edge of the contact lens and the printed area, wherein the central optical zone is located within the printed area, and the outer optical zone is located outside the printed area.
[0139] In the present application, when making morphological judgment, Gaussian blur is first performed, and then the outer contour and inner contour of the printed area are detected. If both the inner and outer contours exist, it means that the annular area is detected, and finally the radius of the optical zone is calculated.
[0140] In this application, since the color pattern categories of the printing area are very rich, and each customer's product design drawings even reach thousands of types. The colors of these patterns are dark and light, and the saturation is high and low. In order to adapt to these patterns, this application proposes an algorithm based on the HSV color space that can adapt to the extraction of multiple colors. It is beneficial to make a difference between the saturation S channel and the brightness V channel, and can extract the background color with low saturation and high brightness. By inverting it, the printing area, central optical area and outer optical area with a high color span can be obtained. The above information is stored in RegionInfo.
[0141] Figure 5 FIG. 1 is a schematic diagram of a color feature extraction process in an embodiment of the present application. Figure 5 As shown, in one embodiment of the present application, extracting color features from the enhanced image includes:
[0142] S510, converting the enhanced image into a LAB color space to obtain a LAB image;
[0143] S520, preprocessing the LAB image to obtain an intermediate image, wherein the preprocessing method includes Gaussian filtering and morphological erosion operations;
[0144] S530, calculating a histogram of the intermediate image, and performing sliding window smoothing processing on the histogram to obtain histogram information;
[0145] S540, clustering the intermediate image to obtain color centers of multiple colors; and performing color threshold segmentation based on the color centers of the multiple colors and preset upper and lower thresholds to obtain pixel points of multiple classes and the number of pixel points of the multiple classes;
[0146] S550, calculates the proportion and color density of each color based on the number of pixels of multiple classes;
[0147] S560, performing morphological determination on the printing area; and when the printing area is annular, dividing the printing area into a plurality of color ring areas based on a plurality of categories, and calculating a color moment of each color ring area;
[0148] S570: Construct a color feature based on the proportion of each color, the color density of each color, and a plurality of color moments.
[0149] In the present application, the image is first preprocessed, and the color image is converted from the RGB color space to the LAB color space. In order not to lose color information, only the brightness L channel is Gaussian filtered. In order to reduce the dispersion interference at the edge of the color point, a morphological corrosion operation is performed. Then, the histogram of the color image is calculated. In order to reduce noise interference, the histogram is smoothed by sliding window. Then, the color center of the monochrome is obtained by clustering method (any density clustering method can be selected). With the color center as the origin and given upper and lower thresholds, the pixel points belonging to each category are extracted by the color threshold segmentation method. The form of the image is a binary image. By counting the non-zero pixels in each binary image, the number of pixels of each category can be obtained, thereby the proportion of each color and the density of each color for the color point can also be calculated. Finally, the printing area is divided into M color ring areas from the inner ring to the outer ring, and the color moments are calculated respectively. The above color information is stored in ColorInfo.
[0150] After the color information is extracted, the printing area is registered.
[0151] Due to the influence of transportation or printing accuracy during the printing process, the pattern of the sample may have slight rotation, translation and distortion compared with the pattern of the template. This deformation can be approximately equivalent to affine deformation in the plane. However, another major problem of pad printing is that the color offset or rotation between multiple overprintings may cause complex deformation between layers of the overall pattern after overprinting. By observing images in a large number of actual scenes, it is found that the rigid deformation has a larger amplitude and a greater impact on the registration. Therefore, if the pattern is simplified to a rigid body, there will only be rotation and translation, and no shear deformation. This can greatly reduce the difficulty of registration calculation. Compared with feature-based matching algorithms (including but not limited to SIFT, SURF, ORB and other algorithms), template matching algorithms based on the grayscale invariant assumption are faster and more stable. However, if there is rotation deformation, the template needs to be continuously rotated for matching, and the amount of calculation increases sharply.
[0152] In order to solve the above problems, the present application proposes a template-based matching algorithm that takes into account both speed and accuracy, and can solve image transformations with both translation and rotation deformations. The printing area ROI is converted to a polar coordinate system according to the fitted center and outer diameter. The translation along the ρ axis represents the translation along the radial direction, and the translation along the θ axis represents the rotation around the center of the circle. In the polar coordinate system, only one template needs to be used to perform a template matching process to successfully align.
[0153] Figure 6 FIG. 1 is a flow chart of printing area registration in an embodiment of the present application. Figure 6 As shown, in one embodiment of the present application, the printing area is registered to obtain the registered printing area, including:
[0154] S610, converting the target area in the printing area and the pre-built registration template into polar coordinates to obtain the target area in the polar coordinates and the registration template in the polar coordinates, wherein the target area includes an inner layer area, a middle layer area and an outer layer area;
[0155] S620, calculating the translation amount of the target area in the polar coordinates and the registration template in the polar coordinates, and converting the translation amount into a rotation angle in Cartesian coordinates;
[0156] S630: construct a two-dimensional transformation matrix M based on the rotation angle. w , and based on the two-dimensional transformation matrix M w The target area is rotated to obtain a rotated target area, wherein the two-dimensional transformation matrix M w The mathematical expression is:
[0157]
[0158] Among them, α = s × cosφ, β = s × sinφ, φ is the rotation angle, s is the scaling factor, α is the product of the scaling factor s and the cosine function of the rotation angle φ, and β is the product of the scaling factor s and the sine function of the rotation angle φ;
[0159] S640: construct a registered printing area based on all the rotated target areas.
[0160] In addition, transforming the sample image involves matrix multiplication, which requires M w Convert to homogeneous matrix M T :
[0161]
[0162] After the template and sample printing area ROI of this application are converted to the polar coordinate system, the sample ROI is expanded, and then the template is aligned to the expanded sample image, the translation amount in polar coordinates is solved, and then the translation amount is converted into a rotation angle in Cartesian coordinates, and the rotated sample image is obtained by using a two-dimensional matrix transformation, thus completing the alignment.
[0163] The above process can achieve a rough alignment of the entire printing area. Since there is a relative translation or rotation between each layer of patterns, in order to obtain a more accurate alignment result, the annular printing area is divided into three areas: inner, middle, and outer. In particular, the relative displacement between the inner and outer circles is larger. The results of the rough alignment are used as the initial value on the inner and outer circles, and then a precise match is performed respectively. If each alignment is successful, the information including the aligned image, mask, detection area, etc. is stored in the Registration variable.
[0164] After the registration is complete, defect detection can be performed.
[0165] Defect detection in this application is divided into general non-comparative defect detection and general comparative defect detection.
[0166] Generally, non-contrasting defects are defects that can be judged without comparing with the template. They are absolute defects, including: partial ink shortage, pad printing offset, internal and external optical area stains, and printing area stains. Among them, non-contrasting ink shortage detection and printing area stain detection are predicted based on the neural network of target detection. The trained network can detect ink shortage defects and printing area stain defects without relying on the qualified product template provided by the user in advance; the input data of the pad printing offset detection operator and the internal and external optical area stain detection operator are all derived from RegionInfo. If the defect is detected, the result code of the defect is added to the result list until all detections are completed. If it is a modeling process, if the result list is empty, it means that the template is indeed a qualified product.
[0167] Compared with general comparative defects, they are relative defects and can only be detected by comparing with the template. They include partial ink shortage, color difference, and printing area stains. The input data for comparative ink shortage detection and printing area stain detection are derived from Registration, and the input data for color difference detection is derived from ColorInfo. In each defect detection, if the defect is detected, the result code of the defect will be added to the result list.
[0168] Based on the above classification, the detection of the color mold pad printing quality of the contact lens based on the regional features, the color features and the registered printing area is divided into:
[0169] (1) performing pad printing offset detection, optical zone stain detection, and non-contrast ink deficiency detection on the color mold pad printing quality of the contact lens based on the regional features; (2) performing contrast ink deficiency detection, color difference detection, and print zone stain detection based on the regional features, the color features, and the registered print area;
[0170] Figure 7 FIG. 1 is a flow chart of a pad printing offset detection process in an embodiment of the present application. Figure 7 As shown, the process of pad printing offset detection includes:
[0171] Taking the area within the edge of the mold as a reference range, and comparing the reference range with the registered printing area;
[0172] When the registered printing area exceeds the reference range, and the deviation between the center of the registered printing area and the center of the reference range exceeds a threshold, determining that pad printing offset exists;
[0173] When the ratio of the maximum spacing and the minimum spacing between the edge of the registered printing area and the edge of the mold is greater than a threshold, it is determined that pad printing offset exists.
[0174] After detecting the pad printing offset defect, add the pad printing offset to the result code and output it.
[0175] Figure 7 The dry lens diameter refers to the final contact lens diameter. The offset ratio should be calculated based on the dry lens diameter. If the dry lens diameter is unknown, the offset calculation should be based on the mold.
[0176] Figure 8 FIG. 1 is a flow chart of stain detection in the optical zone in one embodiment of the present application. Figure 8 As shown, the optical zone stains include dark and light stains in the pupil area, and dark stains in the outer optical area. The optical zone stain detection process includes:
[0177] Determining a preset pupil area, wherein the pupil area is a circle formed by a fixed diameter;
[0178] Determine the shape of the printing area;
[0179] If the printed area is non-annular, performing optical stain detection on the pupil area based on pre-established detection conditions, wherein the detection conditions include an area screening threshold and a grayscale screening threshold;
[0180] If the printed area is annular, extract the inner contour of the printed area; determine whether the printed area is printed into the pupil area based on the inner contour; and perform optical stain detection on the annular area between the inner contour of the printed area and the pupil area and the pupil area based on pre-constructed detection conditions.
[0181] Finally, the stains in the annular area from the inner contour of the printed area to the pupil area and the pupil area are drawn on the same blank image. Since light-colored stains are more obvious in the multi-frame fused image, light-colored stain detection is performed on the fused image. If the external optical area stain detection function is turned on, external optical area stain detection is further performed.
[0182] Fig. 9 FIG. 1 is a flow chart of non-contrastive ink shortage detection in one embodiment of the present application. Fig. 9 As shown, the process of non-contrastive ink shortage detection includes:
[0183] The regional features are identified based on the pre-built neural network to obtain the ink shortage detection result.
[0184] Among them, the neural network in this application has been pre-trained and can be directly used for ink shortage detection.
[0185] Fig.10 FIG. 1 is a flow chart of non-contrastive ink shortage detection in one embodiment of the present application. Fig.10 As shown, in one embodiment of the present application, the comparative ink shortage detection process includes:
[0186] The area and radius of the registered printing area are compared with the area and radius of the preset printing area template respectively, and when they are inconsistent, it is determined that there is an ink shortage defect;
[0187] When the ink shortage defect is not an overall ink shortage defect, ink shortage detection is performed on the target area of the registered printing area to obtain the ink shortage position. The target area is the middle area, the outer circle area and the inner circle area.
[0188] Fig.11 FIG. 1 is a flow chart of color difference detection in an embodiment of the present application, as shown in FIG. Fig.11 As shown, the process of color difference detection includes:
[0189] Initialization parameters, the color difference detection result is determined by two detection results, namely the color difference result of each single color S And the overall color difference result W ;
[0190] A histogram is constructed based on the color feature, and the histogram is compared with a preset histogram template to obtain the overall color difference, and each single color is compared with a preset corresponding single color to obtain the color difference Result of each single color S ;
[0191] Construct color similarity based on the overall color difference and the color difference of each single color;
[0192] When the color similarity is greater than or equal to the preset similarity threshold, it is determined that there is no overall color difference and local color difference; at this time, Result S and Result W All are set as qualified; when there is no overall color difference and local color difference, if the color moment detection is turned on and the pattern is a closed ring, further detect whether there is color difference in the local single layer color, and the whole process ends;
[0193] When the color similarity is less than the preset similarity threshold, it indicates that there may be color difference, and it is necessary to further compare the histogram correlation, calculate the histogram correlation between the histogram and the preset histogram template, and when the histogram correlation is less than the preset correlation threshold, determine that there is an overall color difference and determine the single color with color difference; WSet it as having color difference, and then further locate which color has monochromatic color difference;
[0194] When the histogram correlation is greater than or equal to a preset correlation threshold, calculating a histogram distance between the histogram and a preset histogram template;
[0195] When the histogram distance is less than a preset distance threshold, calculating an overall color difference index between the histogram and a preset histogram template;
[0196] When the overall color difference index is less than the preset color difference threshold, it is determined that only monochromatic color difference exists; that is, Result W Set to Result S , which means that the overall color difference is determined by the monochromatic color difference at this time;
[0197] When the histogram distance is greater than or equal to the preset distance threshold, it is determined that there is an overall color difference and the single color with color difference is determined; if the histogram distance is not less than the given threshold, the Result W It is judged that there is color difference, which means there is overall color difference. Then we further explore which color has the monochromatic color difference and calculate the result of that color. S Set it to have color difference and end the process.
[0198] The process of detecting stains in the printing area includes: identifying the area features, the color features and the registered printing area based on a pre-built neural network to obtain the detection result of stains in the printing area.
[0199] Finally, the detected defects are sorted by priority, and the defect code with the highest priority is taken as the detection result and output. At this point, the whole process is completed.
[0200] This application has the following advantages:
[0201] 1: High efficiency and high precision. The real-time detection system and method for the online contact lens (cosmetic lens) color mold printing quality based on machine vision proposed in this application can achieve a single-sheet running speed of 1100ms in a real-machine test on an 8-core i5-11357 PC, which is nearly twice as fast as the offline detection equipment and meets the requirements for full inspection of the production line.
[0202] 2: In the online high-speed detection scenario, when the imaging environment is affected by vibration, through algorithm processing, a synthetic image with high resolution and high color dynamic range can still be obtained, thus ensuring the realization of subsequent high-precision detection.
[0203] 3: Aiming at the ink deficiency defect that can be sensitively perceived by human vision, an image registration method that takes into account both speed and accuracy is proposed, and combined with digital image processing and neural network algorithms, it achieves excellent detection effect to replace manual quality inspection. At the same time, the algorithm for identifying tiny color differences further makes up for the shortcomings of manual quality inspection results that are non-quantifiable and easily affected by the environment.
[0204] 4: By adjusting the defect priority, this method can easily adapt to the inspection needs of different customers, and can be widely adapted to the inspection of casting products with different patterns. It does not require too much manual intervention and can be run in a fool-proof manner.
[0205] The present invention discloses an online contact lens color mold pad printing quality real-time detection method, which acquires a color image sequence of a contact lens mold; aligns the mold area in the color image sequence, and calculates the average image of the aligned color image sequence to obtain an enhanced image; extracts regional features and color features from the enhanced image; registers the printing area to obtain the registered printing area; and detects the color mold pad printing quality of the contact lens based on the regional features, color features, and registered printing area. The present application acquires a color graphic sequence, calculates the average image after alignment, and then extracts the regional features and color features, thereby detecting the color mold pad printing quality of the contact lens, thereby achieving automatic detection, accurate detection, and high efficiency.
[0206] like Fig.11 As shown, the present application also provides an online contact lens color mold pad printing quality real-time detection system, which is characterized by comprising:
[0207] An acquisition module, used for acquiring a color image sequence of a contact lens casting mold, wherein the color image sequence includes a plurality of frames of color images of the contact lens;
[0208] An alignment module, used for aligning the mold area in the color image sequence, and calculating the average image of the aligned color image sequence to obtain an enhanced image, wherein the enhanced image includes the mold edge of the contact lens;
[0209] A feature extraction module, used to extract regional features and color features from the enhanced image, wherein the regional features include a printed area;
[0210] A registration module, used for registering the printing area to obtain a registered printing area;
[0211] A detection module is used to detect the color mold pad printing quality of the contact lens based on the regional features, the color features and the registered printing area.
[0212] The present invention discloses an online contact lens color mold pad printing quality real-time detection system, which acquires a color image sequence of a contact lens mold; aligns the mold area in the color image sequence, and calculates the average image of the aligned color image sequence to obtain an enhanced image; extracts regional features and color features from the enhanced image; registers the printing area to obtain the registered printing area; and detects the color mold pad printing quality of the contact lens based on the regional features, color features, and registered printing area. The present application acquires a color graphic sequence, calculates the average image after alignment, and then extracts the regional features and color features, thereby detecting the color mold pad printing quality of the contact lens, thereby achieving automatic detection, accurate detection, and high efficiency.
[0213] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, any one of the methods in this embodiment is implemented, wherein the method is the execution logic of this system.
[0214] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0215] 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.
[0216] 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.
[0217] 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.
[0218] 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.
[0219] 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.
[0220] 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.
[0221] 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 real-time detection method for the quality of online contact lens color mold pad printing, characterized in that: Includes steps: Acquire a color image sequence of the contact lens casting mold, wherein the color image sequence includes multiple frames of color images of the contact lens casting mold; Aligning the mold areas in the color image sequence, and calculating the average image of the aligned color image sequence to obtain an enhanced image, wherein the enhanced image includes the mold edge of the contact lens; aligning the mold areas in the color image sequence, including: converting the color image sequence into a grayscale image sequence; taking the last frame image in the grayscale image sequence as a reference image, binarizing the reference image and other images in the color image sequence to obtain a plurality of binarized images; performing median filtering on the multiple binarized reference images to obtain an intermediate image; continuing to perform contour extraction on the intermediate image to obtain a plurality of contours; screening out candidate contours that meet a preset area threshold from the multiple contours; fitting the candidate contours to obtain a circular contour, and extracting the center coordinates and radius of the circular contour; aligning the other images in the color image sequence to the reference image based on the center coordinates of the reference image, the radius of the reference image, the center coordinates of other images in the color image sequence, and the radius of other images in the color image sequence to obtain an aligned color image sequence; Extracting regional features and color features from the enhanced image, wherein the regional features include a printing area; extracting regional features from the enhanced image, including: converting the enhanced image to an HSV color space to obtain an HSV image, wherein the HSV image includes a saturation channel image and a brightness channel image; performing a difference between the saturation channel image and the brightness channel image to obtain a difference image, wherein the difference image represents a background area with low saturation and high brightness; negating the difference image to obtain a color enhanced image, i.e., a foreground area; and binarizing the negated image to obtain a binary image, thereby extracting an area with a high color span as a printing area; performing morphological judgment on the printing area; and determining, when the printing area is annular, a central optical zone and an outer optical zone of the contact lens based on the mold edge and the printing area of the contact lens, wherein the central optical zone is located within the printing area, and the outer optical zone is located within the printing area. outside the area; extracting color features from the enhanced image, including: converting the enhanced image to the LAB color space to obtain a LAB image; preprocessing the LAB image to obtain an intermediate image, wherein the preprocessing method includes Gaussian filtering and morphological corrosion operations; calculating the histogram of the intermediate image, and performing sliding window smoothing on the histogram to obtain histogram information; clustering the intermediate image to obtain color centers of multiple colors; and performing color threshold segmentation based on the color centers of the multiple colors and preset upper and lower thresholds to obtain pixel points of multiple classes and the number of pixel points of multiple classes; calculating the proportion and color density of each color based on the number of pixel points of multiple classes; performing morphological judgment on the printing area; and when the printing area is annular, dividing the printing area into multiple color ring areas based on multiple classes, and calculating the color moment of each color ring area; constructing color features based on the proportion of each color, the color density of each color and multiple color moments; The printing area is registered to obtain the registered printing area, including: converting the target area in the printing area and the pre-constructed registration template into polar coordinates to obtain the target area in the polar coordinates and the registration template in the polar coordinates, wherein the target area includes an inner layer area, a middle layer area and an outer layer area; calculating the translation amount of the target area in the polar coordinates and the registration template in the polar coordinates, and converting the translation amount into a rotation angle in Cartesian coordinates; constructing a two-dimensional transformation matrix based on the rotation angle , and based on the two-dimensional transformation matrix The target area is rotated to obtain a rotated target area, wherein the two-dimensional transformation matrix The mathematical expression is: in, , , is the rotation angle, is the scaling factor, is the scaling factor and rotation angle The product of the cosine functions of is the scaling factor and rotation angle The product of the sine functions of is the rotation center coordinate; construct the registered printing area based on all the rotated target areas; The color mold pad printing quality of the contact lens is detected based on the regional features, the color features and the registered printing area, including: performing pad printing offset detection, optical area stain detection and non-contrast ink lack detection on the color mold pad printing quality of the contact lens based on the regional features; and performing contrast ink lack detection, color difference detection and printing area stain detection based on the regional features, the color features and the registered printing area; Among them, the non-contrasting ink deficiency detection and the printing area stain detection are based on neural network prediction of target detection, the pad printing offset detection and the optical area stain detection are based on the regional characteristics and color characteristics, and the contrasting ink deficiency detection and the color difference detection are based on template comparison.
2. According to claim 1, a real-time detection method for online contact lens color mold pad printing quality is characterized in that: Extracting the center coordinates and radius of the circular contour includes: Calculate the zero-order moment of the binary image where the circular contour is located , first-order moment and first-order moment ; in, , , , is the pixel coordinate of the binary image where the circular contour is located, Pixel The gray value of is the number of horizontal coordinate pixels of the binary image where the circular contour is located, is the number of pixels in the ordinate of the binary image where the circular contour is located; Based on the zero-order moment of the binary image where the circular contour is located , first-order moment and first-order moment Calculate the center coordinates of the circular contour ,in, , ; and based on the zero-order moment of the binary image where the circular contour is located Calculate the radius of the circular outline ,in, .
3. The method for real-time detection of online contact lens color mold printing quality according to claim 1, characterized in that: Aligning other images in the color image sequence to the reference image based on the center coordinates of the reference image, the radius of the reference image, the center coordinates of other images in the color image sequence, and the radius of other images in the color image sequence to obtain an aligned color image sequence, including: For any color image in the color image sequence, an initial mask image is constructed, wherein the initial mask image Gao Wei , width is ; Based on the center coordinates of the reference image and the center coordinates of the color image Calculate the size of the edge filling area of the initial mask image , get the mask image ; Wherein, the mask image Gao Wei , the mask image The width is ; The size of the edge padding area , the mask image of high And the mask image Width The mathematical expression is: Based on the mask image Slice the color image to obtain an aligned image , where the aligned image The mathematical expression is: in, is the row coordinate of the 0th row of the aligned image on the mask image, is the column coordinate of the 0th column of the aligned image on the mask image, For the Aligned images; Based on all aligned images Construct an aligned color image sequence.
4. The method for real-time detection of online contact lens color mold printing quality according to claim 1, characterized in that: The process of detecting the pad printing offset includes: taking the area within the edge of the mold as a reference range, comparing the reference range with the registered printing area, and determining that there is a pad printing offset when the registered printing area exceeds the reference range and the deviation between the center of the registered printing area and the center of the reference range exceeds a threshold value; determining that there is a pad printing offset when the ratio of the maximum spacing and the minimum spacing between the edge of the registered printing area and the edge of the mold is greater than a threshold value; The process of optical zone stain detection includes: determining a preset pupil area, wherein the pupil area is a circle formed by a fixed diameter; determining the shape of a printing area; if the printing area is non-circular, performing optical stain detection on the pupil area based on pre-constructed detection conditions, wherein the detection conditions include an area screening threshold and a grayscale screening threshold; if the printing area is circular, extracting an inner contour of the printing area; judging whether the printing area is printed into the pupil area based on the inner contour; and performing optical stain detection on the circular area between the inner contour of the printing area and the pupil area and the pupil area based on the pre-constructed detection conditions; The process of the non-contrastive ink shortage detection includes: identifying ink shortage features in the regional features based on a pre-constructed neural network to obtain an ink shortage detection result.
5. The method for real-time detection of online contact lens color mold pad printing quality according to claim 1, characterized in that: The comparative ink shortage detection process includes: comparing the area and radius of the registered printing area with the area and radius of the preset printing area template respectively, and determining that there is an ink shortage defect when they are inconsistent; and performing ink shortage detection on the target area of the registered printing area to obtain the ink shortage position when the ink shortage defect is not an overall ink shortage defect; The color difference detection process includes: constructing a histogram based on the color feature, and comparing the histogram with a preset histogram template to obtain an overall color difference, and comparing each single color with a preset corresponding single color to obtain the color difference of each single color; constructing color similarity based on the color difference of each single color; when the color similarity is greater than or equal to a preset similarity threshold, determining that there is no overall color difference and local color difference; when there is no overall color difference and local color difference, performing color moment detection on the color feature to obtain a single-layer color difference; when the color similarity is less than a preset similarity threshold, calculating the directivity of the histogram with the preset histogram template; Histogram correlation, when the histogram correlation is less than a preset correlation threshold, it is determined that there is an overall color difference and a single color with color difference is determined; when the histogram correlation is greater than or equal to the preset correlation threshold, the histogram distance between the histogram and a preset histogram template is calculated, when the histogram distance is less than a preset distance threshold, the overall color difference index between the histogram and the preset histogram template is calculated, when the overall color difference index is less than a preset color difference threshold, it is determined that only a single color color difference exists; when the histogram distance is greater than or equal to the preset distance threshold, it is determined that there is an overall color difference and a single color with color difference is determined; The process of detecting stains in the printing area includes: identifying the area features, the color features and the registered printing area based on a pre-built neural network to obtain the detection result of stains in the printing area.
6. An online contact lens color mold pad printing quality real-time detection system, characterized in that: include: An acquisition module, used for acquiring a color image sequence of a contact lens casting mold, wherein the color image sequence includes a plurality of frames of color images of the contact lens casting mold; an alignment module, for aligning the mold areas in the color image sequence, and calculating the average image of the aligned color image sequence to obtain an enhanced image, wherein the enhanced image includes the mold edge of the contact lens; aligning the mold areas in the color image sequence, including: converting the color image sequence into a grayscale image sequence; taking the last frame image in the grayscale image sequence as a reference image, binarizing the reference image and other images in the color image sequence to obtain a plurality of binarized images; performing median filtering on the plurality of binarized reference images to obtain an intermediate image; continuing to perform contour extraction on the intermediate image to obtain a plurality of contours; screening out candidate contours that meet a preset area threshold from the plurality of contours; fitting the candidate contours to obtain a circular contour, and extracting the center coordinates and radius of the circular contour; aligning the other images in the color image sequence to the reference image based on the center coordinates of the reference image, the radius of the reference image, the center coordinates of other images in the color image sequence, and the radius of other images in the color image sequence to obtain an aligned color image sequence; The feature extraction module is used to extract regional features and color features from the enhanced image, wherein the regional features include a printing area; extracting regional features from the enhanced image includes: converting the enhanced image to an HSV color space to obtain an HSV image, wherein the HSV image includes a saturation channel image and a brightness channel image; performing a difference between the saturation channel image and the brightness channel image to obtain a difference image, wherein the difference image represents a background area with low saturation and high brightness; negating the difference image to obtain a color enhanced image, i.e., a foreground area; and binarizing the negated image to obtain a binary image, thereby extracting an area with a high color span as a printing area; performing morphological judgment on the printing area; and determining, when the printing area is annular, a central optical zone and an outer optical zone of the contact lens based on the mold edge of the contact lens and the printing area, wherein the central optical zone is located within the printing area and the outer optical zone is located within the printing area. outside the printing area; extracting color features from the enhanced image, including: converting the enhanced image to the LAB color space to obtain a LAB image; preprocessing the LAB image to obtain an intermediate image, wherein the preprocessing method includes Gaussian filtering and morphological corrosion operations; calculating the histogram of the intermediate image, and performing sliding window smoothing on the histogram to obtain histogram information; clustering the intermediate image to obtain color centers of multiple colors; and performing color threshold segmentation based on the color centers of the multiple colors and preset upper and lower thresholds to obtain pixel points of multiple classes and the number of pixel points of multiple classes; calculating the proportion and color density of each color based on the number of pixel points of multiple classes; performing morphological judgment on the printing area; and when the printing area is annular, dividing the printing area into multiple color ring areas based on multiple classes, and calculating the color moment of each color ring area; constructing color features based on the proportion of each color, the color density of each color and multiple color moments; A registration module is used to register the printing area to obtain the registered printing area, including: converting the target area in the printing area and the pre-constructed registration template to polar coordinates to obtain the target area in the polar coordinates and the registration template in the polar coordinates, wherein the target area includes an inner layer area, a middle layer area and an outer layer area; calculating the translation amount of the target area in the polar coordinates and the registration template in the polar coordinates, and converting the translation amount into a rotation angle in Cartesian coordinates; constructing a two-dimensional transformation matrix based on the rotation angle , and based on the two-dimensional transformation matrix The target area is rotated to obtain a rotated target area, wherein the two-dimensional transformation matrix The mathematical expression is: in, , , is the rotation angle, is the scaling factor, is the scaling factor and rotation angle The product of the cosine functions of is the scaling factor and rotation angle The product of the sine functions of is the rotation center coordinate; construct the registered printing area based on all the rotated target areas; A detection module, for detecting the color mold pad printing quality of the contact lens based on the regional features, the color features and the registered printing area, including: performing pad printing offset detection, optical area stain detection and non-contrast ink lack detection on the color mold pad printing quality of the contact lens based on the regional features; and performing contrast ink lack detection, color difference detection and printing area stain detection based on the regional features, the color features and the registered printing area; Among them, the non-contrasting ink deficiency detection and the printing area stain detection are based on neural network prediction of target detection, the pad printing offset detection and the optical area stain detection are based on the regional characteristics and color characteristics, and the contrasting ink deficiency detection and the color difference detection are based on template comparison.
Citation Information
Patent Citations
Taking verification method, device, system and equipment for consumable cabinet
CN115223293A
Contact lens flaw detection method and system, electronic equipment and storage medium
CN115239663A