Machine vision-based control method and system for axis-fixing liquid injection and mold closing

CN122876607APending Publication Date: 2026-10-09SIGMA SQUARES (BEIJING) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202611080237.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-21
Publication Date
2026-10-09

Smart Images

  • Figure CN122876607A_ABST
    Figure CN122876607A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of contact lens production, in particular to a fixed-axis liquid injection and mold closing control method and system based on machine vision, which accurately calculates the reference axis direction of each mold through image segmentation, ellipse fitting and feature center extraction, and solves the problem that the mold angle cannot be determined due to the non-rotationally symmetrical pattern in the traditional process. By using the direction angle difference value of the upper mold and the lower mold, the upper mold is controlled to rotate to align with the lower mold, so that the thick and thin areas of the lens after mold closing are consistent with the direction of the highlight pattern, and the functional requirement of automatic orientation and sinking of the lens when worn is met. In addition, the application is applied to a large-scale production scene, supports tray-type multi-mold simultaneous identification and pairing, automatically completes batch mold closing alignment, greatly improves production efficiency and reduces manual errors. Interferences such as mold size tolerance, thermal expansion and contraction and local distortion can be overcome, the ellipse center and positioning features are stably extracted, and high-precision axis alignment is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of contact lens manufacturing technology, specifically a fixed-axis liquid injection mold closing control method and system based on machine vision. Background Technology

[0002] Contact lens pad printing is a printing process used to add color and patterns to colored contact lenses. In traditional contact lens pad printing, since the printed patterns are mostly rotationally symmetrical, the printing head can transfer the pattern to the mold or lens surface at any angle. During the liquid injection and molding stage, the upper and lower molds can also be molded and cured at any angle.

[0003] However, with the development of contact lens technology and the emergence of new market demands, high-brightness fixed-axis lenses have begun to appear on the market. High-brightness fixed-axis lenses refer to lenses with non-rotationally symmetrical highlight areas. These highlight areas have non-rotationally symmetrical patterns and are slightly thicker than other areas. When worn, the pressure of the eyelids and the flow of fluid during blinking cause the thicker part to automatically sink to the bottom, thus fixing the lens orientation. The highlight area always appears slightly below the center of the eye. In this case, traditional liquid injection molding techniques cannot accurately position and fit the upper and lower molds along the axis. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a machine vision-based fixed-axis liquid injection mold closing control method and system to solve the problems in the background art.

[0005] To achieve the above objectives, this application adopts the following technical solution:

[0006] This application discloses a machine vision-based fixed-axis liquid injection mold closing control method, comprising the following steps:

[0007] Obtain the original image of the mold tray of the contact lens during the liquid injection and molding stage, wherein the original image includes the original image of the upper mold tray and the original image of the lower mold tray, and the original image is a grayscale image;

[0008] The original image is segmented to obtain multiple mold sub-images and the mold coordinates corresponding to the multiple sub-images;

[0009] Extract the mold edge contour from the sub-image and fit the mold edge contour to obtain an elliptical mold and an elliptical center;

[0010] Based on the center of the ellipse, extract the annular region where the expected position of the positioning feature is located from the mold ellipse, and extract the center of the positioning feature from the annular region, wherein the positioning feature is pre-set on the edge of the mold;

[0011] The orientation angle of the reference axis of the mold is determined based on the center of the ellipse and the center of the positioning feature. The upper mold and the lower mold are paired based on the mold coordinates. The orientation angle difference between the upper mold and the lower mold in the paired state is calculated. Based on the orientation angle difference, the upper mold is rotated and aligned with the lower mold to complete the mold closing.

[0012] This application also provides a machine vision-based fixed-axis liquid injection and mold closing control system, including:

[0013] The acquisition module is used to acquire the original image of the mold tray of the contact lens during the liquid injection and molding stage, wherein the original image includes the original image of the upper mold tray and the original image of the lower mold tray, and the original image is a grayscale image;

[0014] The segmentation module is used to segment the original image to obtain multiple mold sub-images and the mold coordinates corresponding to the multiple sub-images;

[0015] The coarse positioning module is used to extract the mold edge contour from the sub-image and fit the mold edge contour to obtain an elliptical mold and an elliptical center.

[0016] A fine positioning module is used to extract the annular region where the expected position of the positioning feature is located from the mold ellipse based on the center of the ellipse, and to extract the center of the positioning feature from the annular region, wherein the positioning feature is pre-set at the edge of the mold;

[0017] The alignment and mold closing control module is used to determine the direction angle of the reference axis of the mold based on the center of the ellipse and the center of the positioning feature, and to pair the upper mold and the lower mold based on the mold coordinates, calculate the direction angle difference between the upper mold and the lower mold in the paired state, and control the upper mold to rotate and align to the lower mold based on the direction angle difference to complete the mold closing.

[0018] The beneficial effects of this application are as follows: This application provides a machine vision-based fixed-axis liquid injection mold-closing control method and system. Through image segmentation, ellipse fitting, and extraction of positioning feature centers, it accurately calculates the reference axis direction of each mold, solving the problem that traditional processes cannot determine the mold angular orientation due to the non-rotational symmetry of the pattern. Utilizing the angular difference between the upper and lower molds, the upper mold is controlled to rotate until it aligns with the lower mold, ensuring that the thickness area of ​​the lens after molding is consistent with the direction of the highlight pattern, meeting the functional requirement of automatic orientation and sinking during wear. Furthermore, this application can be applied to large-scale production scenarios, supporting simultaneous identification and pairing of multiple tray-type molds, automatically completing batch mold alignment, significantly improving production efficiency and reducing human error. It can overcome interference from mold size tolerances, thermal expansion and contraction, and local distortion, stably extracting the ellipse center and positioning features to ensure high-precision axis alignment. Attached Figure Description

[0019] The present application will be further described below with reference to the accompanying drawings and embodiments:

[0020] Figure 1 This is a schematic diagram of the overall structure of a contact lens liquid injection and molding device according to one embodiment of this application;

[0021] Figure 2 This is a schematic diagram of the structure of the adjusting mold closing unit in one embodiment of this application;

[0022] Figure 3 This is a schematic diagram of a high-gloss fixed-axis contact lens according to one embodiment of this application;

