Contact lens printing area stain high-precision detection method and system based on convex defects
Through the detection method based on convex defects, the stains in the printing area of the contact lenses are quickly identified, which solves the problem of inefficient traditional manual detection and improves production efficiency and yield.
Patent Information
- Application Number
- CN202510446299.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-04-10
AI Technical Summary
Stain detection in the printing area of existing contact lenses relies on manual detection, which is inefficient and error-prone, making it difficult to identify complex surface features and tiny stains.
Using a detection method based on convex defects, the contact lens image is acquired for pre-processing, the outer ring profile of the printing area is positioned, the convex hull and convex defects are calculated, and the circular mask is constructed to extract stains.
It realizes fast and efficient stain detection in the printing area of contact lenses, improving production efficiency and yield.
Smart Images

Figure CN120374539A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer images, and specifically to a high-precision detection method and system for stains in the printing area of contact lenses based on convex defects. Background Art
[0002] The pattern printing method of contact lenses is mainly the pad printing method. When printing ink, the mold is exposed to the air, and impurities such as dust are likely to fall near the printing area of the mold, resulting in defects. Traditional contact lens quality detection methods rely on manual detection, and this detection method has the following deficiencies: the area of stains and defects is small, and it is necessary to manually detect under a high-power magnifying glass for a long time, which is prone to eye fatigue and incorrect judgment; the fine stains in the printing area are not easy to distinguish from the ink; the detection efficiency is relatively low, etc. Secondly, existing optical detection technologies are difficult to accurately identify and quantitatively analyze the complex surface features of contact lenses (such as pattern morphology, minute stains). Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a high-precision detection method and system for stains in the printing area of contact lenses based on convex defects to solve the problems in the background art.
[0004] To achieve the above purpose, the present invention adopts the following technical solutions:
[0005] A high-precision detection method for stains in the printing area of contact lenses based on convex defects of the present invention includes the steps of:
[0006] Obtain a contact lens image, and preprocess the contact lens image to obtain a preprocessed image;
[0007] Locate the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area;
[0008] Calculate the convex hull of the outer contour of the printing area, determine multiple convex defects in the printing area of the contact lens image based on the outer contour of the printing area and the convex hull; and determine the morphology of the outer contour of the printing area based on the multiple convex defects;
[0009] Construct a circle representing the outer contour of the printing area based on the multiple convex defects, and extract the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle.
[0010] In an embodiment of the present application, preprocessing the contact lens image to obtain a preprocessed image includes:
[0011] Load the contact lens image;
[0012] Perform color space transformation on the loaded contact lens image to obtain a preprocessed image in the target color space.
[0013] In one embodiment of the present application, the outer contour of the printing area is located based on the morphology of the preprocessed image, including:
[0014] Perform Gaussian filtering on the preprocessed image to obtain a filtered image;
[0015] Perform grayscale conversion on the filtered image to obtain a grayscale image;
[0016] Perform adaptive binarization on the grayscale image to obtain a binary image;
[0017] Perform morphological processing on the binary image to obtain an intermediate image, where the intermediate image includes all contour features of the printing area;
[0018] Based on a pre-constructed area screening range, screen the area of each contour feature in the intermediate image to obtain a target contour that meets the area screening range, where the target contour is the outer contour of the printing area.
[0019] In one embodiment of the present application, determining a plurality of convex defects in the printing area of the contact lens image based on the outer contour of the printing area and the convex hull includes:
[0020] Find the difference between the outer contour of the printing area and the convex hull to obtain convex defects.
[0021] In one embodiment of the present application, determining the morphology of the outer contour of the printing area based on a plurality of convex defects includes:
[0022] Extract the end point and the farthest point of each convex defect to obtain a set of convex defect points, where the farthest point is the point on the outer contour of the printing area and the farthest from the convex hull in each convex defect;
[0023] Perform elliptical fitting on all convex defect points in the set of convex defect points to obtain a fitted circle and the center of the fitted circle;
[0024] Calculate the distance between all convex defect points in the set of convex defect points and the center of the fitted circle, calculate the sum of all distances, and when the sum of all distances is less than a preset first distance threshold, determine that the morphology of the outer contour of the printing area is circular, otherwise, determine that the morphology of the outer contour of the printing area is not circular.
[0025] In one embodiment of the present application, constructing a circle representing the outer contour of the printing area based on a plurality of convex defects includes:
[0026] Calculate the distance between all convex defect points in the set of convex defect points and the center of the fitted circle, and remove convex defect points with distances greater than a preset second distance threshold to obtain a filtered set of convex defect points;
[0027] Fit all the convex defect points in the filtered convex defect point set to obtain a circle representing the outer contour of the printing area.
[0028] In an embodiment of the present application, extracting stains in the printing area of the contact lens image based on a pre-constructed mask and the circle includes:
[0029] Construct a mask based on the circle, and perform a bitwise AND operation on the mask and the binary image to obtain a candidate stain contour;
[0030] Calculate the areas of all candidate stain contours, and screen all candidate stain contours based on a preset minimum detection area, so as to use the candidate stain contours with areas larger than the minimum detection area as stain contours;
[0031] Draw the stain contours in the contact lens image to obtain the stains in the printing area of the contact lens image.
[0032] The present application also provides a high-precision detection system for stains in the printing area of a contact lens based on convex defects, including:
[0033] A preprocessing module for obtaining a contact lens image and preprocessing the contact lens image to obtain a preprocessed image;
[0034] A printing area edge positioning module for positioning the edge based on morphology of the preprocessed image to obtain the outer contour of the printing area;
[0035] An outer ring morphology judgment module for calculating the convex hull of the outer contour of the printing area, determining multiple convex defects in the printing area of the contact lens image based on the outer contour of the printing area and the convex hull; and determining the morphology of the outer contour of the printing area based on the multiple convex defects;
[0036] An outer ring stain detection module for constructing a circle representing the outer contour of the printing area based on multiple convex defects, and extracting stains in the printing area of the contact lens image based on a pre-constructed mask and the circle.
[0037] The present application also provides an electronic device, including: a processor and a memory;
[0038] 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 the method described above.
[0039] The present application also provides a computer-readable storage medium, on which a computer program is stored, characterized in that: when the computer program is executed by a processor, the method described above is implemented.
[0040] The beneficial effects of the present invention are as follows: A high-precision detection method and system for stains in the printing area of contact lenses based on convex defects of the present invention obtain a contact lens image, preprocess the contact lens image to obtain a preprocessed image; locate the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area; calculate the convex hull of the outer contour of the printing area, and determine multiple convex defects in the printing area of the contact lens image based on the outer contour and convex hull of the printing area; and determine the morphology of the outer contour of the printing area based on the multiple convex defects; construct a circle representing the outer contour of the printing area based on the multiple convex defects, and extract the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle. The present invention automatically recognizes the image, can quickly and efficiently complete the comprehensive detection of contact lenses, so as to achieve the purpose of reducing costs and increasing efficiency, improving production efficiency, and improving the production yield rate. Description of the Drawings
[0041] The present invention will be further described below in conjunction with the drawings and embodiments:
[0042] Figure 1 It is an ideal schematic diagram of a contact lens mold shown in an embodiment of the present application;
[0043] Figure 2 It is a schematic diagram of stains on a contact lens mold shown in an embodiment of the present application;
[0044] Figure 3 It is a flowchart of a high-precision detection method for stains in the printing area of contact lenses based on convex defects shown in an embodiment of the present application;
[0045] Figure 4 It is a schematic diagram of the preprocessing process shown in an embodiment of the present application;
[0046] Figure 5 It is a schematic diagram of the process for locating the edge of the printing area shown in an embodiment of the present application;
[0047] Figure 6 It is a schematic diagram of the process for judging the outer circle morphology shown in an embodiment of the present application;
[0048] Figure 7 It is a schematic diagram of the process for detecting stains on the outer circle shown in an embodiment of the present application;
[0049] Figure 8 It is a structural diagram of a high-precision detection system for stains in the printing area of contact lenses based on convex defects shown in an embodiment of the present application. Detailed Embodiments
[0050] The following describes the implementation manners of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific implementation manners. 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.
[0051] It should be noted that the diagrams provided in the following embodiments only schematically illustrate the basic concept of the present invention. 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 proportion of each layer in actual implementation can be arbitrarily changed, and the layer layout type may also be more complex.
[0052] 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.
[0053] Figure 1 It is an ideal schematic diagram of a contact lens mold shown in an embodiment of the present application. As Figure 1 shown, in the image, the area outside the mold is the background area, presented as black. The mold area is the circle drawn by the mold edge in the figure, that is, within the white area. The green area within the mold area represents the printing area. The inner and outer edges of the printing area are represented by dotted lines, and these dotted lines are actually the maximum inscribed circle and the minimum circumscribed circle fitted according to the position of the ink.
[0054] Figure 2 It is a schematic diagram of stains on a contact lens mold shown in an embodiment of the present application. As Figure 2 shown, in actual production, there may be stains near the outer edge of the printing area of the contact lens mold. When performing the minimum circumscribed circle fitting, the stains may be regarded as ink, interfering with the fitting of the outer edge of the printing area and being undetected.
[0055] To solve the above problems, the present application adopts a high-precision detection method for stains in the printing area of contact lenses based on convex defects. Before executing the above method, pre-configuration is required, including reading a configuration file, which mainly contains the parameters required by the algorithm. These include the minimum threshold of the mold area MouldAreaLowerLimit, the maximum threshold of the mold area MouldAreaUpperLimit, the minimum threshold of the outer area of the printing area PrintZoneAreaLowerLimit, the maximum threshold of the outer area of the printing area PrintZoneAreaUpperLimit, etc.
[0056] Figure 3 is a flowchart of a high-precision detection method for stains in the printing area of contact lenses based on convex defects shown in an embodiment of the present application. As Figure 3 shown, a high-precision detection method for stains in the printing area of contact lenses based on convex defects in this embodiment may include the steps:
[0057] S310, obtain a contact lens image and preprocess the contact lens image to obtain a preprocessed image;
[0058] The purpose of step S310 is to read the parameters required by the algorithm under the current light field, and load, color space conversion of the contact lens mold image collected by the high-resolution camera, and convert the initial image format collected by the camera into the image format required by the algorithm. Figure 4 is a schematic diagram of the preprocessing process in an embodiment of the present application. As Figure 4 shown, the preprocessing process specifically includes:
[0059] S311, load the contact lens image; including loading, decoding, and reading camera image data.
[0060] S312, perform color space transformation on the loaded contact lens image to obtain a preprocessed image in the target color space. The purpose is to convert the Bayer format image obtained from the camera into the BGR format.
[0061] S320, perform edge localization based on morphology on the preprocessed image to obtain the outer contour of the printing area;
[0062] After obtaining the colored preprocessed image, the outer contour of the printing area is located through steps such as filtering, color space conversion, adaptive binarization, and morphological processing. Figure 5 is a schematic diagram of the process for edge localization of the printing area in an embodiment of the present application. As Figure 5 shown, the specific process of the edge localization process of the printing area includes:
[0063] S321, perform Gaussian filtering on the preprocessed image to obtain a filtered image; performing Gaussian filtering on the input preprocessed image image can reduce noise interference.
[0064] S322, perform grayscale conversion on the filtered image to obtain a grayscale image gray_image;
[0065] S323, perform adaptive binarization on the grayscale image to obtain a binary image; the binary image contains ink and stains.
[0066] S324. Perform morphological processing on the binary image to obtain an intermediate image, where the intermediate image includes all contour features of the printed area;
[0067] The morphological processing includes multiple closing and opening operations to remove noise while connecting all inks to form a nearly circular printed area. At the same time, the contour of the printed area will also be closed to form complete contour features;
[0068] S325. Screen the area of each contour feature in the intermediate image based on a pre-constructed area screening range to obtain a target contour that meets the area screening range, where the target contour is the outer contour of the printed area.
[0069] First, perform contour search to screen out the contour "contour" in the image after morphological processing. Locate the outer circle of the printed area according to the preset contour area, that is, the outer circle of the printed area "PrintOuterContour" must satisfy that its area "area" is within the range of the minimum threshold "PrintZoneAreaLowerLimit" and the maximum threshold "PrintZoneAreaUpperLimit" of the printed area.
[0070] The expression for the screening process is:
[0071]
[0072] S330. Calculate the convex hull of the outer contour of the printed area, determine multiple convexity defects of the printed area of the contact lens image based on the outer contour of the printed area and the convex hull; and determine the shape of the outer contour of the printed area based on multiple convexity defects;
[0073] The purpose of step S330 is to calculate the convex hull and convexity defects based on the outer contour of the printed area, then traverse the convexity defect information to obtain the end point of each convexity defect and the point on the contour farthest from the convex hull, that is, the convexity defect point set. Then fit a circle based on this convexity defect point set. Finally, judge whether the pattern shape of the printed area is nearly circular according to the distance sum of the convexity defect point set to the center of the fitted circle. Figure 6 This is a schematic flowchart of the outer circle shape judgment in an embodiment of the present application. As Figure 6 shown, the specific process of the outer circle shape judgment process includes:
[0074] S331. Calculate the convex hull. First, perform convex hull calculation on the target contour. The convex hull is the smallest convex polygon that can contain all points of the target contour;
[0075] S332. Perform a difference operation on the outer contour of the printing area and the convex hull to obtain convex defects. Based on the obtained convex hull, calculate the difference between the contour and the convex hull, that is, convex defects. These defects may be caused by uneven ink distribution, stains, or other surface irregularities.
[0076] S333. Traverse the calculated convex defect information, extract the end points and the farthest points of each convex defect to obtain a set of convex defect points. Among them, the farthest point is the point on the outer contour of the printing area and the farthest from the convex hull in each convex defect, that is, the set of convex defect points {(x1, y1), (x2, y2), …, (x i , y i )};
[0077] S334. Fit a circle. Perform an ellipse fitting on all the convex defect points in the set of convex defect points to obtain a fitted circle and the center (x0, y0) of the fitted circle;
[0078] S335. Calculate the distance. Calculate the distances between all the convex defect points in the set of convex defect points and the center of the fitted circle, and calculate the sum of all the distances. That is, by traversing the end points at all defect locations and the points on the contour that are farthest from the convex hull and calculating their distances to the center (x0, y0) of the fitted circle, that is
[0079] S336. Judge the shape. When the sum of all the distances is less than a preset first distance threshold, determine that the shape of the outer contour of the printing area is circular; otherwise, determine that the shape of the outer contour of the printing area is not circular. The first distance threshold is var, and its judgment expression is:
[0080]
[0081] S340. Construct a circle representing the outer contour of the printing area based on multiple convex defects, and extract the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle.
[0082] In step S340, first, it is necessary to screen the set of convex defect points. If the distance from the points in the set to their fitted circle is greater than the preset threshold, they will be removed from the set of convex defect points. Then, generate a mask image that shields the ink in the printing area based on the screened set of points. Perform a logical AND operation on the obtained binary image of the contact lens mold and the mask image to obtain a binary image outside the printing area. Finally, detect the stains outside the printing area through contour search and stain screening. Figure 7 This is a schematic flowchart of the outer ring stain detection in an embodiment of the present application. As Figure 7 shown, the outer ring stain detection process specifically includes:
[0083] S341. Calculate the distances between all the convex defect points in the set of convex defect points and the center of the fitted circle, and remove the convex defect points with distances greater than a preset second distance threshold to obtain a filtered set of convex defect points.
[0084] Specifically, it is necessary to traverse the set of convex defect points \(\{(x1,y1),(x2,y2),…,(x i ,y i )\}, then calculate the distance between it and the center \((x0,y0)\) of the fitted circle. If the distance is greater than the preset threshold, remove it from the set of convex defect points.
[0085] S342. Fit all the convex defect points in the filtered set of convex defect points to obtain a circle representing the outer contour of the printing area. The filtered set of convex defect points can fit the circle with the most matching shape.
[0086] S343. Construct a mask based on the circle, and perform a bitwise AND operation on the mask and the binary image to obtain a candidate stain contour.
[0087] First, generate a mask. When generating the mask, first generate a mask image with all 255 pixels of the same size as the input image, and then draw a circle based on the circle obtained in D12 and fill it with a 0 gray value to obtain the mask.
[0088] After obtaining the mask, perform a bitwise AND operation on the binary image obtained in step S323 and the mask to obtain an AND operation image containing the candidate stain contour.
[0089] S344. Calculate the areas of all the candidate stain contours, and screen all the candidate stain contours based on a preset minimum detection area, so as to use the candidate stain contours with areas greater than the minimum detection area as the stain contours.
[0090] Specifically, when the contour area is greater than the minimum detection area SmudgeArea, determine that the current contour is a stain.
[0091] S345. Draw the stain contour in the contact lens image to obtain the stain in the printing area of the contact lens image.
[0092] A high-precision detection method for stains in the printing area of contact lenses based on convex defects of the present invention includes obtaining a contact lens image, preprocessing the contact lens image to obtain a preprocessed image, locating the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area, calculating the convex hull of the outer contour of the printing area, determining multiple convex defects in the printing area of the contact lens image based on the outer contour of the printing area and the convex hull, determining the morphology of the outer contour of the printing area based on the multiple convex defects, constructing a circle representing the outer contour of the printing area based on the multiple convex defects, and extracting the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle. The present invention automatically recognizes the image, can quickly and efficiently complete the comprehensive detection of contact lenses, so as to achieve the purpose of reducing costs and increasing efficiency, improving production efficiency, and improving the production yield rate.
[0093] As Figure 8 shown, the present application also provides a high-precision detection system for stains in the printing area of contact lenses based on convex defects, including:
[0094] A preprocessing module for obtaining a contact lens image and preprocessing the contact lens image to obtain a preprocessed image;
[0095] A printing area edge positioning module for locating the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area;
[0096] An outer circle morphology judgment module for calculating the convex hull of the outer contour of the printing area, determining multiple convex defects in the printing area of the contact lens image based on the outer contour of the printing area and the convex hull, and determining the morphology of the outer contour of the printing area based on the multiple convex defects;
[0097] An outer circle stain detection module for constructing a circle representing the outer contour of the printing area based on the multiple convex defects and extracting the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle.
[0098] A high-precision detection system for stains in the printing area of contact lenses based on convex defects of the present invention includes obtaining a contact lens image, preprocessing the contact lens image to obtain a preprocessed image, locating the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area, calculating the convex hull of the outer contour of the printing area, determining multiple convex defects in the printing area of the contact lens image based on the outer contour of the printing area and the convex hull, determining the morphology of the outer contour of the printing area based on the multiple convex defects, constructing a circle representing the outer contour of the printing area based on the multiple convex defects, and extracting the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle. The present invention automatically recognizes the image, can quickly and efficiently complete the comprehensive detection of contact lenses, so as to achieve the purpose of reducing costs and increasing efficiency, improving production efficiency, and improving the production yield rate.
[0099] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0100] 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.
[0101] 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 the 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 disc that can store program codes.
[0102] 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.
[0103] In this embodiment, the memory may include a random access memory (Random Access Memory, abbreviated as RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0104] The above-mentioned processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, abbreviated as CPU), a network processor (Network Processor, abbreviated as NP), etc.; it may also be a digital signal processor (Digital Signal Processing, abbreviated as DSP), an application specific integrated circuit (Application Specific Integrated Circuit, abbreviated as ASIC), a field programmable gate array (Field-Programmable Gate Array, abbreviated as FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0105] In the above embodiments, although the present invention has been described in conjunction with specific embodiments of the present invention, many alternatives, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. Embodiments of the present invention are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims.
[0106] 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 of ordinary skill in the art in the technical field without departing from the spirit and technical idea disclosed by the present invention should still be covered by the claims of the present invention.
Claims
1. A high-precision detection method for stains in the printing area of contact lenses based on convex defects, characterized in that Including the steps: Obtain a contact lens image, and preprocess the contact lens image to obtain a preprocessed image; Locate the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area; Calculate the convex hull of the outer contour of the printing area, determine multiple convex defects of the printing area of the contact lens image based on the outer contour of the printing area and the convex hull; and determine the morphology of the outer contour of the printing area based on the multiple convex defects; Construct a circle representing the outer contour of the printing area based on the multiple convex defects, and extract the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle.
2. The high-precision detection method for stains in the printing area of a contact lens based on convex defects according to claim 1, wherein Preprocess the contact lens image to obtain a preprocessed image, including: Load the contact lens image; Perform color space transformation on the loaded contact lens image to obtain a preprocessed image in the target color space.
3. The high-precision detection method for stains in the printing area of a contact lens based on convex defects according to claim 1, wherein, Locate the edge based on morphology for the preprocessed image to obtain the outer contour of the printing area, including: Perform Gaussian filtering on the preprocessed image to obtain a filtered image; Perform grayscale conversion on the filtered image to obtain a grayscale image; Perform adaptive binarization on the grayscale image to obtain a binary image; Perform morphological processing on the binary image to obtain an intermediate image, where the intermediate image includes all contour features of the printing area; Screen the area of each contour feature in the intermediate image based on a pre-constructed area screening range to obtain a target contour that meets the area screening range, where the target contour is the outer contour of the printing area.
4. A high-precision detection method for stains in the printing area of contact lenses based on convex defects according to claim 1, characterized in that Determine multiple convex defects of the printing area of the contact lens image based on the outer contour of the printing area and the convex hull, including: Find the difference between the outer contour of the printing area and the convex hull to obtain convex defects.
5. A high-precision detection method for stains in the printing area of contact lenses based on convex defects according to claim 1, characterized in that Determine the morphology of the outer contour of the printing area based on the multiple convex defects, including: Extract the end point and the farthest point of each convex defect to obtain a set of convex defect points, where the farthest point is the point on the outer contour of the printing area and farthest from the convex hull in each convex defect; Perform ellipse fitting on all convex defect points in the set of convex defect points to obtain a fitted circle and the center of the fitted circle; Calculate the distances between all convex defect points in the set of convex defect points and the center of the fitted circle, calculate the sum of all distances, and when the sum of all distances is less than a preset first distance threshold, determine that the morphology of the outer contour of the printing area is circular, otherwise, determine that the morphology of the outer contour of the printing area is not circular.
6. A high-precision detection method for stains in the printing area of contact lenses based on convex defects according to claim 1, characterized in that, Construct a circle representing the outer contour of the printing area based on the multiple convex defects, including: Calculate the distances between all convex defect points in the set of convex defect points and the center of the fitted circle, and remove convex defect points with distances greater than a preset second distance threshold to obtain a screened set of convex defect points; Perform fitting on all convex defect points in the screened set of convex defect points to obtain a circle representing the outer contour of the printing area.
7. A high-precision detection method for stains in the printing area of contact lenses based on convex defects according to claim 3, characterized in that Extract the stains in the printing area of the contact lens image based on a pre-constructed mask and the circle, including: Construct a mask based on the circle, and perform a bitwise AND operation on the mask and the binary image to obtain a candidate stain contour; Calculate the areas of all candidate stain contours, and screen all the candidate stain contours based on a preset minimum detection area, so as to use the candidate stain contours with areas larger than the minimum detection area as stain contours; Draw the stain contours in the contact lens image to obtain the stains in the printed area of the contact lens image.
8. A high-precision detection system for stains in the printing area of contact lenses based on convex defects, characterized in that, Comprising: A preprocessing module, configured to obtain a contact lens image and preprocess the contact lens image to obtain a preprocessed image; A printed area edge positioning module, configured to perform edge positioning based on morphology on the preprocessed image to obtain an outer contour of the printed area; An outer contour morphology determination module, configured to calculate the convex hull of the outer contour of the printed area, determine multiple convex defects in the printed area of the contact lens image based on the outer contour of the printed area and the convex hull; and determine the morphology of the outer contour of the printed area based on the multiple convex defects; An outer stain detection module, configured to construct a circle representing the outer contour of the printed area based on the multiple convex defects, and extract the stains in the printed area of the contact lens image based on a pre-constructed mask and the circle.
9. An electronic device, comprising: A processor and a memory; 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 the method according to claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, the method according to claims 1-7 is implemented.
Citation Information
Patent Citations
Printed circuit board defect identification method
CN115311262A
Lithium battery weld defect detection method and system and storage medium
CN116309576A
Method and system for separation and contour reconstruction of overlapped particulate matters
CN116977476A
Method and system for detecting flaws of printed contact lenses based on cloud-machine vision
CN118505634A
Rotary contact lens color mold transfer printing method and system
CN119682380A