Method and system for extracting printing ring of printing contact lens based on machine vision
The method and system use machine vision to accurately identify and isolate printed regions on decorative contact lenses, enhancing defect detection and reducing labor costs in production.
Patent Information
- Application Number
- CN202410666483.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2044-05-28
AI Technical Summary
The prior art is difficult to effectively extract the printing area of the contact lens, resulting in the inability to provide assistance for subsequent defect detection.
Using a machine vision-based method, the printing area is determined by acquiring the original image of the contact lens, pre-processing, contour feature extraction and geometric parameter analysis.
Effective extraction of the printing area of contact lenses is achieved, the accuracy and production efficiency of defect detection are improved, and labor costs are reduced.
Smart Images

Figure CN118644510B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision, and specifically to a method and system for extracting a printing ring of a printed contact lens based on machine vision. Background Art
[0002] A contact lens, also called a corneal contact lens or a corneal contact glass, refers to a lens worn on the cornea of the eyeball to correct vision or protect the eyes. In order to make the wearing of contact lenses more beautiful, in the prior art, patterns are also printed on the surface of contact lenses, such as colored contact lenses.
[0003] However, due to the differences in the lens materials, processes, and formulas of contact lenses, printed contact lenses have various forms, and it is difficult to have a good method for extracting the printing ring area of printed contact lenses, so that it is impossible to provide assistance for subsequent defect detection of the lens surface area. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a method and system for extracting a printing ring of a printed contact lens based on machine vision to solve the problem that it is difficult to extract the printing area of contact lenses in the prior art.
[0005] To achieve the above purpose, the present invention adopts the following technical solutions:
[0006] A method for extracting a printing ring of a printed contact lens based on machine vision according to the present invention includes:
[0007] Obtaining an original image of a contact lens;
[0008] Preprocessing the original image to obtain a process image, wherein the preprocessing includes noise reduction processing;
[0009] Extracting the contour features of the process image and determining whether there is a contact lens in the process image based on the contour features of the process image;
[0010] When there is a contact lens in the process image, extracting the geometric parameters of the contact lens in the process image;
[0011] Extracting the printing area in the process image based on the geometric parameters of the edge contour of the contact lens.
[0012] In an embodiment of the present application, preprocessing the original image to obtain a process image includes:
[0013] Converting the original image from RAW format to RGB format to obtain an intermediate image;
[0014] Transform the first intermediate image to the grayscale space to obtain a grayscale image;
[0015] Perform Gaussian filtering on the grayscale image to obtain a process image.
[0016] In an embodiment of the present application, extracting the contour features of the process image and determining whether there is a contact lens in the process image based on the contour features of the process image includes:
[0017] Extract the contour pixel points of the process image based on a contour extraction operator;
[0018] Count the contour pixel points to obtain the number of contour pixel points;
[0019] Compare the number of the contour pixel points with a preset number threshold, and when the number of the contour pixel points is greater than the preset number threshold, determine that there is a contact lens in the process image, and when the number of the contour pixel points is less than or equal to the preset number threshold, determine that there is no contact lens in the process image.
[0020] In an embodiment of the present application, extracting the geometric parameters of the contact lens in the process image includes:
[0021] Extract the edge contour in the process image to obtain an edge contour image;
[0022] Filter the contours in the edge contour image based on pre-configured lens parameters to obtain the edge contour of the contact lens;
[0023] Count the number of pixel points of the edge contour of the contact lens to obtain the effective pixel number PixNum; and perform integrity verification on the edge contour of the contact lens based on the effective pixel number PixNum;
[0024] When it is determined that the edge contour of the contact lens is complete, fit the edge contour of the contact lens to obtain a fitted contour and the geometric parameters to be tested of the fitted contour;
[0025] Perform geometric verification on the geometric parameters to be tested based on pre-configured lens parameters, and when passing the geometric verification of the geometric parameters to be tested, obtain the geometric parameters of the edge contour of the contact lens.
[0026] In an embodiment of the present application, the pre-configured lens parameters include the longest diameter interval DMaxRange, the shortest diameter interval DMinRange, the maximum tolerance threshold range DDiff of the lens major and minor axes, and the lens aspect ratio AspectRatio. Among them, based on the pre-configured lens parameters, screening the contours in the edge contour image to obtain the edge contour of the contact lens includes:
[0027] Extract the geometric parameters of the contours in the edge contour image, where the geometric parameters of the contours include the major axis diameter a1, the minor axis diameter b1, the average diameter d1, the diameter difference dif1, and the aspect ratio asp1, d1 = mean(a1, b1), dif1 = abs(a1 - b1), asp1 = b1 / a1;
[0028] Match the geometric parameters of the contours in the edge contour image with the pre-configured lens parameters, and when the geometric parameters of the contours in the edge contour image and the pre-configured lens parameters meet the first target condition, use the contours in the edge contour image as the edge contour of the contact lens, where the first target condition includes:
[0029] The average diameter d1 is within the intersection interval DMaxRange&DMinRange of the longest diameter interval DMaxRange and the shortest diameter interval DMinRange;
[0030] The aspect ratio asp1 is greater than or equal to the lens aspect ratio AspectRatio;
[0031] The diameter difference dif1 is within the maximum tolerance threshold range DDiff of the lens major and minor axes.
[0032] In an embodiment of the present application, performing integrity verification on the edge contour of the contact lens based on the effective pixel number PixNum includes:
[0033] When the effective pixel number PixNum satisfies PixNum / edgeSamNumMin > rateTh, determine that the edge contour of the contact lens is complete; otherwise, determine that the edge contour of the contact lens is incomplete, where edgeSamNumMin is the minimum threshold of the pre-set effective edge sampling points, and rateTh is the pre-set lens edge ratio.
[0034] In an embodiment of the present application, the geometric parameters to be tested include the major axis diameter a2, the minor axis diameter b2, the average diameter d2, the diameter difference dif2, and the aspect ratio asp2, where d2 = mean(a2, b2), dif2 = abs(a2 - b2), asp2 = b2 / a2;
[0035] Geometrically verifying the geometric parameters to be inspected based on pre-configured lens parameters, including:
[0036] Matching the geometric parameters to be inspected with the pre-configured lens parameters, and performing geometric verification on the geometric parameters to be inspected when the geometric parameters to be inspected and the pre-configured lens parameters meet the second target condition, where the second target condition includes:
[0037] The average diameter d2 is within the intersection interval DMaxRange&DMinRange of the longest diameter interval DMaxRange and the shortest diameter interval DMinRange;
[0038] The aspect ratio asp2 is greater than or equal to the aspect ratio of the lens AspectRatio;
[0039] The diameter difference dif2 is within the maximum tolerance threshold range DDiff of the major and minor axes of the lens.
[0040] In an embodiment of the present application, extracting the printed area in the process image based on the geometric parameters of the edge profile of the contact lens, including:
[0041] Performing polar coordinate transformation on the process image based on the geometric parameters of the edge profile of the contact lens to obtain a polar coordinate image, where the printed area in the polar coordinate image is a vertical strip;
[0042] Projecting the polar coordinate image along the vertical direction to obtain a one-dimensional vector, where the one-dimensional vector includes the number of printing textures at multiple positions;
[0043] Determining the starting coordinate and ending coordinate of the printed area from the one-dimensional vector based on a preset outer contour threshold of the printed area and an inner contour threshold of the printed area;
[0044] Verifying the starting coordinate and ending coordinate of the printed area based on preset verification parameters, where the verification parameters include the outer contour threshold of the printed area, the minimum radius of the printing ring, and the outer contour radius of the printing ring;
[0045] When verifying the starting coordinate and ending coordinate of the printed area, constructing the printed area based on the starting coordinate and ending coordinate of the printed area.
[0046] In an embodiment of the present application, the printed area is annular, and the mathematical expression of the inner circle innerEllipse of the printed area is:
[0047] innerEllipse = ((cx, cy), (sx * 2, sx * 2), 0)
[0048] The foreign mathematical expression of the printing area is:
[0049] outerEllipse = ((cx, cy), (ex * 2, ex * 2), 0)
[0050] The mathematical expression of the overall lens fullEllipse is:
[0051] fullEllipse = ((cx, cy), (a, b), 0)
[0052] Among them, (cx, cy) are the central coordinates of the printing area, sx is the starting abscissa of the printing area, ex is the ending abscissa of the printing area, a is the major axis diameter of the printing area, and b is the minor axis diameter of the printing area.
[0053] This application also provides a printing ring extraction system for a printed contact lens based on machine vision, including:
[0054] An acquisition module, configured to acquire the original image of the contact lens;
[0055] A preprocessing module, configured to preprocess the original image to obtain a process image, where the preprocessing includes noise reduction processing;
[0056] A contour extraction module, configured to extract the contour features of the process image and determine whether a contact lens exists in the process image based on the contour features of the process image;
[0057] A geometric parameter extraction module, configured to extract the geometric parameters of the edge contour of the contact lens from the process image when a contact lens exists in the process image;
[0058] A printing area extraction module, configured to extract the printing area in the process image based on the geometric parameters of the edge contour of the contact lens.
[0059] The beneficial effects of the present invention are as follows: A method and system for extracting a printing ring of a printed contact lens based on machine vision according to the present invention obtain an original image of the contact lens; then preprocess the original image to obtain a process image, wherein the preprocessing includes noise reduction processing; extract the contour features of the process image, and determine whether there is a contact lens in the process image based on the contour features of the process image; when there is a contact lens in the process image, extract the geometric parameters of the contact lens in the process image; and extract the printing area in the process image based on the geometric parameters of the edge contour of the contact lens. This application can effectively extract the printing area of the contact lens, effectively help contact lens-related enterprises detect edge defects and locate problems in the previous process, thereby greatly avoiding the misguidance caused by human senses during manual detection, further reducing labor costs, and greatly improving product production efficiency. At the same time, it can adapt to lenses of different colors, patterns, sizes, and materials from various contact lens manufacturers, is convenient to transplant, and can be applied to the current production environment more efficiently and conveniently. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The present invention will be further described below with reference to the drawings and embodiments:
[0061] Figure 1 It is a flowchart of a method for extracting a printing ring of a printed contact lens based on machine vision shown in an embodiment of the present application;
[0062] Figure 2 It is a schematic diagram of a preprocessing process in an embodiment of the present application;
[0063] Figure 3 It is a schematic diagram of a contour judgment process in an embodiment of the present application;
[0064] Figure 4 It is a schematic diagram of an edge extraction process in an embodiment of the present application;
[0065] Figure 5 It is a schematic diagram of a process for extracting a printing area in an embodiment of the present application;
[0066] Figure 6 It is a schematic diagram of a process image in an embodiment of the present application;
[0067] Figure 7 It is a polar coordinate image in an embodiment of the present application;
[0068] Figure 8 It is a schematic diagram of a vertical projection in an embodiment of the present application;
[0069] Figure 9 It is a structural diagram of a system for extracting a printing ring of a printed contact lens based on machine vision in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0070] The following specific examples are used to illustrate the implementation of the present invention. 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, and various 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, without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0071] It should be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner. Therefore, only the layers related to the present invention are shown in the diagrams, rather than being drawn according to the number, shape, and size of the layers in actual implementation. The type, quantity, and ratio of each layer in actual implementation can be arbitrarily changed, and the layer layout type may also be more complex.
[0072] In the following description, a large number of details are explored to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details.
[0073] Before implementing a method for extracting a printing ring of a printing contact lens based on machine vision in this application, various parameters need to be pre-configured, specifically including:
[0074] Lens size parameters: including lens size parameters, such as the longest diameter interval DMaxRange, the shortest diameter interval DMinRange, the maximum tolerance threshold DDiff for the major and minor axes of the lens, the aspect ratio AspectRatio of the lens, etc.
[0075] Loading algorithm parameters: including extraction parameters, analysis parameters, etc., details are as follows:
[0076] Canny algorithm offset parameter edgeC, no-slice threshold parameter missTh;
[0077] Minimum threshold edgeSamNumMin for the number of effective edge sampling points, ratio rateTh of the lens edge;
[0078] Polar coordinate sampling angle deg, inner contour threshold printInnerTh of the printing area, outer contour threshold printOuterTh of the printing area, minimum radius printRMin of the printing ring, outer contour radius printOuterR of the printing ring;
[0079] System configuration parameters: whether to output images, etc.
[0080] After the above parameter configuration is completed, the following extraction process is started.
[0081] Figure 1 It is a flowchart of a method for extracting a printing ring of a machine vision-based printed contact lens shown in an embodiment of the present application. As Figure 1 shown, the present application includes image acquisition, preprocessing, contour judgment, edge extraction, printing area extraction, and result output. The specific introduction of each step is as follows:
[0082] S100, Image acquisition: Acquire the original image of the contact lens;
[0083] The present application takes pictures of the contact lens based on a pre-configured camera to obtain the original image;
[0084] S200, Preprocessing: Preprocess the original image to obtain a process image. Among them, the preprocessing includes noise reduction processing;
[0085] The preprocessing process is responsible for initializing the configuration of the detection system, as well as reading, loading, color space conversion, noise reduction, etc. on the contact lens image collected by the camera to reduce the interference caused by environmental noise, and finally generating the process image ProcessImage;
[0086] Figure 2 It is a schematic diagram of the preprocessing process in an embodiment of the present application. As Figure 2 shown, the specific process of the preprocessing includes:
[0087] S210, Convert the original image from RAW format to RGB format to obtain an intermediate image;
[0088] Specifically, the present application loads, decodes, and obtains the original image data of the camera, and converts it from RAW to RGB format to obtain the intermediate image Image.
[0089] S220, Transform the first intermediate image Image to the grayscale space to obtain a grayscale image GrayImage;
[0090] S230, Perform Gaussian filtering on the grayscale image to obtain a process image ProcessImage.
[0091] Specifically, in this embodiment, the grayscale image GrayImage is subjected to Gaussian filtering with a kernel of 3×3 to obtain ProcessImage, aiming to reduce the interference caused by environmental noise.
[0092] S300, Contour judgment: Extract the contour features of the process image, and judge whether there is a contact lens in the process image based on the contour features of the process image;
[0093] The contour judgment process is responsible for using the Canny algorithm on the process image ProcessImage and judging whether there is a lens based on the relevant pixel content extracted. The offset parameter edgeC of the Canny algorithm is pre-configured.
[0094] Figure 3 This is a schematic diagram of the contour judgment process in an embodiment of the present application. As Figure 3 shown, after loading the process image ProcessImage and configuring the parameters edgeC and missTh, the contour judgment starts;
[0095] The specific contour judgment process includes:
[0096] S310, extracting the contour pixel points of the process image based on a contour extraction operator;
[0097] Specifically, use the Canny algorithm with the offset parameter edgeC to extract the edge contour.
[0098] S320, counting the contour pixel points to obtain the number of contour pixel points PixNum;
[0099] S330, comparing the number of the contour pixel points with a preset number threshold. When the number of the contour pixel points is greater than the preset number threshold, it is determined that there is a contact lens in the process image. When the number of the contour pixel points is less than or equal to the preset number threshold, it is determined that there is no contact lens in the process image.
[0100] In this embodiment, for the number of contour pixel points PixNum, use missTh to judge PixNum. If it is less than or equal to, it means there is no lens, assign "No Lens" to the lens result Res and output the result. Otherwise, it is considered that this module passes and assign "Pass" to the lens result Res. The expression is as follows:
[0101]
[0102] When the lens result Res is "Pass", it indicates that there is a contact lens in the process image ProcessImage, and then the subsequent S400 process is carried out;
[0103] S400, edge extraction: when there is a contact lens in the process image, extract the geometric parameters of the contact lens in the process image;
[0104] The edge extraction process is responsible for using an edge extraction algorithm on the ProcessImage generated by A to adaptively extract the corresponding lens edge image Edge and the geometric parameters Pars of the corresponding fitted ellipse, such as the centroid, major and minor axes of the lens.
[0105] Figure 4 This is a schematic diagram of the edge extraction process in an embodiment of the present application. As Figure 4 shown, the specific edge extraction process includes:
[0106] S410, extract the edge contour in the process image to obtain an edge contour image;
[0107] The present application uses an adaptive algorithm to perform edge extraction on the ProcessImage to obtain the corresponding edge contour image Bin. In specific implementation, other edge detection operators such as Sobel, Canny, Robert, etc. can also be used.
[0108] S420, screen the contours in the edge contour image based on the pre-configured lens parameters to obtain the edge contour of the contact lens;
[0109] Specifically, the pre-configured lens size parameters are used for screening. If the contour meets the lens size parameters, it enters the subsequent process; if not, the result of this image is set to "Reverse", and the process ends and outputs the result.
[0110] The specific process of screening includes:
[0111] S421, extract the geometric parameters of the contours in the edge contour image, where the geometric parameters of the contours include the major axis diameter a1, the minor axis diameter b1, the average diameter d1, the diameter difference dif1, and the aspect ratio asp1, d1 = mean(a1, b1), dif1 = abs(a1 - b1), asp1 = b1 / a1;
[0112] S422, match the geometric parameters of the contours in the edge contour image with the pre-configured lens parameters, and when the geometric parameters of the contours in the edge contour image and the pre-configured lens parameters meet the first target condition, use the contours in the edge contour image as the edge contour of the contact lens, where the first target condition includes:
[0113] The average diameter d1 is within the intersection interval DMaxRange & DMinRange of the longest diameter interval DMaxRange and the shortest diameter interval DMinRange;
[0114] The aspect ratio asp1 is greater than or equal to the lens aspect ratio AspectRatio;
[0115] The diameter difference dif1 is within the maximum tolerance threshold range DDiff of the lens major and minor axes.
[0116] The expression of the screening process is:
[0117]
[0118] S430, count the number of pixel points of the edge contour of the contact lens to obtain the effective pixel number PixNum; and perform integrity verification on the edge contour of the contact lens based on the effective pixel number PixNum;
[0119] After obtaining the edge contour of the contact lens, integrity verification is also required. A complete contour can be directly fitted to obtain the complete lens contour in an elliptical shape. An incomplete contour cannot be fitted.
[0120] Among them, when the effective pixel number PixNum satisfies PixNum / edgeSamNumMin > rateTh, it is determined that the edge contour of the contact lens is complete and proceeds to the subsequent process; otherwise, it is determined that the edge contour of the contact lens is incomplete, where edgeSamNumMin is the minimum threshold of the effective edge sampling points set in advance, and rateTh is the proportion of the lens edge set in advance.
[0121] When the edge contour of the contact lens is incomplete, the image result is set to Crack, the process ends and the result is output.
[0122] The expression for integrity verification is:
[0123]
[0124] S440, when it is determined that the edge contour of the contact lens is complete, fit the edge contour of the contact lens to obtain the fitted contour and the geometric parameters to be verified of the fitted contour;
[0125] The method adopted in this application is the least squares fitting ellipse algorithm based on PCA. In specific implementation, other fitting ellipse algorithms can also be used, such as the three-arc combination selection algorithm.
[0126] Thus, the geometric parameters of the fitted ellipse corresponding to the contour are obtained, which are the major axis diameter a2, the minor axis diameter b2, the average diameter d2, the diameter difference dif2, and the aspect ratio asp2 respectively, where d2 = mean(a2, b2), dif2 = abs(a2 - b2), and asp2 = b2 / a2 (a2 ≠ 0).
[0127] S450, perform geometric verification on the geometric parameters to be verified based on the pre-configured lens parameters. When passing the geometric verification of the geometric parameters to be verified, obtain the geometric parameters of the edge contour of the contact lens.
[0128] The method of geometric verification is the same as the screening process in step S420, specifically including:
[0129] Match the geometric parameters to be inspected with the pre-configured lens parameters, and when the geometric parameters to be inspected and the pre-configured lens parameters meet the second target condition, perform geometric verification on the geometric parameters to be inspected, where the second target condition includes:
[0130] The average diameter d2 is within the intersection interval DMaxRange&DMinRange of the longest diameter interval DMaxRange and the shortest diameter interval DMinRange;
[0131] The aspect ratio asp2 is greater than or equal to the lens aspect ratio AspectRatio;
[0132] The diameter difference dif2 is within the maximum tolerance threshold range DDiff of the major and minor axes of the lens.
[0133] Its expression is:
[0134]
[0135] When passing the geometric verification, perform the subsequent process. If the geometric verification cannot be passed, end the process and output the result.
[0136] S500, Printing area extraction: Extract the printing area in the process image based on the geometric parameters of the edge contour of the contact lens.
[0137] Figure 5 This is a schematic flow diagram of the printing area extraction in an embodiment of the present application, as Figure 5 shown. Specifically, the printing area extraction process includes:
[0138] S510, Perform polar coordinate transformation on the process image based on the geometric parameters of the edge contour of the contact lens to obtain a polar coordinate image, where the printing area in the polar coordinate image is a vertical strip;
[0139] In the present application, the geometric parameters Pars extracted above are used to perform polar coordinate transformation on the process image ProcessImage to obtain the polar coordinate image Polar_Pro; specifically:
[0140] Perform radius scanning with the center coordinate as the center point.
[0141] Among them, the center of the circle required by the polar coordinate transformation formula is the ellipse center c(cx, cy) in Pars, the radius is r = mean(a2 / / 2, b2 / / 2), the horizontal axis in the polar coordinate system is the polar angle, and the vertical axis is the polar radius. Here
[0142] The transformation formula is:
[0143] The sampling angle deg is pre-configured, and the number of samples obtained is
[0144] Therefore, in this application, the process image ProcessImag is subjected to polar coordinate transformation using c and cnt, and the interpolation method is nearest neighbor interpolation to obtain the polar coordinate image Polar_Pro;
[0145] Figure 6 It is a schematic diagram of the process image in an embodiment of this application, Figure 7 It is the polar coordinate image in an embodiment of this application, as Figure 6 - Figure 7 As shown, the circular ring in the original image becomes a strip through polar coordinate transformation.
[0146] S520, project the polar coordinate image along the vertical direction to obtain a one-dimensional vector, where the one-dimensional vector includes the number of printing textures at multiple positions;
[0147] Figure 8 It is a schematic diagram of the vertical projection in an embodiment of this application, as Figure 8 As shown, the polar coordinate image Polar_Pro is vertically projected according to the direction of the edge line to obtain the corresponding one-dimensional vector vec. The arrow in the figure indicates the projection direction, and the left part is the printed pattern part of the lens.
[0148] S530, determine the starting coordinate and ending coordinate of the printing area from the one-dimensional vector based on a preset outer contour threshold of the printing area and an inner contour threshold of the printing area;
[0149] This application uses the pre-configured inner contour threshold printInnerTh of the printing area and the outer contour threshold printOuterTh of the printing area to screen and traverse vec to determine the corresponding subscript of vec, and this subscript is the starting point ps and ending point pe of the printing area.
[0150] In this embodiment, the comparison can be continued in sequence. The area that meets the inner contour threshold printInnerTh of the printing area is used as the starting point ps, and the area that meets the outer contour threshold printOuterTh of the printing area is used as the ending point ps.
[0151] Among them, since the center of the circle in Pars is used as the expansion of the polar coordinate system, it can be considered that the inner ring radius of the printing area is the abscissa sx where ps is located, and the outer ring radius of the printing area is the abscissa ex where ps is located, where sx < ex
[0152] S540, verify the starting coordinates and ending coordinates of the printing area based on preset verification parameters, where the verification parameters include the outer contour threshold of the printing area printOuterTh, the minimum radius of the printing ring printRMin, and the outer contour radius of the printing ring printOuterR;
[0153] If all conditions are met, it is considered that the extraction of the printing area is successful, and the subsequent process is entered; otherwise, it exits, assigns the lens result Res to "Print Failed", and finally enters the result output module.
[0154] S550, when verifying the starting coordinates and ending coordinates of the printing area, construct the printing area based on the starting coordinates and ending coordinates of the printing area.
[0155] Among them, the printing area is annular, and the mathematical expression of the inner circle innerEllipse of the printing area is:
[0156] innerEllipse = ((cx, cy), (sx * 2, sx * 2), 0)
[0157] The mathematical expression of the outer circle of the printing area is:
[0158] outerEllipse = ((cx, cy), (ex * 2, ex * 2), 0)
[0159] The mathematical expression of the overall lens fullEllipse is:
[0160] fullEllipse = ((cx, cy), (a, b), 0)
[0161] Among them, (cx, cy) is the center coordinate of the printing area, sx is the starting abscissa of the printing area, ex is the ending abscissa of the printing area, a is the major axis diameter of the printing area, and b is the minor axis diameter of the printing area.
[0162] S600, result output;
[0163] Package and output the above results. For example, "no lens" in step S300. When a lens is detected, for a normal lens, output the obtained printing ellipse information, that is, innerEllipse, outerEllipse, fullEllipse; otherwise, output the corresponding step.
[0164] This application has been verified in practice and can achieve a processing capacity of 50 ms per sheet in the PC real machine test of 8-core i5-11357.
[0165] There are a total of 500 groups of test samples, which are images of printed contact lenses from various manufacturers.
[0166] The system report outputs the corresponding inner ring ellipse information and outer ring ellipse information of the printing, a total of 500 groups, and the extraction rate is 100%.
[0167] Using this edge defect detection system can effectively help contact lens-related enterprises detect edge defects and locate problems in the previous process, can greatly avoid the misguidance caused by the human eye's senses during manual inspection, and at the same time further reduce labor costs and greatly improve product production efficiency.
[0168] Operating with the relevant configuration table adopted in this application can very easily adapt to lenses of different colors, patterns, sizes, and materials from various contact lens manufacturers, is convenient for transplantation, and can be applied to the current production environment more efficiently and conveniently.
[0169] The printing ring extraction system for printed contact lenses based on machine vision proposed in this application has a higher deployment convenience and a better user experience, effectively filling the market gap compared with the current mechanical deployment operation.
[0170] As Figure 9 shown, this application also provides a printing ring extraction system for printed contact lenses based on machine vision, including:
[0171] An acquisition module for acquiring the original image of the contact lens;
[0172] A preprocessing module for preprocessing the original image to obtain a process image, where the preprocessing includes noise reduction processing;
[0173] A contour extraction module for extracting the contour features of the process image and judging whether there is a contact lens in the process image based on the contour features of the process image;
[0174] A geometric parameter extraction module for extracting the geometric parameters of the edge contour of the contact lens from the process image when there is a contact lens in the process image;
[0175] A printing area extraction module for extracting the printing area in the process image based on the geometric parameters of the edge contour of the contact lens.
[0176] A printing ring extraction system for a printed contact lens based on machine vision according to the present invention includes obtaining an original image of the contact lens; then preprocessing the original image to obtain a process image, where the preprocessing includes noise reduction processing; extracting contour features of the process image, and determining whether a contact lens exists in the process image based on the contour features of the process image; when a contact lens exists in the process image, extracting geometric parameters of the contact lens in the process image; and extracting a printed area in the process image based on the geometric parameters of the edge contour of the contact lens. This application can effectively extract the printed area of the contact lens, effectively help contact lens-related enterprises detect edge defects and locate problems in the previous process, thereby greatly avoiding the misguidance caused by human senses during manual inspection, further reducing labor costs, and greatly improving product production efficiency. At the same time, it can adapt to lenses of different colors, patterns, sizes, and materials from various contact lens manufacturers, is easy to transplant, and can be applied to the current production environment more efficiently and conveniently.
[0177] This embodiment also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements any one of the methods in this embodiment, where the method is the execution logic of this system.
[0178] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0179] 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.
[0180] For the computer-readable storage medium in this embodiment, those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to a computer program. The foregoing computer program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes: various media such as ROM, RAM, magnetic disk, or optical disk that can store program codes.
[0181] 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 a computer program, the communication interface is used for communication, and the processor and the transceiver are used to run the computer program so that the electronic terminal executes each step of the above method.
[0182] In this embodiment, the memory may include a Random Access Memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0183] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may 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.
[0184] In the above embodiments, although the present invention has been described in conjunction with specific embodiments of the present invention, many substitutions, 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 substitutions, modifications, and variations that fall within the broad scope of the appended claims.
[0185] The above embodiments are only illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Any person familiar with this technology can modify or change the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or changes made by those with ordinary knowledge in the technical field without departing from the spirit and technical ideas disclosed by the present invention should still be covered by the claims of the present invention.
Claims
1. A method for extracting a printing ring of a printed contact lens based on machine vision, characterized in that, Including the steps: Obtain the original image of the contact lens; Preprocess the original image to obtain a process image, where the preprocessing includes noise reduction processing; Extract the contour features of the process image, and determine whether there is a contact lens in the process image based on the contour features of the process image; When there is a contact lens in the process image, extract the geometric parameters of the contact lens in the process image; Extract the printed area in the process image based on the geometric parameters of the edge profile of the contact lens; extracting the printed area in the process image based on the geometric parameters of the edge profile of the contact lens includes: performing a polar coordinate transformation on the process image based on the geometric parameters of the edge profile of the contact lens to obtain a polar coordinate image, wherein the printed area in the polar coordinate image is a vertical strip; projecting the polar coordinate image along the vertical direction to obtain a one-dimensional vector, wherein the one-dimensional vector includes the number of printing textures at multiple positions; determining the starting coordinate and the ending coordinate of the printed area from the one-dimensional vector based on a preset outer contour threshold of the printed area and an inner contour threshold of the printed area; verifying the starting coordinate and the ending coordinate of the printed area based on a preset verification parameter, wherein the verification parameter includes an outer contour threshold of the printed area, a minimum radius of the printing ring, and an outer contour radius of the printing ring; when verifying the starting coordinate and the ending coordinate of the printed area, constructing the printed area based on the starting coordinate and the ending coordinate of the printed area; the printed area is annular, and the inner circle of the printed area The mathematical expression of is: The mathematical expression for the outer circle of the printing area is as follows: The overall lens The mathematical expression is: Among them, is the central coordinate of the printing area, is the starting abscissa of the printing area, is the ending abscissa of the printing area, is the major axis diameter of the printing area, is the minor axis diameter of the printing area.
2. The method for extracting a printing ring of a printing contact lens based on machine vision according to claim 1, wherein, Preprocess the original image to obtain a process image, including: Convert the original image from RAW format to RGB format to obtain an intermediate image; Transform the intermediate image to the grayscale space to obtain a grayscale image; Perform Gaussian filtering on the grayscale image to obtain a process image.
3. A method for extracting a printing ring of a machine vision-based printed contact lens according to claim 1, characterized in that, Extract the contour features of the process image, and determine whether there is a contact lens in the process image based on the contour features of the process image, including: Extract the contour pixel points of the process image based on a contour extraction operator; Count the contour pixel points to obtain the number of contour pixel points; Compare the number of contour pixel points with a preset number threshold, and when the number of contour pixel points is greater than the preset number threshold, determine that there is a contact lens in the process image, and when the number of contour pixel points is less than or equal to the preset number threshold, determine that there is no contact lens in the process image.
4. The method for extracting a printing ring of a machine vision-based printed contact lens according to claim 1, wherein Extract the geometric parameters of the contact lens in the process image, including: Extract the edge contour in the process image to obtain an edge contour image; Filter the contour in the edge contour image based on pre-configured lens parameters to obtain the edge contour of the contact lens; Count the number of pixels of the edge contour of the contact lens to obtain the effective number of pixels ; and based on the effective number of pixels perform integrity verification on the edge contour of the contact lens; When it is determined that the edge contour of the contact lens is complete, fit the edge contour of the contact lens to obtain a fitted contour and the geometric parameters to be verified of the fitted contour; Perform geometric verification on the geometric parameters to be verified based on pre-configured lens parameters, and when the geometric verification of the geometric parameters to be verified passes, obtain the geometric parameters of the edge contour of the contact lens.
5. The printing ring extraction method of a machine vision-based printed contact lens according to claim 4, wherein The pre-configured lens parameters include the longest diameter range , the shortest diameter range , the maximum tolerance threshold range of the major and minor axes of the lens and the aspect ratio of the lens . Among them, filtering the contours in the edge contour image based on the pre-configured lens parameters to obtain the edge contour of the contact lens includes: Extract the geometric parameters of the contour in the edge contour image, where the geometric parameters of the contour include the major axis diameter , the minor axis diameter , the average diameter , the diameter difference and the aspect ratio , , , ; Match the geometric parameters of the contour in the edge contour image with the pre-configured lens parameters, and when the geometric parameters of the contour in the edge contour image satisfy the first target condition, use the contour in the edge contour image as the edge contour of the contact lens, where the first target condition includes: Average diameter In the longest diameter range And the shortest diameter range Of the intersection range Inside; Aspect ratio Greater than or equal to the aspect ratio of the lens ; Diameter difference within the maximum tolerance threshold range of the major and minor axes of the lens inside 6. The method for extracting a printing ring of a machine vision-based printed contact lens according to claim 4, wherein Based on the number of effective pixels Perform integrity verification on the edge contour of the contact lens, including: When the number of effective pixels satisfies , it is determined that the edge contour of the contact lens is complete; otherwise, it is determined that the edge contour of the contact lens is incomplete, where is the minimum threshold of the number of effective edge sampling points set in advance, is the proportion of the lens edge set in advance.
7. A method for extracting a printing ring of a printing contact lens based on machine vision according to claim 4, characterized in that, The geometric parameters to be inspected include the major axis diameter , the minor axis diameter , the average diameter , the diameter difference and the aspect ratio , where , , ; Perform geometric verification on the geometric parameters to be verified based on pre-configured lens parameters, including: Match the geometric parameters to be verified with the pre-configured lens parameters, and when the geometric parameters to be verified and the pre-configured lens parameters satisfy the second target condition, pass the geometric verification of the geometric parameters to be verified, where the second target condition includes: Average diameter In the longest diameter range Intersecting with the shortest diameter range Intersection range Inside; Aspect ratio Greater than or equal to the aspect ratio of the lens ; Diameter difference Within the maximum tolerance threshold range of the major and minor axes of the lens Inside.
8. A printing ring extraction system for a printed contact lens based on machine vision, characterized in that, Including: An acquisition module for acquiring the original image of the contact lens; A preprocessing module for preprocessing the original image to obtain a process image, where the preprocessing includes noise reduction processing; The contour extraction module is used to extract the contour features of the process image and determine whether there is a contact lens in the process image based on the contour features of the process image; The geometric parameter extraction module is used to extract the geometric parameters of the edge contour of the contact lens from the process image when there is a contact lens in the process image; A printing area extraction module, configured to extract a printing area in the process image based on geometric parameters of an edge contour of the contact lens; extracting the printing area in the process image based on the geometric parameters of the edge contour of the contact lens includes: performing a polar coordinate transformation on the process image based on the geometric parameters of the edge contour of the contact lens to obtain a polar coordinate image, wherein the printing area in the polar coordinate image is a vertical strip; projecting the polar coordinate image along the vertical direction to obtain a one-dimensional vector, wherein the one-dimensional vector includes the number of printing textures at multiple positions; determining a starting coordinate and an ending coordinate of the printing area from the one-dimensional vector based on a preset outer contour threshold of the printing area and an inner contour threshold of the printing area; verifying the starting coordinate and the ending coordinate of the printing area based on preset verification parameters, wherein the verification parameters include the outer contour threshold of the printing area, the minimum radius of the printing ring, and the outer contour radius of the printing ring; when verifying the starting coordinate and the ending coordinate of the printing area, constructing the printing area based on the starting coordinate and the ending coordinate of the printing area; the printing area is annular, and the inner circle of the printing area The mathematical expression of is: The mathematical expression of the outer circle of the printing area is as follows: The overall lens The mathematical expression is: Among them, is the central coordinate of the printing area, is the starting abscissa of the printing area, is the ending abscissa of the printing area, is the major axis diameter of the printing area, is the minor axis diameter of the printing area.
Citation Information
Patent Citations
High-precision contact lens edge defect detection method and system based on machine vision
CN117269179A
Method and system for detecting flaws of printed contact lenses based on cloud-machine vision
CN118505634A