[0023] Figure 4 This is a schematic diagram of the mold structure for a high-gloss fixed-axis lens according to an embodiment of this application;

[0024] Figure 5 This is a flowchart illustrating a machine vision-based fixed-axis liquid injection mold closing control method in one embodiment of this application.

[0025] Figure 6 This is a flowchart of the initialization configuration in one embodiment of this application;

[0026] Figure 7 This is a flowchart illustrating the preprocessing process in one embodiment of this application;

[0027] Figure 8 This is a schematic diagram of an image segmentation process according to an embodiment of this application;

[0028] Figure 9 This is a schematic diagram of the coarse positioning process in one embodiment of this application;

[0029] Figure 10 This is a schematic diagram of the ellipse fitting iteration process in one embodiment of this application;

[0030] Figure 11 As shown in one embodiment of this application Schematic diagram of the precise positioning process;

[0031] Figure 12 This is a logic structure diagram of a fixed-axis liquid injection and mold closing control system based on machine vision, as shown in one embodiment of this application. Detailed Implementation

[0032] Figure 1 This is a schematic diagram of the overall structure of a contact lens liquid injection and molding device according to one embodiment of this application. The liquid injection and molding control methods described in this application are all based on Figure 1 The structure shown is as follows: Figure 1 As shown, it includes:

[0033] Lower die feeding unit 100 for loading material into the lower die

[0034] Carrier turnover unit 200 for turnover of lower mold carrier;

[0035] An injection unit 300 is provided along the turnover path of the vehicle turnover unit 200;

[0036] Adjust the mold clamping unit 400;

[0037] 500 mold clamping unit;

[0038] The specific steps are as follows:

[0039] The turnover unit 200 drives the lower mold carrier containing the lower mold to be injected to the injection unit 300;

[0040] The injection unit 300 injects liquid into the empty lower mold inside the lower mold carrier 210; the turnover unit 200 moves the lower mold carrier 210, which carries the liquid-injected lower mold, to the adjustment and closing unit 400.

[0041] Adjust the mold clamping unit 400 to pick up the upper mold, adjust the upper mold to match the lower mold to be clamped, and place the upper mold into the lower mold after liquid injection;

[0042] The turnover unit 200 drives the paired upper and lower molds to the mold closing and pressing unit 500; the mold closing and pressing unit 500 presses the upper and lower molds together to complete the mold closing.

[0043] Furthermore, the specific structure and principle of the above-mentioned overall structure can be found in the applicant's application CN202510137337.5, "A Method and System for Injection and Molding of Contact Lenses for Astigmatism." The following section will focus on the content related to injection and molding control.

[0044] Figure 2 This is a schematic diagram of the structure of the adjusting mold closing unit in one embodiment of this application, as shown below. Figure 2 As shown, in the mold-closing adjustment unit, a first vision acquisition device 401 for acquiring images of the lower mold tray 600 and a second first vision acquisition device 402 for acquiring images of the upper mold tray are respectively provided at the top. After acquiring images of the lower mold tray and the upper mold tray respectively, the system enters the fixed-axis liquid injection mold-closing control method based on machine vision described in this application to calculate the required rotation angle of the upper mold. At the same time, the pickup actuator 404 in the pickup adjustment mechanism 403 first picks up the upper mold from the upper mold tray and places it in the temporary storage mechanism 405 for dust removal. After dust removal, the rotation adjustment angle is obtained from the fixed-axis liquid injection mold-closing control method based on machine vision, the upper mold is picked up and moved above the lower mold tray 600, rotated and aligned, and then liquid is injected and the mold is closed. The subsequent process is curing. Since the pattern of the lens is pre-printed inside the lower mold by the transfer printing head, the cured lens also has the pattern printed on it.

[0045] Based on the above structure, this application can realize liquid injection and mold closing control for non-rotationally symmetrical products such as astigmatism lenses and high-gloss fixed-axis contact lenses.

[0046] Figure 3 This is a schematic diagram of a high-gloss fixed-axis contact lens according to one embodiment of this application, as shown below. Figure 3 As shown, the high-gloss fixed-axis contact lens described in this application has a high-gloss area 310 printed on the lower side of the center of the lens, which makes the wearer's eyes appear brighter and more expressive.

[0047] Because the thickness of contact lenses is not uniform, the lens in this application employs a special structural design that utilizes eyelid pressure and water flow during blinking to allow the thicker portion to automatically sink to the bottom, thereby fixing the lens orientation. In other words, the highlight area 110 simultaneously corresponds to the thicker area of ​​the lens, and both have an axis that cannot be arbitrarily rotated for alignment. The upper and lower molds must be aligned axially during the liquid injection and molding stage. After liquid injection, molding, and curing, the pattern is printed onto the lens.

[0048] Figure 4 This is a schematic diagram of the mold structure for a high-gloss fixed-axis lens according to one embodiment of this application, as shown below. Figure 4 As shown, the edge of the main body of the mold for the high-gloss fixed-axis lens in this application (including the upper mold on the right and the lower mold on the left) is provided with positioning features, namely the two notches shown in the figure. These features are used for axis alignment during the liquid injection and mold closing stage.

[0049] Figure 5 This is a flowchart illustrating a machine vision-based fixed-axis liquid injection mold closing control method in one embodiment of this application, as shown below. Figure 5 As shown, the fixed-axis liquid injection mold closing control method based on machine vision in this application includes the following steps in its overall concept:

[0050] A. Configuration Parameter Loading: Responsible for initializing the measurement system, including reading configuration files and loading algorithm and system parameters. Load images captured by the camera Original images of the mold tray for the upper mold, respectively. Original image of the mold tray and the lower mold. And loading the corresponding detection model, etc.

[0051] B. Preprocessing: Image processing Grayscale conversion, Gaussian filtering, and grayscale stretching are performed to reduce image noise and highlight mold features.

[0052] C. Image segmentation: The original image is segmented to obtain multiple mold sub-images and the mold coordinates corresponding to the multiple sub-images;

[0053] use For the first grayscale image Second grayscale image Target detection is performed, and the detection bounding boxes are used to segment the sub-images, which serve as the approximate range of each mold.

[0054] D. Coarse positioning: Extract the mold edge contour from the sub-image and fit the mold edge contour to obtain the elliptical mold and the ellipse center;

