A contact lens casting mold printing defect detection method and system
By aligning the center of mass and transforming the color image of the contact lens casting mold, an image adapted to the printed defect detection model is generated, and a deep neural network is used for automatic detection, which solves the problem of ink leakage defect detection efficiency during the contact lens casting mold printing process. Efficient and accurate defect detection is achieved.
Patent Information
- Application Number
- CN202410052836.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-15
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-01-15
AI Technical Summary
There are defective products in the printing process of existing contact lens casting molds, and relying on manual inspection results in inefficiency and erroneous judgments. Ink-lost or misprint detection methods require a template to be established for comparison, and the detection efficiency is low.
By obtaining color images of multiple contact lens casting molds at different light source heights, performing centroid alignment and coordinate transformation, generating images that are adapted to printed defect detection models, using deep neural networks and other models for defect detection, and automatically identify defects.
It reduces labor costs, saves time, improves production yield, and improves the accuracy and efficiency of defect detection.
Smart Images

Figure CN117849072B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition technology, and in particular to a method and system for detecting defects in contact lens mold printing. Background Art
[0002] Cosmetic contact lenses are contact lenses that can enhance brightness, enlarge, darken or change the color of the eyes. The pattern printing method of cosmetic contact lenses is mainly based on the pad printing method of the contact lens mold. Since the printing ink is easily affected by the concentration of the ink itself, the ambient temperature and humidity, etc., the mold is prone to ink leakage during the printing process. The printing quality inspection method of related technologies relies on manual inspection. This inspection method has the following shortcomings: (1) Long-term manual inspection causes eye fatigue and is prone to misjudgment; (2) The ink shortage or missing printing detection method in the printing field requires the establishment of a template for the qualified product first, and the ink shortage defect is detected by comparing with the template, and the inspection efficiency is relatively low. Summary of the invention
[0003] In view of the above-mentioned shortcomings of the prior art, the present invention provides a method and system for detecting defects in contact lens mold printing to solve the above-mentioned technical problems.
[0004] The present invention provides a contact lens mold printing defect detection method, which comprises: acquiring a plurality of contact lens mold color images collected at different light source heights; aligning the centroids of the plurality of contact lens mold color images to obtain a contact lens mold fusion image; performing coordinate transformation on the contact lens mold fusion image to obtain a transformed image, so that the transformed image is adapted to a contact lens mold printing defect detection model; and performing defect detection on the transformed image using the contact lens mold printing defect detection model to obtain a defect detection result.
[0005] In one embodiment of the present invention, the process of aligning the centroids of a plurality of the contact lens mold color images to obtain a contact lens mold fusion image includes: converting the plurality of the contact lens mold color images into grayscale images respectively to obtain a plurality of grayscale images, and performing threshold segmentation and filtering on each of the grayscale images respectively to obtain a plurality of contact lens mold binary filtered images; establishing an annular mask image based on each of the contact lens mold binary filtered images to obtain a plurality of the annular mask images, wherein the annular position of the annular mask image corresponds to the edge area of the mold, and the annular position of the annular mask image is filled with a grayscale value within a preset range; and aligning the centroids of the plurality of the contact lens mold color images respectively to obtain a plurality of grayscale images, and performing threshold segmentation and filtering on each of the grayscale images respectively to obtain a plurality of contact lens mold binary filtered images; and establishing an annular mask image based on each of the contact lens mold binary filtered images to obtain a plurality of the annular mask images, wherein the annular position of the annular mask image corresponds to the edge area of the mold, and the annular position of the annular mask image is filled with a grayscale value within a preset range; and The contact lens mold binary filtered image is ANDed with the corresponding annular mask image to obtain a plurality of mold edge area images; the contour image in each of the mold edge area images is extracted, and the area size of the contour image in each of the mold edge area images is screened to obtain the screened contour image; the centroid of the corresponding mold edge area image is determined according to the moment characteristics of each of the screened contour images, and the plurality of contact lens mold color images are aligned according to the centroid of the corresponding mold edge area image to obtain a contact lens mold fusion image, and the centroids of the plurality of mold edge area images have a one-to-one correspondence with the plurality of contact lens mold color images.
[0006] In one embodiment of the present invention, the process of performing coordinate transformation on the contact lens mold fusion image to obtain a transformed image includes: transforming the contact lens mold fusion image in the polar coordinate transformation manner to obtain a rectangular image; and performing size transformation on the rectangular image to obtain a transformed image so that the transformed image adapts to the contact lens mold printing defect detection model.
[0007] In one embodiment of the present invention, defect detection is performed on the transformed image through the contact lens mold printing defect detection model, and the process of obtaining the defect detection result includes: inputting the transformed image into the contact lens mold printing defect detection model; if the contact lens mold printing defect detection model detects that there are defects in the transformed image, drawing the defect position in the transformed image to obtain a defect detection output image, and transforming the defect detection output image to obtain the defect detection result; if the contact lens mold printing defect detection model does not detect the existence of defects in the transformed image, then the current product is qualified as the defect detection result.
[0008] In one embodiment of the present invention, the process of screening the area size of the contour image in each of the mold edge area images includes: obtaining a preset contact lens mold area range; sorting the contour images in all the mold edge area images according to the area size, and selecting a preset number of contour images from the sorting results;
[0009] The preset number of contour images are compared with the preset contact lens casting mold area range, and the contour images that meet the preset contact lens casting mold area range are used as the screened contour images.
[0010] In one embodiment of the present invention, the process of aligning a plurality of the color images of the contact lens mold according to the centroids of the corresponding mold edge region images to obtain a contact lens mold fusion image includes: selecting a mold edge region image from the plurality of the mold edge region images as a reference image, and using the centroid of the reference image as a reference centroid; calculating the offset between the centroid of the mold edge region image and the reference centroid respectively to obtain the offset of the mold edge region image relative to the reference image; and resizing each of the mold edge region images based on the offset. Expand, and according to the expanded size, establish a three-channel full-zero mask image, and fill each of the contact lens mold color images into the corresponding three-channel full-zero mask image to obtain multiple filled mask images, and the three channels correspond to three color dimensions; align the centroids of all the filled mask images with the reference centroid to obtain an aligned image, and the pixel value at each position in the aligned image is an overlapping pixel value; calculate the mean of the overlapping pixel values at each position in the aligned image, and replace the overlapping pixel value at the corresponding position with the mean of the overlapping pixel values at each position to obtain the contact lens mold fusion image.
[0011] In one embodiment of the present invention, the process of transforming the contact lens mold fusion image by the polar coordinate transformation to obtain a rectangular image includes: obtaining the center coordinates and radius of the contact lens mold fusion image; calculating the edge circumference of the contact lens mold fusion image based on the center coordinates and radius; expanding the contact lens mold fusion image with the center of the circle by the polar coordinate transformation to obtain a rectangular image, wherein the height of the rectangular image is the edge circumference and the width is the radius.
[0012] In one embodiment of the present invention, the process of resizing the rectangular image to obtain the transformed image includes: performing a first rotation operation on the rectangular image to obtain a contact lens mold rotation image, wherein the width of the contact lens mold rotation image is the edge circumference and the height is the radius; cropping the contact lens mold rotation image according to a preset cropping ratio to obtain a contact lens mold cropped image; segmenting the contact lens mold cropped image according to a preset segmentation number to obtain multiple contact lens mold segmented images, and recording a first positional relationship between the multiple contact lens mold segmented images and the rectangular image; dividing the edge area in the contact lens mold segmented image, adding an overlapping area to the edge area, and splicing the overlapping area with the edge area to obtain a contact lens mold supplementary image, wherein the overlapping area has the same size as the edge area, and the overlapping area and the edge area are adjacent in position in the contact lens mold fusion image; stacking the contact lens mold supplementary images to obtain the transformed image, and recording a second positional relationship between the contact lens mold supplementary image and the transformed image.
[0013] In one embodiment of the present invention, the defect detection output image is transformed to obtain the defect detection result. The process includes: dividing a defect detection supplementary image from the defect detection output image according to the second positional relationship, performing an AND operation on the edge area pixel values of the defect detection supplementary image and the corresponding overlapping area pixel values to obtain the pixel values after the operation, and replacing the edge area pixel values of the defect detection supplementary image with the pixel values after the operation to obtain a defect detection segmented image, wherein the defect detection supplementary image has a corresponding relationship with the contact lens mold supplementary image; replacing the pixels in a pre-generated all-zero mask image with the defect detection segmented image according to the first positional relationship to obtain a rectangular mask image, wherein the size of the all-zero mask image is the same as that of the rectangular image; performing a second rotation operation and a polar coordinate inverse transformation operation on the rectangular mask image to obtain a circular mask image, wherein the size of the circular mask image is the same as that of the contact lens mold fusion image; performing contour extraction on the circular mask image to obtain a mask image contour image, and using the mask image contour image as the defect detection result.
[0014] According to one aspect of an embodiment of the present invention, a contact lens mold printing defect detection system is provided, the system comprising: an image acquisition module, used to acquire multiple contact lens mold color images collected at different light source heights; an image fusion module, used to align the centroids of the multiple contact lens mold color images to obtain a contact lens mold fusion image; an image transformation module, used to perform coordinate transformation on the contact lens mold fusion image to obtain a transformed image, so that the transformed image can adapt to a contact lens mold printing defect detection model; a defect detection module, used to perform defect detection on the transformed image through the contact lens mold printing defect detection model to obtain a defect detection result.
[0015] Beneficial effects of the present invention: The present invention obtains multiple color images of contact lens molds collected at different light source heights, aligns the centroids of the multiple color images of contact lens molds to obtain a contact lens mold fusion image, performs coordinate transformation on the contact lens mold fusion image to obtain a transformed image, so that the transformed image is adapted to a contact lens mold printing defect detection model, and performs defect detection on the transformed image through the contact lens mold printing defect detection model to obtain a defect detection result, which has the technical effects of reducing labor costs, saving time, and improving production yield.
[0016] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0018] Figure 1 is a schematic diagram of a contact lens casting mold image shown in an exemplary embodiment of the present application;
[0019] Figure 2 is a flow chart of a contact lens casting mold printing defect detection method shown in an exemplary embodiment of the present application;
[0020] Figure 3 is a schematic diagram of centroid alignment of multiple contact lens casting color images shown in an exemplary embodiment of the present application;
[0021] Figure 4 is a schematic diagram of a rotating image of a contact lens casting mold shown in an exemplary embodiment of the present application;
[0022] Figure 5 is a schematic diagram of a cutout image of a contact lens casting mold shown in an exemplary embodiment of the present application;
[0023] Figure 6 is a schematic diagram of a contact lens casting mold segmentation image shown in an exemplary embodiment of the present application;
[0024] Figure 7 is a schematic diagram of a transformed image shown in an exemplary embodiment of the present application;
[0025] Figure 8 is a schematic diagram of a defect detection result shown in an exemplary embodiment of the present application;
[0026] Fig. 9 It is a block diagram of a contact lens casting mold printing defect detection system shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0027] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. 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 understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.
[0028] 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 components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0029] In the following description, numerous details are discussed 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. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0030] Figure 1 FIG. 1 is a schematic diagram of a contact lens casting mold image shown in an exemplary embodiment of the present application. Figure 1 As shown, the contact lens mold image includes a pupil area and a printing area, wherein the printing area is a defect detection area, the white area between the outer edge of the printing area and the edge of the mold is not printed with ink and is not detected, and the black area is the background area.
[0031] The implementation details of the technical solution of the embodiment of the present application are described in detail below:
[0032] Figure 2 is a flowchart of a contact lens casting printing defect detection method shown in an exemplary embodiment of the present application, referring to Figure 2 As shown, the contact lens casting mold printing defect detection method at least includes steps S210 to S240, which are described in detail as follows:
[0033] Step S210, obtaining a plurality of contact lens mold color images collected at different light source heights.
[0034] In one embodiment of the present application, when the contact lens mold is placed on the inspection station for inspection, the light source will move quickly from low to high multiple times, and the light source will stay for a short time after each movement. At this time, a camera is used to take pictures to obtain multiple color images of the contact lens mold at different light source heights.
[0035] Step S220, aligning the centroids of the plurality of contact lens mold color images to obtain a contact lens mold fusion image.
[0036] In this embodiment, since mechanical vibration is unavoidable when the camera takes images, the pixels at each position of multiple images at different light source heights are usually not one-to-one corresponding, and directly fusing the images will produce a problem of blurred patterns. However, after the centroids of multiple contact lens mold color images are aligned and then fused, the problem of blurred patterns in the fused image can be reduced, and the lighting in the printing area can be uniform, thereby improving the quality of the fused image of the contact lens mold.
[0037] Step S230, coordinate transformation is performed on the contact lens mold fusion image to obtain a transformed image, so that the transformed image is adapted to the contact lens mold printing defect detection model.
[0038] In this embodiment, since the printing area of the contact lens mold is usually annular, when using the contact lens mold printing defect detection model to perform defect detection on the edge of the annular printing area, there is a problem that arc defects are difficult to accurately mark, resulting in poor defect detection results and low accuracy. By performing coordinate transformation on the contact lens mold fusion image, background interference is reduced and the resolution of the contact lens mold fusion image is improved, thereby greatly improving the defect detection accuracy.
[0039] In step S240, defect detection is performed on the transformed image by printing a defect detection model of the contact lens mold to obtain a defect detection result.
[0040] In this embodiment, the contact lens mold printing defect detection model can be a deep neural network detection model, etc., which is not limited here.
[0041] In this embodiment, by acquiring multiple color images of contact lens molds collected at different light source heights, the multiple color images of contact lens molds are aligned to obtain a contact lens mold fusion image, and the coordinates of the contact lens mold fusion image are transformed to obtain a transformed image, so that the transformed image is adapted to a contact lens mold printing defect detection model, and defect detection is performed on the transformed image through the contact lens mold printing defect detection model to obtain a defect detection result, which has the technical effect of reducing labor costs, saving time, and improving production yield.
[0042] In one embodiment of the present application, the process of aligning the centroids of multiple contact lens mold color images to obtain a contact lens mold fusion image includes: converting the multiple contact lens mold color images into grayscale images respectively to obtain multiple grayscale images, and performing threshold segmentation and filtering on each grayscale image respectively to obtain multiple contact lens mold binary filtered images.
[0043] In this embodiment, the process of converting multiple contact lens mold color images into grayscale images includes: performing noise reduction, color space conversion and other operations on the multiple contact lens mold color images to obtain multiple contact lens mold grayscale images.
[0044] In this embodiment, each grayscale image is threshold segmented and filtered to obtain a plurality of contact lens mold binary filtered images, including: (1) each contact lens mold grayscale image is adaptively threshold segmented to obtain a plurality of contact lens mold binary images; (2) the plurality of contact lens mold binary images are filtered to obtain a plurality of contact lens mold binary filtered images.
[0045] Based on each contact lens mold binary filtering image, an annular mask image is established to obtain multiple annular mask images, the annular positions of the annular mask images correspond to the edge areas of the mold, and the annular positions of the annular mask images are filled with gray values within a preset range.
[0046] In this embodiment, the process of establishing an annular mask image based on each binary filter image of the contact lens mold includes: (1) generating an all-zero mask image with the same width and height as the binary filter image of the contact lens mold; (2) taking the centroid of each image as the center of the circle, drawing a circle on the all-zero mask image with a first preset multiple of the radius of each image, and filling it with a first preset gray value; (3) taking the centroid of each image as the center of the circle, drawing a circle on the all-zero mask image with a second preset multiple of the radius of each image, and filling it with a second gray value, to obtain an annular mask image corresponding to the binary filter image of the contact lens mold.
[0047] In this embodiment, the first preset multiple can be 1.1 or other values, the second preset multiple can be 0.9 or other values, the first preset grayscale value can be 255 or other grayscale values, the second preset grayscale value can be 0 or other grayscale values. The grayscale value within the preset range can be set according to actual conditions and is not limited here.
[0048] Each contact lens mold binary filter image is ANDed with the corresponding annular mask image to obtain multiple mold edge area images.
[0049] In this embodiment, each contact lens mold binary filter image is ANDed with the corresponding annular mask image, which can effectively remove the interference of the printed area and the information outside the mold, and is conducive to improving the extraction speed of the mold edge contour.
[0050] The contour image in each mold edge region image is extracted, and the area size of the contour image in each mold edge region image is screened to obtain a screened contour image.
[0051] In this embodiment, the area size of the contour image in each mold edge area image is screened to obtain the screened contour image, which includes: (1) obtaining a preset contact lens mold area range; (2) sorting the contour images in all mold edge area images according to the area size, and selecting a preset number of contour images from the sorting results; (3) comparing the preset number of contour images with the preset contact lens mold area range, and using the contour images that meet the preset contact lens mold area range as the screened contour images.
[0052] According to the moment features of each filtered contour image, the centroid of the corresponding mold edge area image is determined, and multiple contact lens mold color images are aligned according to the centroid of the corresponding mold edge area image to obtain a contact lens mold fusion image. The centroids of the multiple mold edge area images have a one-to-one correspondence with the multiple contact lens mold color images.
[0053] In this embodiment, the method of determining the centroid of the image of the edge region of the mold according to the moment feature of each filtered contour image is a prior art and will not be described in detail herein.
[0054] In this embodiment, a plurality of contact lens mold color images are aligned according to the centroids of the corresponding mold edge area images and then fused, which can reduce the problem of blurred patterns in the fused image and improve the quality of the contact lens mold fused image.
[0055] In one embodiment of the present application, the process of performing coordinate transformation on the contact lens mold fusion image to obtain the transformed image includes: transforming the contact lens mold fusion image in a polar coordinate transformation manner to obtain a rectangular image.
[0056] In this embodiment, the process of transforming the contact lens mold fusion image by polar coordinate transformation to obtain a rectangular image includes: (1) obtaining the center coordinates and radius of the contact lens mold fusion image; (2) calculating the edge perimeter of the contact lens mold fusion image according to the center coordinates and radius; (3) expanding the contact lens mold fusion image with the center of the circle by polar coordinate transformation to obtain a rectangular image.
[0057] The rectangular image is resized to obtain a transformed image, so that the transformed image is adapted to the contact lens casting mold printing defect detection model.
[0058] In this embodiment, the process of resizing a rectangular image to obtain a transformed image includes: (1) performing a first rotation operation on the rectangular image to obtain a contact lens mold rotation image, wherein the width of the contact lens mold rotation image is the edge circumference and the height is the radius; (2) cropping the contact lens mold rotation image according to a preset cropping ratio to obtain a contact lens mold cropped image; (3) segmenting the contact lens mold cropped image according to a preset segmentation number to obtain multiple contact lens mold segmented images; (4) dividing the edge area in the contact lens mold segmented image, adding an overlapping area to the edge area, and splicing the overlapping area with the edge area to obtain a contact lens mold supplementary image, wherein the overlapping area has the same size as the edge area, and the overlapping area and the edge area are adjacent in position in the contact lens mold fusion image; and (5) stacking the contact lens mold supplementary images to obtain a transformed image, so that the transformed image adapts to the image input size of the contact lens mold printing defect detection model.
[0059] In one embodiment of the present application, defect detection is performed on the transformed image using a contact lens mold printing defect detection model, and a process of obtaining a defect detection result includes: inputting the transformed image into the contact lens mold printing defect detection model.
[0060] In this embodiment, the contact lens mold printing defect detection model can be a deep neural network detection model, etc., which is not limited here.
[0061] If the contact lens casting mold printing defect detection model detects that there are defects in the transformed image, the defect position is drawn in the transformed image to obtain a defect detection output image, and the defect detection output image is transformed to obtain a defect detection result.
[0062] In this embodiment, the number of defects in the transformed image may be one or more, and the defect positions may be drawn in the transformed image by means of box marking or other marking methods.
[0063] If the contact lens casting mold printing defect detection model does not detect the existence of defects in the transformed image, the current product is considered qualified as the defect detection result.
[0064] In this embodiment, the transformed image is automatically identified by the contact lens mold printing defect detection model, and it is possible to determine whether the photographed product has defects without comparing it with a pre-established template, which can reduce labor costs, save time, and improve detection efficiency and accuracy.
[0065] In one embodiment of the present application, the process of screening the area size of the contour image in each mold edge area image includes:
[0066] Get the preset contact lens casting area range.
[0067] In this embodiment, the preset contact lens mold area range includes a maximum value of the mold area, a minimum value of the mold area, and the like.
[0068] The contour images in all the mold edge area images are sorted according to their area sizes, and a preset number of contour images are selected from the sorting results.
[0069] In this embodiment, the preset number can be set according to actual conditions and is not limited here.
[0070] In this embodiment, the contour images in all the mold edge area images can be sorted in ascending order or in descending order, wherein the preset number of contour images can be a preset number of contour images that are ranked at the top in the ascending order, or a preset number of contour images that are ranked at the bottom in the descending order.
[0071] A preset number of contour images are compared with a preset contact lens casting area range, and contour images that meet the preset contact lens casting area range are used as screened contour images.
[0072] In this embodiment, the contour images that do not meet the preset contact lens mold area range are screened out to avoid interference from redundant information, which is beneficial to improving the quality of the contact lens mold fusion image.
[0073] In one embodiment of the present application, a plurality of contact lens mold color images are aligned according to the centroids of the corresponding mold edge area images to obtain a contact lens mold fusion image, the process comprising: selecting an image of the mold edge area from the plurality of mold edge area images as a reference image, and using the centroid of the reference image as a reference centroid.
[0074] In this embodiment, the reference image may be the image with the largest area among the multiple images of the edge region of the mold, or may be other images of the edge region of the mold.
[0075] The offset between the centroid of the mold edge region image and the reference centroid is calculated respectively to obtain the offset of the mold edge region image relative to the reference image.
[0076] In this embodiment, the method for calculating the offset between the centroid of the mold edge region image and the reference centroid is a prior art and is not limited here.
[0077] In this embodiment, if the mold edge area image and the reference image are the same image, the offset of the mold edge area image relative to the reference image is zero, and a three-channel all-zero mask image is directly created for the reference image without expanding the size of the reference image.
[0078] Based on the offset, the size of each mold edge area image is expanded, and according to the expanded size, a three-channel all-zero mask image is established, and each contact lens mold color image is filled into the corresponding three-channel all-zero mask image to obtain multiple filled mask images, and the three channels correspond to three color dimensions.
[0079] In this embodiment, based on the offset, the process of expanding the size of each mold edge area image includes: increasing the width of the mold edge area image by the offset, increasing the height of the mold edge area image by the offset, and drawing a three-channel all-zero mask image according to the expanded width and the expanded height. The filling grayscale value of the three-channel all-zero mask image can be zero or other pixel values, and the three color dimensions can be R, G, and B color dimensions or other color dimensions. The three-channel all-zero mask image is suitable for filling color images.
[0080] The centroids of all filled mask images are aligned with the reference centroid to obtain an aligned image, and the pixel value at each position in the aligned image is the overlapping pixel value. The centroid of the filled mask image is the same as the centroid of the mold edge area image.
[0081] In this embodiment, the overlapping pixel value is the sum of the pixel values at corresponding positions in all filled mask images.
[0082] In this embodiment, the centroids of all filled mask images are aligned with the reference centroid, which solves the problem of pattern blurring caused by direct fusion of pixels at different positions of images of edge regions of different molds, which do not correspond.
[0083] The mean value of the overlapping pixel values at each position in the aligned image is calculated, and the overlapping pixel values at the corresponding position are replaced by the mean value of the overlapping pixel values at each position to obtain the contact lens mold fusion image.
[0084] In this embodiment, the contact lens mold fusion image obtained by centroid alignment has the characteristic of uniform illumination in the printing area, and the centroid alignment method has a small amount of calculation, is efficient and accurate, and is suitable for online detection scenarios.
[0085] Figure 3 is a schematic diagram of centroid alignment of multiple contact lens casting color images shown in an exemplary embodiment of the present application, located at Figure 3 The point on the left is the centroid of the image of the edge region of the mold, located at Figure 3 The point on the right is the reference centroid, and the distance between them is the offset, i.e. padding_size. Figure 3 The middle grey border area is a filling area with the same size as the offset. The point on the right is used as the center during alignment, and the image obtained after alignment is cropped to the size of the reference image to obtain the contact lens cast fusion image.
[0086] In one embodiment of the present application, the process of transforming the contact lens mold fusion image in a polar coordinate transformation manner to obtain a rectangular image includes: obtaining the center coordinates and radius of the contact lens mold fusion image.
[0087] In this embodiment, after obtaining the contact lens mold fusion image, the center coordinates and radius of the contact lens mold fusion image can be calculated according to the size and position of the contact lens mold fusion image. Here, the method for calculating the center coordinates and radius of the contact lens mold fusion image is not limited.
[0088] According to the coordinates of the center of the circle and the radius, the edge circumference of the contact lens casting fusion image is calculated.
[0089] In this embodiment, the method of calculating the edge perimeter of the contact lens mold fusion image according to the coordinates of the center of the circle and the radius is a prior art and is not limited here.
[0090] The contact lens mold fusion image is expanded with the center of the circle through polar coordinate transformation to obtain a rectangular image, in which the height of the rectangular image is the edge perimeter and the width is the radius.
[0091] In this embodiment, the contact lens mold fusion image is transformed from a ring-shaped image to a rectangular image by polar coordinate transformation, thereby achieving the effect of changing the shape of the contact lens mold fusion image.
[0092] In one embodiment of the present application, the process of resizing a rectangular image to obtain a transformed image includes: performing a first rotation operation on the rectangular image to obtain a contact lens mold rotation image, wherein the width of the contact lens mold rotation image is the edge circumference and the height is the radius.
[0093] In this embodiment, when the first rotation operation is performed on the rectangular image, the rotation angle may be 90 degrees counterclockwise or 270 degrees clockwise.
[0094] Figure 4 is a schematic diagram of a rotating image of a contact lens casting mold shown in an exemplary embodiment of the present application, such as Figure 4 As shown, the width of the contact lens casting mold rotation image is the edge circumference, the height is the radius, and the gray area of the contact lens casting mold rotation image corresponds to the printing area.
[0095] The contact lens mold rotation image is cropped according to a preset cropping ratio to obtain a contact lens mold cropped image.
[0096] In this embodiment, the preset cropping ratio can be three quarters of the contact lens mold rotating image, or it can be other cropping ratios. For example, after cropping the contact lens mold rotating image according to the preset cropping ratio of three quarters, three quarters of the contact lens mold rotating image (the upper part of the contact lens mold rotating image) is used as the contact lens mold cropped image, and one quarter of the contact lens mold rotating image (the lower part) will be cropped off, thereby reducing the interference of background information and improving the accuracy of contact lens mold defect detection.
[0097] Figure 5 is a schematic diagram of a contact lens casting mold cutting image shown in an exemplary embodiment of the present application, such as Figure 5 As shown, Figure 5 As shown, the size of the gray area of the contact lens mold cropped image is unchanged from the size of the gray area of the contact lens mold rotated image, while the white area at the bottom of the contact lens mold cropped image is smaller than the white area at the bottom of the contact lens mold rotated image, thereby reducing the interference of background information and improving the accuracy of contact lens mold defect detection.
[0098] The contact lens mold cut image is segmented according to a preset segmentation number to obtain a plurality of contact lens mold segmented images, and a first positional relationship between the plurality of contact lens mold segmented images and the rectangular image is recorded.
[0099] In this embodiment, when the ratio of the edge perimeter to the radius is greater than a preset threshold, the preset number of divisions may be 3 or other values, and the preset threshold may be 6 or other values.
[0100] The edge area in the contact lens casting mold segmentation image is divided, and an overlapping area is added to the edge area, and the overlapping area is spliced with the edge area to obtain a contact lens casting mold supplementary image, and the overlapping area has the same size as the edge area.
[0101] In this embodiment, the width of the edge region may be a width corresponding to 100 image elements, or a width corresponding to other numerical image elements. The overlapping region and the edge region are adjacent in the contact lens mold fusion image.
[0102] In this embodiment, the pixels in the overlapping area are spliced with the pixels in the edge area, and the pixels in the edge area in the contact lens mold segmentation image are supplemented to avoid the loss of pixels in the edge area during the defect detection process, which affects the detection effect.
[0103] Figure 6 is a schematic diagram of a contact lens casting mold segmentation image shown in an exemplary embodiment of the present application, such as Figure 6 As shown, the contact lens mold cropped image is divided into three segments, each segment is the same size, and each segment has edge regions at both ends. Therefore, there are 6 edge regions, namely edge region 1, edge region 2, edge region 3, edge region 4, edge region 5 and edge region 6. Since edge region 6 and edge region 1 are adjacent to each other in the contact lens mold fusion image, edge region 6 is regarded as the overlapping region of edge region 1. Similarly, edge region 2 and edge region 3, as well as edge region 4 and edge region 5 are regarded as overlapping regions.
[0104] The contact lens casting mold supplementary images are stacked to obtain a transformed image, and a second positional relationship between the contact lens casting mold supplementary images and the transformed image is recorded.
[0105] In this embodiment, the stacking direction of the contact lens mold supplementary images is vertical stacking, and the size of the images is transformed after stacking to adapt to the image input size of the contact lens mold printing defect detection model.
[0106] Figure 7 is a schematic diagram of a transformed image shown in an exemplary embodiment of the present application, such as Figure 7 As shown, three segments of contact lens mold supplementary images are stacked in the vertical direction, and after stacking, the size of the image is transformed to adapt to the image input size of the contact lens mold printing defect detection model.
[0107] In one embodiment of the present application, the process of transforming the defect detection output image to obtain the defect detection result includes: dividing the defect detection supplementary image from the defect detection output image according to the second positional relationship, performing an AND operation on the edge area pixel values of the defect detection supplementary image and the corresponding overlapping area pixel values to obtain the calculated pixel values, and replacing the edge area pixel values of the defect detection supplementary image with the calculated pixel values to obtain the defect detection segmented image, and the defect detection supplementary image has a corresponding relationship with the contact lens mold supplementary image.
[0108] In this embodiment, three defect detection supplementary images are divided from the defect detection output image in order from top to bottom, the size of the defect detection supplementary image is consistent with the size of the contact lens casting supplementary image, and the positions of the three defect detection supplementary images in the defect detection output image correspond to the positions of the three contact lens casting supplementary images in the transformed image. The edge area of the defect detection segmented image is the same size as the edge area in the contact lens casting supplementary image.
[0109] The pixels in the pre-generated all-zero mask image are replaced by the defect detection segmentation image according to the first positional relationship to obtain a rectangular mask image.
[0110] In this embodiment, the defect detection segmented image and the contact lens mold segmented image have a corresponding relationship, and the size of the all-zero mask image is the same as the size of the rectangular image.
[0111] A second rotation operation and a polar coordinate inverse transformation operation are performed on the rectangular mask image to obtain a circular mask image, and the circular mask image has the same size as the contact lens casting fusion image.
[0112] In this embodiment, the second rotation operation is to rotate the rectangular mask image 90 degrees clockwise, and the rectangular mask image can also be rotated 270 degrees counterclockwise. After the second rotation operation is performed on the rectangular mask image, a rectangular rotated mask image is obtained, and then the rectangular rotated mask image is subjected to an inverse polar coordinate transformation operation, which is the inverse process of the polar coordinate transformation method.
[0113] The contour of the circular mask image is extracted to obtain a mask image contour, and the mask image contour image is used as a defect detection result.
[0114] In this embodiment, after the mask contour image is obtained, a circumscribed rectangle is drawn on the mask contour image to obtain a defect detection result.
[0115] Figure 8 FIG. 1 is a schematic diagram showing a defect detection result according to an exemplary embodiment of the present application. Figure 8 As shown, the defective positions in the mask contour image are marked by means of boxes, so that the positions of the printing defects can be intuitively seen.
[0116] The following describes a system embodiment of the present application, which can be used to execute the contact lens mold printing defect detection method in the above embodiment of the present application. For details not disclosed in the system embodiment of the present application, please refer to the embodiment of the contact lens mold printing defect detection method in the above embodiment of the present application.
[0117] Fig. 9 It is a block diagram of a contact lens casting mold printing defect detection system shown in an exemplary embodiment of the present application.
[0118] like Fig. 9 As shown, the exemplary contact lens casting mold printing defect detection system includes: an image acquisition module 901 is used to acquire multiple contact lens casting mold color images collected at different light source heights.
[0119] The image fusion module 902 is used to align the centroids of multiple contact lens mold color images to obtain a contact lens mold fusion image.
[0120] The image transformation module 903 is used to perform coordinate transformation on the contact lens mold fusion image to obtain a transformed image so as to adapt the transformed image to the contact lens mold printing defect detection model.
[0121] The defect detection module 904 is used to perform defect detection on the transformed image by printing a defect detection model using a contact lens casting mold to obtain a defect detection result.
[0122] In one embodiment of the present application, when the contact lens mold is placed on the inspection station for inspection, the light source will move quickly from low to high multiple times, and the light source will stay for a short time after each movement. At this time, a camera is used to take pictures to obtain multiple color images of the contact lens mold at different light source heights.
[0123] In this embodiment, since mechanical vibration is unavoidable when the camera takes images, the pixels at each position of multiple images at different light source heights are usually not one-to-one corresponding, and directly fusing the images will produce a problem of blurred patterns. However, after the centroids of multiple contact lens mold color images are aligned and then fused, the problem of blurred patterns in the fused image can be reduced, and the lighting in the printing area can be uniform, thereby improving the quality of the fused image of the contact lens mold.
[0124] In this embodiment, since the printing area of the contact lens mold is usually annular, when using the contact lens mold printing defect detection model to perform defect detection on the edge of the annular printing area, there is a problem that arc defects are difficult to accurately mark, resulting in poor defect detection results and low accuracy. By performing coordinate transformation on the contact lens mold fusion image, background interference is reduced and the resolution of the contact lens mold fusion image is improved, thereby greatly improving the defect detection accuracy.
[0125] In this embodiment, the contact lens mold printing defect detection model can be a deep neural network detection model, etc., which is not limited here.
[0126] In this embodiment, by acquiring multiple color images of contact lens molds collected at different light source heights, the multiple color images of contact lens molds are aligned to obtain a contact lens mold fusion image, and the coordinates of the contact lens mold fusion image are transformed to obtain a transformed image, so that the transformed image is adapted to a contact lens mold printing defect detection model, and defect detection is performed on the transformed image through the contact lens mold printing defect detection model to obtain a defect detection result, which has the technical effect of reducing labor costs, saving time, and improving production yield.
[0127] It should be noted that the contact lens mold printing defect detection system provided in the above embodiment and the contact lens mold printing defect detection method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In actual application, the contact lens mold printing defect detection system provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the system into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0128] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the electronic device implements the contact lens mold printing defect detection method provided in the above-mentioned embodiments.
[0129] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0130] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0131] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor of a computer, causes the computer to execute the above-mentioned contact lens casting mold printing defect detection method. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0132] Another aspect of the present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the contact lens casting mold printing defect detection method provided in each of the above embodiments.
[0133] 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 technology may modify or change the above embodiments without violating the spirit and scope of the present invention. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A method for detecting defects in contact lens mold printing, characterized in that: The method comprises: Acquire multiple contact lens casting color images acquired at different light source heights; Aligning the centroids of the plurality of contact lens casting color images to obtain a contact lens casting fusion image; The contact lens casting mold fusion image is subjected to coordinate transformation to obtain a transformed image, so that the transformed image is adapted to the contact lens casting mold printing defect detection model; the coordinate transformation method is a polar coordinate transformation method; Perform defect detection on the transformed image by using the contact lens casting mold printing defect detection model to obtain a defect detection result; The process of aligning the centroids of the plurality of contact lens casting color images to obtain a contact lens casting fusion image comprises: Converting the plurality of contact lens casting mold color images into grayscale images respectively to obtain a plurality of grayscale images, and performing threshold segmentation and filtering on each of the grayscale images respectively to obtain a plurality of contact lens casting mold binary filtering images; Based on each of the contact lens mold binary filtering images, an annular mask image is established to obtain a plurality of the annular mask images, wherein the annular position of the annular mask image corresponds to the edge area of the mold, and the annular position of the annular mask image is filled with a gray value within a preset range; Performing AND operations on each of the contact lens mold binary filter images and the corresponding annular mask image to obtain multiple mold edge area images; Extracting a contour image from each of the mold edge region images, and screening the area size of the contour image in each of the mold edge region images to obtain a screened contour image; According to the moment features of each of the filtered contour images, the centroid of the corresponding mold edge region image is determined, and the plurality of contact lens mold color images are aligned according to the centroid of the corresponding mold edge region image to obtain a contact lens mold fusion image, wherein the centroids of the plurality of mold edge region images have a one-to-one correspondence with the plurality of contact lens mold color images; The process of aligning a plurality of the contact lens mold color images according to the centroids of the corresponding mold edge area images to obtain a contact lens mold fusion image comprises: Selecting one image of the edge region of the mold from the plurality of images of the edge region of the mold as a reference image, and using the centroid of the reference image as a reference centroid; respectively calculating the offset between the centroid of the mold edge region image and the reference centroid to obtain the offset of the mold edge region image relative to the reference image; Based on the offset, each image of the edge area of the mold is expanded in size, and a three-channel all-zero mask image is established according to the expanded size, and each contact lens mold color image is filled into the corresponding three-channel all-zero mask image to obtain a plurality of filled mask images, where the three channels correspond to three color dimensions; Aligning the centroids of all the filled mask images with the reference centroid to obtain an aligned image, wherein the pixel value at each position in the aligned image is an overlapping pixel value; The mean value of the overlapping pixel values at each position in the aligned image is calculated, and the overlapping pixel values at the corresponding position are replaced by the mean value of the overlapping pixel values at each position to obtain the contact lens casting fusion image.
2. The contact lens casting mold printing defect detection method according to claim 1, characterized in that: The process of performing coordinate transformation on the contact lens casting mold fusion image to obtain a transformed image comprises: Transforming the contact lens mold fusion image in the polar coordinate transformation manner to obtain a rectangular image; The rectangular image is resized to obtain a transformed image, so that the transformed image is adapted to a contact lens casting mold printing defect detection model.
3. The contact lens casting mold printing defect detection method according to claim 2, characterized in that: The process of performing defect detection on the transformed image by printing the defect detection model of the contact lens casting mold to obtain the defect detection result includes: inputting the transformed image into the contact lens casting mold printing defect detection model; If the contact lens casting mold printing defect detection model detects that there is a defect in the transformed image, the defect position is drawn in the transformed image to obtain a defect detection output image, and the defect detection output image is transformed to obtain the defect detection result; If the contact lens casting mold printing defect detection model does not detect the existence of defects in the transformed image, the current product is considered qualified as the defect detection result.
4. The contact lens casting printing defect detection method according to claim 1, characterized in that: The process of screening the area size of the contour image in each of the mold edge area images comprises: Obtaining a preset contact lens casting mold area range; Sorting the contour images in all the mold edge area images according to their area sizes, and selecting a preset number of contour images from the sorting results; The preset number of contour images are compared with the preset contact lens casting mold area range, and the contour images that meet the preset contact lens casting mold area range are used as the screened contour images.
5. The contact lens casting mold printing defect detection method according to claim 2, characterized in that: The process of transforming the contact lens mold fusion image in the polar coordinate transformation manner to obtain a rectangular image includes: Obtaining the center coordinates and radius of the contact lens mold fusion image; Calculating the edge perimeter of the contact lens casting mold fusion image according to the center coordinates and the radius; The contact lens mold fusion image is expanded with the center of the circle through the polar coordinate transformation method to obtain a rectangular image, wherein the height of the rectangular image is the edge perimeter, and the width is the radius.
6. The contact lens casting mold printing defect detection method according to claim 2, characterized in that: The process of resizing the rectangular image to obtain the transformed image includes: Performing a first rotation operation on the rectangular image to obtain a contact lens mold rotation image, wherein the width of the contact lens mold rotation image is the edge circumference, and the height is the radius; According to a preset cropping ratio, the contact lens casting mold rotation image is cropped to obtain a contact lens casting mold cropped image; Segmenting the contact lens mold cut image according to a preset segmentation number to obtain a plurality of contact lens mold segmentation images, and recording a first positional relationship between the plurality of contact lens mold segmentation images and the rectangular image; Dividing the edge area in the contact lens casting mold segmentation image, adding an overlapping area to the edge area, and splicing the overlapping area with the edge area to obtain a contact lens casting mold supplementary image, wherein the overlapping area has the same size as the edge area, and the overlapping area and the edge area are adjacent in position in the contact lens casting mold fusion image; The contact lens casting mold supplementary images are stacked to obtain the transformed image, and a second positional relationship between the contact lens casting mold supplementary images and the transformed image is recorded.
7. The contact lens casting printing defect detection method according to claim 6, characterized in that: The process of transforming the defect detection output image to obtain the defect detection result includes: According to the second positional relationship, dividing the defect detection supplementary image from the defect detection output image, performing an AND operation on the edge area pixel value of the defect detection supplementary image and the corresponding overlapping area pixel value to obtain the calculated pixel value, and replacing the edge area pixel value of the defect detection supplementary image with the calculated pixel value to obtain the defect detection segmented image, wherein the defect detection supplementary image has a corresponding relationship with the contact lens casting mold supplementary image; Replacing pixels in a pre-generated all-zero mask image by the defect detection segmentation image according to the first positional relationship to obtain a rectangular mask image, wherein the size of the all-zero mask image is the same as the size of the rectangular image; Performing a second rotation operation and a polar coordinate inverse transformation operation on the rectangular mask image to obtain a circular mask image, wherein the circular mask image has the same size as the contact lens casting mold fusion image; The contour of the circular mask image is extracted to obtain a contour image of the mask image, and the contour image of the mask image is used as the defect detection result.
8. A contact lens casting printing defect detection system, characterized in that: The contact lens casting mold printing defect detection system is used to perform the contact lens casting mold printing defect detection method according to any one of claims 1 to 7, and the system comprises: An image acquisition module, used to acquire a plurality of contact lens casting mold color images collected at different light source heights; An image fusion module, used for aligning the centroids of the plurality of contact lens casting color images to obtain a contact lens casting fusion image; An image transformation module, used for performing coordinate transformation on the contact lens casting mold fusion image to obtain a transformed image, so that the transformed image is adapted to the contact lens casting mold printing defect detection model; The defect detection module is used to perform defect detection on the transformed image by printing the defect detection model of the contact lens casting mold to obtain a defect detection result.
Citation Information
Cited By
An artificial intelligence-based method for detecting defects in contact lens production
CN119125008B