[0055] The edge positions of the mold contour are roughly extracted based on the gradient magnitude accumulation curve. Then, the ROI region of the sub-image is shrunk using the edge positions to avoid interference from adjacent mold edge contours. Next, the ROI region is sharpened to improve the contrast between the mold edges and the background. Adaptive binarization is used to extract image features, obtaining the contour information of all features. (Based on data obtained from C...) Get each feature Then, the feature contours are filtered to obtain the final mold edge contours. .

[0056] E. Precise positioning of the mold: Fit the edge contour of the mold to obtain the mold ellipse and the center of the ellipse;

[0057] Based on the extracted mold edge contour Use the improved version The least squares algorithm improves the accuracy of ellipse fitting and automatically adapts to mold tolerances to obtain the optimal ellipse. Thus, the center of the mold can be precisely located. .

[0058] F. Mark Precision Positioning: Based on the center of the ellipse, extract the annular region where the expected position of the positioning feature is located from the mold ellipse, and extract the center of the positioning feature from the annular region, wherein the positioning feature is pre-set on the edge of the mold;

[0059] Select the baseline subimage, and from... Obtain the scale range parameter from E, and then use the scale range parameter and the parameter obtained from E. The annular region is extracted and filtered by entropy value to generate... Mask of the area ,according to and D edge Using centroid calculation center .

[0060] In batch scenarios, the proportions determined by selecting a baseline sub-image are directly applied to other sub-images to extract the proportions from all sub-images. Mask of the area and generate center .

[0061] G. Angle Calculation and Mold Closure: Determine the direction angle of the reference axis of the mold based on the center of the ellipse and the center of the positioning feature, and pair the upper mold and the lower mold based on the mold coordinates. Calculate the direction angle difference between the upper mold and the lower mold in the paired state, and control the upper mold to rotate and align with the lower mold based on the direction angle difference to complete the mold closure.

[0062] Obtained in E And obtained from F , forming a vector ,calculate The angle between the mold and the X-axis of the image is used to obtain the axial angle of the male or female mold. The coordinates described above are used to pair the upper and lower molds for any set of molds. The difference in their axial angles is calculated to obtain the rotation angle of the male mold's pick-up actuator, which is used to perform mold closing.

[0063] The following section will elaborate on each step in the overall approach outlined above.

[0064] A. Initialization Configuration: Responsible for initializing the measurement system and loading preset system parameters. Load the image data captured by the camera as .

[0065] Figure 6 This is a flowchart of the initialization configuration in one embodiment of this application, such as... Figure 6 As shown, the initialization configuration process in this application includes:

[0066] A1. Read the configuration file. The configuration table consists of three parts.

[0067] One is the system's preset configuration, which includes size parameters, system settings, etc.;

[0068] The second part is feature verification information, which includes the mold. The detection parameters and configuration parameters include the mold edge contour. Geometric information, such as length intervals area range Aspect Ratio Range The configuration parameters mainly include image sharpening parameters. Adaptive binarization parameters , Generate proportional range parameters Image grayscale mean parameter Parameters of the improved RANSAC algorithm, etc.

[0069] Thirdly, there are model configuration parameters, including a list of object categories. The model detects the confidence threshold dictionary for each object. and model path wait.

[0070] A2. Load, decode, and read camera image data, convert it from RAW to RGB format, and then transform the image to grayscale space to obtain a grayscale image. This process yields the captured bright-field image data, which serves as... .

[0071] A3. Load the relevant parameters from A1, including detection parameters and configuration parameters.

[0072] B. Preprocessing: Preprocessing is responsible for... The image undergoes secondary processing, including preprocessing, noise removal, and ensuring image consistency.

[0073] Figure 7 This is a flowchart illustrating the preprocessing process in one embodiment of this application, as shown below. Figure 7 As shown, the preprocessing procedure in this application includes:

[0074] B1. Perform Gaussian filtering on the original image to obtain a Gaussian filtered image;

[0075] Specifically, the original image in A2 Performing verification Gaussian filtering process to obtain Gaussian filtered image The aim is to reduce interference from environmental noise.

[0076] B2. Calculate the mean gray level of the Gaussian filtered image, and calculate the ratio of the mean gray level to the preset mean gray level parameter to obtain the gray level ratio;

[0077] calculate Image mean Calculate its relationship with The ratio of grayscale .

[0078] B3. Based on the grayscale ratio, perform grayscale stretching on the Gaussian filtered image to obtain a preprocessed image.

[0079] use right Perform grayscale stretching to obtain the preprocessed image. .

[0080] C. Image segmentation: The original image is segmented to obtain multiple mold sub-images and the corresponding mold coordinates of the multiple sub-images.

[0081] Figure 8 This is a schematic diagram of the image segmentation process in one embodiment of this application, as shown below. Figure 8 As shown, the image segmentation process includes:

[0082] C1. Target detection is performed on the preprocessed image based on a pre-built recognition model to obtain multiple target detection results, wherein the target detection results include detection boxes, detection confidence scores, and target categories;

[0083] Among them, The model is used for inference detection to obtain the detection results. ,in, ;

[0084] This is the first test result. This is the second test result. For the first One test result, For the first One test result, The first The two diagonal coordinates of the detection box of each detection result. For the first The confidence level of each test result No. The target category label for each detection result.

[0085] C2. Extract the target detection result with the target category of mold from the multiple detection results; compare the detection confidence of the target detection result with the target category of mold with a preset confidence threshold, and extract the sub-image based on the detection box when the detection confidence is greater than or equal to the preset confidence threshold.

[0086] Specifically, it includes:

[0087] C21, Loop Firstly, according to Perform filtering if Includes If the condition is met, jump to C22; otherwise, return to C21.

[0088] C22, obtained Confidence threshold for this category ,and Compare, if If the condition is met, jump to C23; otherwise, return to C21.

[0089] C23, will Save to If the iteration is not complete, return C21; otherwise, terminate.

[0090] C3. Assign coordinates to multiple sub-images and use the coordinates of the sub-images as the corresponding mold coordinates. In this application, regardless of whether it is the upper mold tray image or the lower mold tray image, the two-dimensional coordinates are automatically assigned based on the lower left sub-image. For example, the coordinates of the lower left sub-image are (0,0), and the mold coordinates of the sub-images in the same row are (1,0), (2,0)... respectively. The position coordinates are converted to facilitate the subsequent pairing of the upper and lower molds.

[0091] D. Coarse positioning: Extract the mold edge contour from the sub-image and fit the mold edge contour to obtain the elliptical mold and the ellipse center.

[0092] Figure 9 This is a schematic diagram of the coarse positioning process in one embodiment of this application, as shown below. Figure 9 As shown, the coarse positioning process includes:

[0093] YOLO bounding boxes are typically 10% to 20% larger than the actual mold outline and may include the edges of adjacent molds. To eliminate interference from adjacent mold outlines, this application performs the following ROI region shrinking before coarse positioning.

[0094] D1. Extract the gradient magnitude of each pixel in the sub-image, and accumulate the gradient magnitude of each pixel along the horizontal and vertical directions to obtain the horizontal projection curve and the vertical projection curve.

[0095] First, try using the Sobel operator to calculate the gradient magnitude of each pixel in the sub-image. This yields a gradient magnitude map of the same size as the original image.

[0096] For each row, the sum of the gradient magnitudes of all pixels in that row is calculated, resulting in a one-dimensional array of length H of the image height. The peaks typically correspond to the horizontal edges (top and bottom boundaries) of the object.

[0097] For each column, the sum of the gradient magnitudes of all pixels in that column is calculated, resulting in a one-dimensional array with a length of the image width W. The peaks typically correspond to the horizontal edges (left and right boundaries) of the object.

[0098] D2. Extract two peaks from the horizontal projection curve that exceed a preset peak threshold, and extract two peaks from the vertical projection curve that exceed a preset peak threshold. Based on the four peaks, extend outward by a unit distance to obtain the left boundary, right boundary, upper boundary, and lower boundary. Based on the left boundary, the right boundary, the upper boundary, and the lower boundary, shrink the sub-image to the ROI region to obtain the target region image.

[0099] In horizontal and vertical gradient projection curves, the peak position typically corresponds to the pixel column / row with the strongest gradient response at the mold edge. However, the true edge of the mold (i.e., the geometric boundary of the mold contour) is often located inside the gradient response peak (because the gradient magnitude reaches its maximum at the edge, but the edge itself is a transition zone, and its exact location may be near the peak). If the peak position is directly used as the clipping boundary, part of the true mold edge may be cut off, resulting in an incomplete contour and affecting the accuracy of subsequent ellipse fitting. The purpose of extrapolating by a unit distance is precisely to preserve the complete edge transition region, ensuring that the clipped ROI includes the entire edge contour of the mold.

[0100] D3. Sharpen the coarse positioning result image based on preset image sharpening parameters to obtain a sharpened image, wherein the image sharpening parameters include radius, intensity, and threshold.

[0101] Use image sharpening parameters right Sharpen.

[0102] D4. Perform adaptive binarization processing on the sharpened image to obtain a binary image and the contour features in the binary image;

[0103] Apply adaptive binarization Extract contour features.

[0104] D5. Extract the geometric features from each contour feature in the binary image, wherein the geometric features include length, area and aspect ratio;

[0105] D6. Compare the geometric features in each contour feature with the preset geometric feature filtering range, and take the contour features whose geometric features meet the preset geometric feature filtering range as the mold edge contour. The geometric feature filtering range includes length range, area range and aspect ratio range.

[0106] Traverse the contour, based on the length range area range Aspect Ratio Range Precisely filter contour features.

[0107] E. Mold Precision Positioning: Based on the extracted mold edge contour Use the improved version The least squares algorithm improves the accuracy of ellipse fitting and automatically adapts to mold tolerances to obtain the optimal ellipse. Thus, the center of the mold can be precisely located. .

[0108] The angle determination in this application depends on the mold center. and location features To improve accuracy, the following improved version is adopted. + Least squares algorithm for precise positioning.

[0109] E1. Target points are selected from the mold edge contour based on gradient magnitude threshold and local orientation consistency, and sampling weights are assigned to each target point. And configure the initial number of iterations. ;

[0110] Before ellipse fitting (RANSAC), high-quality edge points are screened based on gradient magnitude and orientation consistency, and sampling weights are assigned to each point, while the initial number of iterations is set. The aim is to provide a cleaner and more representative point set for subsequent random sampling and ellipse fitting, and to control the computational complexity of the algorithm. The specific process includes:

[0111] E11. Obtain the gradient magnitude and gradient direction of each edge point in the mold edge contour, and calculate the average gradient of the entire preprocessed image;

[0112] Specifically, the Sobel operator is used to calculate the horizontal gradient of the preprocessed grayscale image. and vertical gradient Gradient magnitude of a pixel gradient direction .

[0113] Average gradient of the whole graph ,in, This represents the number of pixels in the preprocessed image.

[0114] E12. Construct a screening threshold based on the average gradient of the entire image. ;

[0115]

[0116] In the formula, The set scaling factor (empirical value 0.3~0.5) will be used to filter edge points with excessively low gradient magnitudes in E15.

[0117] E13, and construct a neighborhood with the edge point as the center, and calculate the gradient direction variance of all edge points in the neighborhood;

[0118] For each edge point Take a square neighborhood with a side length of 5 pixels and collect the gradient directions of all edge pixels within this neighborhood. Since the direction is a cyclic variable, the cyclic variance is used for calculation.

[0119]

[0120]

[0121] In the formula, This represents the total number of edge points within the neighborhood of the current edge point. Let be the average length of the resultant vector.

[0122] On the edge of a smooth ellipse, the gradient direction within the local neighborhood should be basically consistent (perpendicular to the tangent of the edge). However, at noisy, burr-like, or intersecting edges, the gradient direction is disordered, and the cyclic variance will increase significantly. Therefore, by calculating the variance of the gradient direction of all edge points in the neighborhood, it can be used to distinguish between the true edge of the ellipse and the interference points.

[0123] E14. Edge points that meet the target conditions are taken as target points, wherein the target conditions include gradient magnitude greater than the filtering threshold and gradient direction variance of all edge points in the neighborhood less than a preset direction variance threshold.

[0124] Edge points that simultaneously meet the following two conditions will be retained as target points:

[0125]

[0126]

[0127] Gradient magnitude filtering ensures points have sufficient contrast. Orientation consistency filtering ensures points belong to smooth elliptical arcs rather than random noise or corner points. These filtering methods significantly reduce the proportion of outliers (typically from 50% to below 20%), improving RANSAC convergence speed and final fitting accuracy. They also reduce ellipse center shifts caused by local spikes and reflections.

[0128] E15. Assign sampling weights to each target point. Among them, sampling weight The mathematical expression is:

[0129]

[0130] In the formula, For target point gradient magnitude, For the target point The gradient direction variance of all edge points in the neighborhood of the center;

[0131] Sampling weight In the calculation formula, points with high gradient magnitudes are more likely to be strong responses to real edges. As a reward factor for directional consistency, points with high consistency have a higher probability of being selected. The product of these two factors forms a comprehensive quality index, which serves as the sampling weight. This method is used in subsequent RANSAC random sampling to draw sampling points according to weighted proportions using a roulette wheel method. This guides the sampling to tend to select "more reliable" points, increasing the probability of fitting excellent candidate ellipses each time. Even if there are a few outliers that fail to pass the pre-filter, their low weight reduces their chance of being selected. Thus, a more stable optimal model is obtained with the same number of iterations.

[0132] E16. Define the initial number of iterations. Initial iteration count The mathematical expression is:

[0133]

[0134] In the formula, Indicates rounding up. Set the target confidence probability (e.g., 0.99). The initial interior point ratio is set (e.g., 0.5). This represents the number of sampling points (e.g., 6 sampling points).

[0135] RANSAC requires guaranteeing the probability that at least one sample consists entirely of interior points. The principle behind the above calculation is: the probability that all samples are interior points is... The probability of failure is , The probability of all failures is ,Require .

[0136] Initial iteration count It will be updated in subsequent iterations, and with the subsequent adaptive update mechanism, it can be dynamically adjusted after a better ellipse is found. To balance accuracy and efficiency.

[0137] E2, Sampling weights based on each target point and the initial number of iterations Multiple rounds of least-squares ellipse fitting iterations are performed on multiple target points to select the optimal ellipse. Based on the optimal ellipse, a mold ellipse and its center are constructed. Figure 10 This is a schematic diagram of the ellipse fitting iteration process in one embodiment of this application, as shown below. Figure 10 As shown, the ellipse fitting iteration process includes:

[0138] E21, Based on sampling weights Sampling is performed to obtain a subset of target points. ;

[0139] Using the roulette wheel selection method: based on the sampling weight of each target point... Calculate the cumulative probability distribution. In each iteration, N points are randomly selected independently (N is usually 6).

[0140] Sampling weight By combining gradient magnitude and local orientation consistency, points with larger weights are more likely to be reliable interior points. Random sampling according to weight proportions increases the probability of selecting high-reliability points, thereby increasing the probability that the candidate ellipse is fitted from the true interior points.

[0141] E22. Based on the target point subset and the sampling weight of each target point in the target point subset, perform weighted least squares ellipse fitting to obtain the candidate ellipse for the current iteration round.

[0142] For the target point subset and their corresponding weights ( For sampling point index, (This is a global index), establish the general equation of the ellipse:

[0143]

[0144] In the formula, For a quadratic term coefficient, The cross term coefficient, For a quadratic term coefficient, For a single term coefficient, For a single term coefficient, This is a constant term.

[0145] Then, construct the weighted least squares objective function: The constraints are: .

[0146]

[0147] The elliptic coefficients are obtained by solving the generalized eigenvalue problem (or SVD), and then converted into geometric parameters: center. Major and minor half-shafts Rotation angle To form the current candidate ellipse .

[0148] E23. Calculate each target point The shortest of the candidate ellipse Calculate the geometric distance and sum all the shortest geometric distances to obtain the total error;

[0149] For the target point Calculate its distance to the current candidate ellipse Shortest Euclidean distance Total error Represented as:

[0150]

[0151] The summed total error can be used to evaluate the goodness of fit of the candidate ellipse to all target points.

[0152] E24. Compare the total error of the current round with the historical lowest total error;

[0153] If the current round is the first iteration, then there is no previous round, and the update branch of E25 is executed directly.

[0154] Otherwise, compare and historical lowest total error E25. When the total error of the current round is less than the historical lowest total error, target points whose shortest geometric distance is less than or equal to a preset distance threshold are taken as interior points, and the proportion of interior points in the current round is calculated. And based on the proportion of interior points in the current round. Update the iteration round and proceed to step S7, where if there is no total error in the previous round, update directly;

[0155] like Then the current candidate ellipse is considered Better results. A better ellipse means its determined interior points are closer to the true ellipse contour, thus making the interior point ratio more reliable. The required number of iterations is recalculated based on the new interior point ratio, ensuring that the remaining iterations are sufficient to find the global optimum. Dynamic adjustment avoids excessive iterations (reducing the number of iterations when the interior point ratio is high) or insufficient iterations (increasing the number of iterations when the ratio is low). The computational load is adaptively controlled while maintaining high confidence probability. The interior point ratio estimate gradually approximates the true value, improving the algorithm's robustness.

[0156] E26. When the total error of the current round is greater than or equal to the historical lowest total error, proceed to step E27.

[0157] Candidate ellipses whose errors have not been improved are not of reference value and there is no need to waste computational resources updating the model parameters.

[0158] E27. Return to step E21 until the latest iteration number is reached, or if there are M consecutive iterations in which the proportion of interior points has not been updated and the proportion of interior points exceeds the preset proportion threshold, the ellipse with the smallest total error among multiple iterations is taken as the optimal ellipse.

[0159] After each iteration, the iteration counter is incremented by 1.

[0160] The termination condition is that any of the following is met:

[0161] The number of iterations has reached the current dynamically updated value. value.

[0162] Early termination condition met: continuous The optimal ellipse has not been updated 20 times (e.g., 20 times). And the current interior point ratio .

[0163] When terminating, select the ellipse with the smallest total error from all the ellipses that have been tried. As the final candidate ellipse.

[0164] E28. Use the optimal ellipse as the mold ellipse. And extract the center of the ellipse of the mold ellipse. .

[0165] Return to the center of the ellipse Used for subsequent positioning (such as forming a vector with the center of the Mark).

[0166] F, Precise positioning: From Obtain the scale range parameters (including the scale range of the outer ellipse) in the middle. and the range of the inner ellipse ), based on the proportional range parameter and obtained from E ,generate Mask of the area ,according to and D edge Using centroid calculation center .

[0167] Due to dimensional tolerances, thermal expansion and contraction, or localized deformation during mold production, the actual radial proportion of the positioning feature (Mark) relative to the mold center deviates from the theoretical design value (fixed). If a fixed proportion is used, the annular area may completely deviate from the true position of the Mark, leading to positioning failure.

[0168] This application combines a reference sub-image with step search (i.e., enumerating multiple ratio combinations within a certain range) to adaptively find the annular region that best matches the actual shape of the current mold. By using the maximum information entropy criterion, even if the mold has ±5% scaling or distortion, the true interval where the Mark is located can still be accurately locked, thereby ensuring the stable extraction of localization features. Then, the optimal ratio collected from the reference sub-image is used in other sub-images to balance accuracy and computational efficiency. The specific method is as follows.

[0169] Figure 11 As shown in one embodiment of this application A flowchart illustrating the precise positioning process, as shown below. Figure 11 As shown, The precise positioning process includes:

[0170] F1. Select the reference sub-image, the mold ellipse within the reference sub-image, and the ellipse center; then extract the length of the major semi-axis of the mold ellipse from the reference sub-image. Length of the short half-axis and rotation angle ;

[0171] In this application, the reference sub-image is selected based on the coordinates allocated above. The reference sub-image of the mold located in the middle has better lighting conditions and the extracted scale parameters are more accurate.

[0172] F2. Obtain the pre-configured outer ellipse scale range. and the range of the inner ellipse ,in, This is the minimum proportional parameter of the external ellipse. This is the maximum proportional parameter of the outer ellipse. This is the minimum scale parameter of the inner ellipse. The maximum proportion of the inner ellipse;

[0173] The radial position of the positioning feature (Mark) on the mold is relatively fixed, typically located within a certain proportional range from the center. This is determined by a pre-configured outer ellipse proportional range. and the range of the inner ellipse You can limit the search area.

[0174] Uniform width constraint for the annular region: This ensures that the width of the annulus between the inner and outer ellipses remains constant, facilitating subsequent comparisons of entropy at different ratios.

[0175] F3. Extract the outer contour ratio parameters of multiple steps from the outer ellipse ratio range and the inner ellipse ratio range respectively using a preset step size. and inner contour proportion parameters ;

[0176] Discretize the continuous proportional intervals, with the step size determining the fineness of the search (e.g., 0.01 or 0.02). Traverse all possible intervals using a grid search method. This combination avoids the problem of mismatched fixed parameters. The step size can be adjusted according to actual accuracy requirements, balancing real-time performance and positioning accuracy.

[0177] F4. For each step, the ellipse center of the mold ellipse based on the reference sub-image. Outer contour proportion parameters Inner contour proportion parameters The length of the major semi-axis of the mold ellipse of the reference sub-image The length of the minor semi-axis of the mold ellipse of the reference sub-image Rotation angle of the mold ellipse and the reference sub-image Calculate the outer ellipse and the inner ellipse The outer ellipse and the inner ellipse The mathematical expression is:

[0178]

[0179]

[0180] Since the mold ellipse and the Mark area are in an affine or perspective projection relationship, using the same center and rotation angle can ensure that the annular area is geometrically aligned with the mold, avoiding the omission of the Mark due to directional deviation.

[0181] F5, Based on the external ellipse and the inner ellipse Construct candidate annular regions;

[0182] This area precisely covers the radial range where Mark might appear, eliminating interference areas near the mold center and on the outer edge.

[0183] F6. Calculate the information entropy of regions within multiple candidate annular regions. The candidate annular region with the highest information entropy is selected as the annular region where the expected location of the localization feature is located.

[0184] Information entropy The expression is:

[0185]

[0186] In the formula, Indicates the first The probability of a gray level appearing within a circular area.

[0187] F7. Extract the target outer contour ratio parameters and target inner contour ratio parameters corresponding to the annular region of the reference sub-image, based on the ellipse center and semi-major axis length of the mold ellipse in each sub-image other than the reference sub-image. Length of the short half-axis and rotation angle Construct a ring-shaped region containing the expected location of the localization feature.

[0188] The method for constructing the annular region can refer to the method in the reference sub-image above. The above method of first calculating the annular region of the reference sub-image and then extracting the scale factor to extend to other sub-images reduces a heavy task that requires grid search for each sub-image (such as 100 entropy calculations) to only one search. The results of the remaining sub-images can be used directly, which greatly reduces the computational load while maintaining the positioning accuracy.

[0189] F8. Extract the contour pixel set in the annular region and calculate the zero-order moment of the contour pixel set. , First moment in the axial direction , First moment in the axial direction ;

[0190] These moments describe the quality and distribution of the contour points.

[0191] F9, Based on the zeroth order moment The above First moment in the axial direction The above First moment in the axial direction Calculate the center of the positioning feature , .

[0192] The moment method has an averaging effect on uneven distribution of contour points, and can still provide a stable center estimate even if the Mark edge is slightly incomplete due to lighting. This provides a reliable reference point for subsequent angle calculations.

[0193] G. Angle Calculation and Mold Closing Control: Determine the direction angle of the reference axis of the mold based on the center of the ellipse and the center of the positioning feature, and pair the upper mold and the lower mold based on the mold coordinates. Calculate the direction angle difference between the upper mold and the lower mold in the paired state, and control the upper mold to rotate and align with the lower mold based on the direction angle difference to complete the mold closing.

[0194] The angle calculation process includes:

[0195] G1, Construct a center vector based on the ellipse center and the positioning features. , ;

[0196] G2, Calculate the vector and Angle between axes and the included angle The direction angle serving as the reference axis of the mold. .

[0197] G3. For the sub-image sets of the upper model and the lower model, pairing is performed using pre-assigned coordinates;

[0198] G4. For any paired sub-image combination, calculate the difference in orientation angles between the upper and lower moduli. ,in, The direction angle of the upper mold. The direction angle of the lower die, and the difference in direction angles. This is the angle at which the upper mold needs to be rotated.

[0199] The above process directly uses the relative angle difference, eliminating the need for global benchmark calibration and automatically offsetting tray deflection and camera installation errors. Only vector angle and subtraction operations are required, making it suitable for real-time batch processing. It ensures that the thickness areas of the male and female molds match the pattern direction after mold assembly, guaranteeing automatic orientation and sinking of the lens when worn.

[0200] like Figure 12 As shown, this application also provides a machine vision-based fixed-axis liquid injection and mold closing control system, including:

[0201] The acquisition module is used to acquire the original image of the mold tray of the contact lens during the liquid injection and molding stage, wherein the original image includes the original image of the upper mold tray and the original image of the lower mold tray, and the original image is a grayscale image;

[0202] The segmentation module is used to segment the original image to obtain multiple mold sub-images and the mold coordinates corresponding to the multiple sub-images;

[0203] The coarse positioning module is used to extract the mold edge contour from the sub-image and fit the mold edge contour to obtain an elliptical mold and an elliptical center.

[0204] A fine positioning module is used to extract the annular region where the expected position of the positioning feature is located from the mold ellipse based on the center of the ellipse, and to extract the center of the positioning feature from the annular region, wherein the positioning feature is pre-set at the edge of the mold;

[0205] The alignment and mold closing control module is used to determine the direction angle of the reference axis of the mold based on the center of the ellipse and the center of the positioning feature, and to pair the upper mold and the lower mold based on the mold coordinates, calculate the direction angle difference between the upper mold and the lower mold in the paired state, and control the upper mold to rotate and align to the lower mold based on the direction angle difference to complete the mold closing.

[0206] This application presents a machine vision-based fixed-axis liquid injection mold-closing control method and system. Through image segmentation, ellipse fitting, and extraction of positioning feature centers, it accurately calculates the reference axis direction of each mold, solving the problem of traditional processes being unable to determine the mold's angular orientation due to the non-rotational symmetry of the pattern. Utilizing the angular difference between the upper and lower molds, the upper mold is controlled to rotate until it aligns with the lower mold, ensuring that the thickness area of ​​the lens after molding is consistent with the direction of the highlight pattern, meeting the functional requirement of automatic orientation and sinking during wear. Furthermore, this application is applicable to large-scale production scenarios, supporting simultaneous identification and pairing of multiple tray-type molds, automatically completing batch mold alignment, significantly improving production efficiency and reducing human error. It can overcome interference from mold dimensional tolerances, thermal expansion and contraction, and local distortion, stably extracting the ellipse center and positioning features to ensure high-precision axis alignment.

Claims

1. A machine vision-based method for controlling fixed-axis liquid injection mold closing, characterized in that, include: Obtain the original image of the mold tray of the contact lens during the liquid injection and molding stage, wherein the original image includes the original image of the upper mold tray and the original image of the lower mold tray, and the original image is a grayscale image; The original image is segmented to obtain multiple mold sub-images and the mold coordinates corresponding to the multiple sub-images; Extract the mold edge contour from the sub-image and fit the mold edge contour to obtain an elliptical mold and an elliptical center; Based on the center of the ellipse, extract the annular region where the expected position of the positioning feature is located from the mold ellipse, and extract the center of the positioning feature from the annular region, wherein the positioning feature is pre-set on the edge of the mold; The orientation angle of the reference axis of the mold is determined based on the center of the ellipse and the center of the positioning feature. The upper mold and the lower mold are paired based on the mold coordinates. The orientation angle difference between the upper mold and the lower mold in the paired state is calculated. Based on the orientation angle difference, the upper mold is rotated and aligned with the lower mold to complete the mold closing.

2. The machine vision-based fixed-axis liquid injection mold closing control method according to claim 1, characterized in that, The original image is segmented to obtain multiple mold sub-images and the corresponding mold coordinates of the multiple sub-images, including; The original image is preprocessed to obtain a preprocessed image, wherein the preprocessing includes grayscale conversion, Gaussian filtering, and grayscale stretching; The preprocessed image is subjected to target detection based on a pre-built target detection model to obtain multiple target detection results, wherein the target detection results include detection boxes, detection confidence scores, and target categories; Extract the target detection results whose target category is mold from the multiple detection results; The detection confidence of the target category "mold" is compared with a preset confidence threshold, and when the detection confidence is greater than or equal to the preset confidence threshold, a sub-image is extracted based on the detection box. Coordinates are assigned to multiple sub-images, and the coordinates of the sub-images are used as the corresponding mold coordinates.

3. The fixed-axis liquid injection mold closing control method based on machine vision according to claim 1, characterized in that, Extracting the mold edge contour from the sub-image includes: Extract the gradient magnitude of each pixel in the sub-image, and accumulate the gradient magnitude of each pixel along the horizontal and vertical directions to obtain the horizontal projection curve and the vertical projection curve; Extract two peaks from the horizontal projection curve that exceed a preset peak threshold, and extract two peaks from the vertical projection curve that exceed a preset peak threshold. Based on the four peaks, extend outward by a unit distance to obtain the left boundary, right boundary, upper boundary, and lower boundary. Based on the left boundary, right boundary, upper boundary, and lower boundary, shrink the sub-image to the ROI region to obtain the target region image. The target region image is sharpened based on preset image sharpening parameters to obtain a sharpened image. The sharpened image is subjected to adaptive binarization to obtain a binary image and contour features in the binary image; Extract geometric features from each contour feature in the binary image, wherein the geometric features include length, area, and aspect ratio; The geometric features in each contour feature are compared with the preset geometric feature filtering range, and the contour features whose geometric features meet the preset geometric feature filtering range are taken as the mold edge contour. The geometric feature filtering range includes length range, area range and aspect ratio range.

4. The machine vision-based fixed-axis liquid injection mold closing control method according to claim 1, characterized in that, Fitting the edge contour of the mold to obtain an elliptical mold and an elliptical center includes: Target points are selected from the mold edge contour based on gradient magnitude threshold and local orientation consistency, and a sampling weight is assigned to each target point. And configure the initial number of iterations. ; Based on the sampling weight of each target point and the initial number of iterations Multiple rounds of least-squares ellipse fitting iterations are performed on multiple target points to select the optimal ellipse, and a mold ellipse and ellipse center are constructed based on the optimal ellipse.

5. The fixed-axis liquid injection mold closing control method based on machine vision according to claim 4, characterized in that, Target points are selected from the mold edge contour based on gradient magnitude threshold and local orientation consistency, and a sampling weight is assigned to each target point. And configure the initial number of iterations. ,include: Obtain the gradient magnitude and gradient direction of each edge point in the mold edge contour, and calculate the average gradient of the entire preprocessed image; The screening threshold is constructed based on the average gradient of the entire graph; A neighborhood is constructed with the edge point as the center, and the gradient direction variance of all edge points in the neighborhood is calculated. Edge points that meet the target conditions are used as target points. The target conditions include a gradient magnitude greater than the filtering threshold and a gradient direction variance of all edge points in the neighborhood less than a preset direction variance threshold. Assign sampling weights to each target point Among them, sampling weight The mathematical expression is: In the formula, For target point gradient magnitude, For the target point The gradient direction variance of all edge points in the neighborhood of the center; Define the initial number of iterations Initial iteration count The mathematical expression is: In the formula, Indicates rounding up. The target confidence probability is set. The initial interior point scale is set. This represents the number of sampling points.

6. The machine vision-based fixed-axis liquid injection mold closing control method according to claim 4, characterized in that, Based on the sampling weight of each target point and the initial number of iterations Multiple rounds of least-squares ellipse fitting iterations are performed on multiple target points to select the optimal ellipse. Based on the optimal ellipse, a mold ellipse and its center are constructed, including: S1, based on sampling weights Sampling is performed to obtain a subset of target points; S2, perform weighted least squares ellipse fitting based on the target point subset and the sampling weight of each target point in the target point subset to obtain the candidate ellipse for the current iteration round; S3, calculate each target point The shortest geometric distance to the candidate ellipse is calculated, and the total error is obtained by summing all the shortest geometric distances. S4 compares the total error of the current round with the historical lowest total error; S5, when the total error of the current round is less than the historical lowest total error, take the target points whose shortest geometric distance is less than or equal to the preset distance threshold as interior points, and calculate the proportion of interior points in the current round. And based on the proportion of interior points in the current round. Update the iteration round and proceed to step S7, where if there is no total error in the previous round, update directly; S6. When the total error of the current round is greater than or equal to the historical lowest total error, proceed to step S7. S7. Return to step S1 until the latest iteration number is reached, or if there are M consecutive rounds in which the proportion of interior points has not been updated and the proportion of interior points exceeds the preset proportion threshold, the ellipse with the smallest total error among multiple iteration rounds is taken as the optimal ellipse. S8, take the optimal ellipse as the mold ellipse, and extract the ellipse center of the mold ellipse.

7. The fixed-axis liquid injection mold closing control method based on machine vision according to claim 1, characterized in that, Based on the center of the ellipse, extract the annular region containing the expected location of the positioning feature from the mold ellipse, including: Select the reference sub-image, the mold ellipse within the reference image, and the ellipse center; then extract the length of the major semi-axis of the mold ellipse from the reference image. Length of the short half-axis and rotation angle ; Obtain the pre-configured outer ellipse scale range and inner ellipse scale range; Extract the outer contour ratio parameters of multiple steps from the outer ellipse ratio range and the inner ellipse ratio range using a preset step size. and inner contour proportion parameters ; For each step, based on the center of the ellipse Outer contour proportion parameters Inner contour proportion parameters The length of the major semi-axis The length of the short semi-axis and the rotation angle Calculate the outer ellipse and the inner ellipse ; Based on the outer ellipse and the inner ellipse Construct candidate annular regions; calculate the information entropy of regions within multiple candidate annular regions. The candidate annular region with the largest information entropy is taken as the annular region where the expected location of the localization feature is located. Extract the target outer contour ratio parameters and target inner contour ratio parameters corresponding to the annular region of the reference sub-image, based on the ellipse center and semi-major axis length of the mold ellipse in each sub-image other than the reference sub-image. Length of the short half-axis and rotation angle Construct a ring-shaped region containing the expected location of the localization feature.

8. The machine vision-based fixed-axis liquid injection mold closing control method according to claim 1, characterized in that, Extracting the center of the positioning feature from the annular region includes: Extract the contour pixel set in the annular region and calculate the zeroth moment of the contour pixel set. , First moment in the axial direction , First moment in the axial direction ; Based on the zeroth moment The above First moment in the axial direction The above First moment in the axial direction Calculate the center of the positioning feature , .

9. The machine vision-based fixed-axis liquid injection mold closing control method according to claim 1, characterized in that, Determining the orientation angle of the mold's reference axis based on the center of the ellipse and the center of the positioning feature includes: A vector is constructed based on the center of the ellipse and the center of the positioning feature. , ; Calculate the vector and Angle between axes and the included angle The direction angle serving as the reference axis of the mold. .

10. A machine vision-based fixed-axis liquid injection and mold closing control system, characterized in that, include: The acquisition module is used to acquire the original image of the mold tray of the contact lens during the liquid injection and molding stage, wherein the original image includes the original image of the upper mold tray and the original image of the lower mold tray, and the original image is a grayscale image; The segmentation module is used to segment the original image to obtain multiple mold sub-images and the mold coordinates corresponding to the multiple sub-images; The coarse positioning module is used to extract the mold edge contour from the sub-image and fit the mold edge contour to obtain an elliptical mold and an elliptical center. A fine positioning module is used to extract the annular region where the expected position of the positioning feature is located from the mold ellipse based on the center of the ellipse, and to extract the center of the positioning feature from the annular region, wherein the positioning feature is pre-set at the edge of the mold; The alignment and mold closing control module is used to determine the direction angle of the reference axis of the mold based on the center of the ellipse and the center of the positioning feature, and to pair the upper mold and the lower mold based on the mold coordinates, calculate the direction angle difference between the upper mold and the lower mold in the paired state, and control the upper mold to rotate and align to the lower mold based on the direction angle difference to complete the mold closing.

Citation Information

Patent Citations

  • Liquid injection and mold closing method and system for contact lens astigmatism sheet

    CN119635940A