Edge equipment contact lens edge defect detection system based on gRPC and YOLOv11

By using an edge device detection system based on gRPC and an improved YOLOv11 algorithm, the efficiency and accuracy issues of contact lens edge defect detection have been resolved. This system enables efficient and accurate defect detection and real-time quality monitoring, thereby improving production efficiency and product quality.

CN121883430APending Publication Date: 2026-04-17SIGMA SQUARES (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SIGMA SQUARES (BEIJING) TECH CO LTD
Filing Date
2025-12-31
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Current methods for detecting edge defects in contact lenses mainly rely on manual visual inspection, which is inefficient and produces inaccurate and inconsistent results, making it difficult to meet the needs of high-efficiency production, especially in terms of accuracy and robustness in detecting minute defects.

Method used

An edge device detection system based on gRPC and an improved YOLOv11 algorithm is adopted, including preprocessing, coarse detection and localization, edge detection and post-processing modules. It combines the improved YOLOv11 model for defect detection and improves detection accuracy and efficiency through the improved C2f_SimAM and TVConv modules.

Benefits of technology

It enables rapid and accurate detection of defects at the edge of contact lenses, improving detection efficiency and accuracy, reducing production costs, ensuring production quality, and performing real-time statistical analysis to improve the monitoring of yield and defect rates on the production line.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121883430A_ABST
    Figure CN121883430A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of machine vision, in particular to an edge equipment contact lens edge defect detection system based on gRPC and YOLOv11, which gives consideration to the detection precision and the output efficiency, can quickly and accurately position and classify targets in images, and provides powerful technical support for sorting equipment. By applying machine vision and the improved YOLOv11 algorithm to the contact lens edge flaw detection system, the advantages of the machine vision and the improved YOLOv11 algorithm can be fully exerted, and efficient and accurate detection of the contact lens edge flaw is realized. Therefore, the detection efficiency can be improved, the production cost can be reduced, the detection accuracy and reliability can be improved, the product quality problem caused by errors of manual detection is effectively avoided, and a powerful guarantee is provided for the production quality of contact lenses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine vision, specifically an edge device contact lens edge defect detection system based on gRPC and YOLOv11. Background Technology

[0002] In automated contact lens inspection equipment, edge defect detection based on machine vision has always been a key focus and challenge. Edge defects in contact lenses (such as notches, burrs, irregular shapes, cracks, etc.) are typically tiny (some defect detection indicators are less than 0.1mm), and the edges themselves may fluctuate due to solution effects, requiring the inspection system to have extremely high spatial resolution and algorithm robustness. Simultaneously, for production demands, production line speeds can reach tens of lenses per minute, requiring the algorithm to complete detection in milliseconds. Furthermore, the material, thickness, and curvature of lenses from different manufacturers may vary slightly, and the system must adapt to these variations without compromising detection accuracy.

[0003] Traditional contact lens edge defect detection mainly relies on manual visual inspection, which has many limitations. Manual inspection is not only inefficient and difficult to meet the needs of large-scale production, but it is also easily affected by the subjective factors of the inspectors, resulting in poor accuracy and consistency of the inspection results. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide an edge device contact lens edge defect detection system based on gRPC and YOLOv11 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 an edge device contact lens edge defect detection system based on gRPC and YOLOv11, comprising:

[0007] The preprocessing module is used to acquire images of contact lenses from the current production batch and to locate the contact lens images to obtain carrier positioning information.

[0008] The coarse detection and positioning module is used to extract the positioning image from the contact lens image based on the vehicle positioning information, and to perform coarse detection and positioning on the contour features in the positioning image to obtain the coarse detection and positioning result.

[0009] An edge detection module is used to detect the edge of the contact lens in the contact lens image based on the coarse detection positioning result when the coarse detection positioning result matches the pre-configured feature inspection parameters, and to obtain an edge detection result. The edge detection result includes whether there is a defect region. When a defect region is included, the edge detection result also includes the defect features of the defect region.

[0010] The post-processing module is used to perform type analysis on the edge detection results to obtain the defect type; and to perform post-processing on the coarse detection positioning results and defect types of the contact lens images of the current production batch to obtain structured detection information.

[0011] The statistical analysis module is used to perform batch quality statistics and defect feedback analysis on the structured inspection information of the contact lens images of the current production batch, and obtain statistical analysis results.

[0012] In one embodiment of this application, the edge detection results are subjected to type analysis to obtain the defect type; and the coarse inspection results, positioning results, and defect types of the contact lens images of the current production batch are post-processed to obtain structured detection information, including:

[0013] The values ​​of multiple defect parameters in the defect feature are compared with the defect definitions of multiple pre-constructed defect types, wherein the defect definitions include reference value ranges for multiple defect parameters; when the values ​​of multiple defect parameters in the defect feature match the defect definition of any one target defect type, the defect feature is determined to be a target defect type; when the values ​​of multiple defect parameters in the defect feature do not match the defect definition of any one target defect type, the defect feature is determined to be a defect type of the interference category.

[0014] For each contact lens image, if the coarse detection localization result is not passed, or if the edge detection result shows a defective area, the corresponding defect type defect code is assigned to the detection information, and the contact lens image is labeled based on the coarse detection localization result or the edge detection result. Structured detection information is constructed by combining the detection information and the labeled contact lens image.

[0015] In one embodiment of this application, structured inspection information of contact lens images from the current production batch is used to perform batch quality statistics and defect feedback analysis to obtain statistical analysis results, including:

[0016] Data statistics are obtained by performing edge detection on the contact lens images of the current production batch; abnormal data are accumulated for the coarse inspection results of the contact lens images of the current production batch that do not contain lenses, and an alarm is triggered when the accumulated number exceeds a preset threshold.

[0017] A defect type statistical list is constructed based on the defect type analysis results of the images of contact lenses from the current production batch. The defect type statistical list includes cumulative statistical results of multiple defect types and is used to optimize the contact lens manufacturing process.

[0018] In one embodiment of this application, the coarse detection and localization result includes elliptical contour information. Based on the localization information, the edge of the contact lens in the contact lens image is detected to obtain an edge detection result, including:

[0019] The contact lens image is cropped based on the elliptical contour information to obtain a single object image;

[0020] The single object image is transformed into polar coordinates to obtain a single object polar coordinate image.

[0021] Inference is performed on the single object image and the single object polar coordinate image based on a pre-built improved YOLOv11 model to obtain inference results, wherein the inference results include the object's rotation matrix information, confidence information and detection category information;

[0022] Feature extraction is performed on the reasoning results to obtain defect features, wherein the defect features include grayscale features and geometric features.

[0023] In one embodiment of this application, the improved YOLOv11 model is obtained by training a pre-built improved YOLOv11 network using training data. The method for constructing the improved YOLOv11 network includes:

[0024] The improved YOLOv11 network is obtained by replacing the C2PSA module in the backbone network with the C2f_SimAM module and replacing the C3k2 module with the TVConv module. The C2f_SimAM module is a C2f module that incorporates a similarity attention mechanism, the mathematical expression of which is:

[0025]

[0026] In the formula, Indicates the input feature map, This represents a feature map that incorporates attention weights. This represents the Sigmoid activation function. The L1 norm of the feature map is represented. This indicates the number of color channels in the feature map. Indicates the height of the feature map. Indicates the width of the feature map. and All of these represent learnable parameters.

[0027] In one embodiment of this application, feature extraction is performed on the reasoning result to obtain defect features, including:

[0028] The detection boxes that meet the target conditions in the inference results are taken as target detection boxes, wherein the target conditions include a size greater than a preset size threshold and a confidence level greater than a preset confidence threshold.

[0029] For the detection box generated based on the polar coordinate image of the single object, perform an inverse polar coordinate transformation on the vertex coordinates of the detection box to obtain the vertex coordinates and the detection box in the image coordinates.

[0030] Based on the detection box in image coordinates, an example image of object grayscale information is extracted from the contact lens image, and defect features are extracted from the example image of object grayscale information extraction, wherein the defect features include grayscale features and geometric features.

[0031] In one embodiment of this application, an example image of object grayscale information is extracted from the contact lens image based on a detection box in image coordinates, and defect features are extracted from the example image of object grayscale information, including:

[0032] Based on rotation matrix and the coordinates of the center point of the ellipse Vertex coordinates in image coordinates Perform a rotation transformation to obtain the vertex coordinates after the rotation transformation. Wherein, the vertex coordinates after the rotation transformation The mathematical expression is:

[0033]

[0034] From the vertex coordinates after the rotation transformation Extract Maximum value in direction and minimum value , Maximum value in direction and minimum value ;

[0035] Based on the above Maximum value in direction and Maximum value in direction Construct the coordinates of the top right corner of the rectangle and based on the Minimum value of direction and Minimum value of direction Construct the coordinates of the bottom left corner of the rectangle ; and based on the coordinates of the upper right corner point and the coordinates of the lower left corner point Construct a regular rectangle;

[0036] The single object image is binarized to obtain a single object binarized image; and the single object image and the single object binarized image are cropped based on the regular rectangle to obtain an object image and an object binarized image.

[0037] Gray-scale features and geometric features are extracted from the object image and the object binary image, respectively. The gray-scale features include average gray-scale and maximum gray-scale. The geometric features include contour fullness, contour aspect ratio, and contour smoothness.

[0038] In one embodiment of this application, the contact lens image is a grayscale image, wherein locating the contact lens image to obtain vehicle positioning information includes:

[0039] The contact lens image is binarized based on a preset fixed threshold to obtain a binary image;

[0040] The vehicle region is extracted from the binary image, and a positioning bounding box for the vehicle region is generated to obtain positioning information, wherein the positioning information includes the center coordinates of the positioning bounding box, the width of the positioning bounding box, and the height of the positioning bounding box.

[0041] In one embodiment of this application, the coarse detection and localization result includes a localization result and a coarse detection result. Coarse detection and localization are performed on the contour features in the localization image to obtain the coarse detection and localization result, including:

[0042] The positioning image is processed by a flood filling algorithm to obtain a binarized image;

[0043] Contour extraction is performed on the binarized image to obtain multiple contour features; a rotating rectangle with multiple contour features is generated; and the contour features of the rotating rectangle with a length greater than a preset length threshold and a width greater than a preset width threshold are saved as target contour features.

[0044] The saved target contour is drawn onto a blank image, and the largest contour is selected. The contour outer envelope method is then applied to the largest contour to obtain the outer contour.

[0045] Ellipse fitting is performed on the outer contour to obtain a fitted ellipse; and the ellipse contour information of the fitted ellipse is extracted, wherein the fitted ellipse is the positioning result, and the ellipse contour information includes the ellipse center, major axis and minor axis;

[0046] The ellipse contour information is verified based on pre-configured ellipse feature inspection parameters to obtain a coarse inspection result, which includes size discrepancy, no product, and inspection passed.

[0047] In one embodiment of this application, the statistical analysis module is configured in an edge device, and the coarse inspection results and defect type analysis results of the contact lens images of the current production batch are sent to the edge device via the gRPC protocol.

[0048] The beneficial effects of this application are as follows: This application discloses an edge device contact lens edge defect detection system based on gRPC and YOLOv11. This application balances detection accuracy and output efficiency, enabling rapid and accurate localization and classification of targets in images, providing strong technical support for sorting equipment. By applying machine vision and the improved YOLOv11 algorithm to the contact lens edge defect detection system, the advantages of both can be fully utilized to achieve efficient and accurate detection of contact lens edge defects. This not only improves detection efficiency and reduces production costs, but also enhances detection accuracy and reliability, effectively avoiding product quality problems caused by errors in manual inspection, and providing strong assurance for the production quality of contact lenses. In addition, this application statistically analyzes the defect results during the production process, thereby extracting the yield rate, abnormality rate, and high-frequency defect types of the production line in real time, providing a data basis for adjusting the contact lens production line. Attached Figure Description

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

[0050] Figure 1 This is an application scenario diagram of an edge device contact lens edge defect detection system based on gRPC and YOLOv11, as shown in one embodiment of this application;

[0051] Figure 2 This is a structural diagram of an edge device contact lens edge defect detection system based on gRPC and YOLOv11, as shown in one embodiment of this application.

[0052] Figure 3 This is a schematic diagram of the initialization configuration process in one embodiment of this application;

[0053] Figure 4 This is a schematic diagram of the preprocessing flow in one embodiment of this application;

[0054] Figure 5 This is a flowchart illustrating the coarse detection and localization process in one embodiment of this application;

[0055] Figure 6 This is a flowchart of edge defect detection based on the improved YOLOv11 in one embodiment of this application;

[0056] Figure 7 This is a schematic diagram of the feature analysis process in one embodiment of this application;

[0057] Figure 8This is a flowchart of the comprehensive result analysis in one embodiment of this application;

[0058] Figure 9 This is a flowchart illustrating the final result analysis of the detected image in one embodiment of this application;

[0059] Figure 10 This is a flowchart illustrating the production batch data statistics in one embodiment of this application;

[0060] Figure 11 This is a flowchart of defect feedback analysis in one embodiment of this application. Detailed Implementation

[0061] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.

[0062] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the layers related to this application and are not drawn according to the actual number, shape and size of the layers in the actual implementation. In the actual implementation, the form, number and proportion of each layer can be arbitrarily changed, and the layer layout may also be more complex.

[0063] Numerous details are explored in the following description to provide a more thorough explanation of embodiments of this application; however, it will be apparent to those skilled in the art that embodiments of this application may be practiced without these specific details.

[0064] Figure 1 This is an application scenario diagram of an edge device contact lens edge defect detection system based on gRPC and YOLOv11, as shown in one embodiment of this application. Figure 1 As shown, in this application, an industrial camera is used to photograph the contact lens product to obtain a corresponding grayscale image; the image is transmitted to an industrial control computer and preliminarily processed by the industrial control computer, and then forwarded to an edge device for defect detection, obtaining relevant detection results and uploading them to the cloud service processing center. Finally, the cloud service processing center collects and sends the edge defect detection results of the lens to the client or the subsequent detection data processing center.

[0065] Figure 2 This is a structural diagram of an edge device contact lens edge defect detection system based on gRPC and YOLOv11, as shown in one embodiment of this application. Figure 2As shown in this embodiment, an edge device contact lens edge defect detection system based on gRPC and YOLOv11 includes:

[0066] A. Configuration Module: Responsible for initializing the detection system, including reading configuration files, loading algorithm and system parameters (Pars), and loading bright-field images captured by the camera. And loading the corresponding detection model, etc.

[0067] B. Preprocessing module, used to acquire the original image of the contact lens, and to preprocess the original image of the contact lens to obtain the contact lens image. ; and the contact lens image Perform positioning to obtain vehicle location information;

[0068] The preprocessing module is responsible for... The secondary processing is performed to reduce image noise and highlight flaw details.

[0069] C. Coarse detection and positioning module, used to extract positioning images from the contact lens images based on the vehicle positioning information, and to perform coarse detection and positioning on the contour features in the positioning images to obtain coarse detection and positioning results (including coarse detection results and positioning results).

[0070] The coarse detection and lens positioning module uses the vehicle positioning information obtained in section B and processes the image data to perform [the following]. Edge extraction and localization are performed. From the contour information obtained from the localization results, ellipse fitting is performed on the contour (the images of contact lenses in water are basically ellipses), and the geometric ellipse information of the lens is obtained. Combining with A Therefore, the test results A preliminary inspection is conducted to check the lens size and for any obvious defects.

[0071] D. Edge detection module, used to detect the edge of the contact lens in the contact lens image based on the positioning information when the positioning result matches the pre-configured feature inspection parameters, and obtain an edge detection result, wherein the edge detection result includes whether there is a defect region, and when a defect region is included, the edge detection result also includes the defect features of the defect region;

[0072] If the coarse detection module in C passes, the geometric information obtained from the positioning information (i.e., the elliptical contour information) in C is used. , Image cropping and edge polar coordinate image Generation. For the image generated in C, use the relevant model to locate and identify defects. If defects exist, store them and calculate the feature for each defect. The feature contains geometric and color information, such as length and width, aspect ratio, average gray level, and maximum gray level.

[0073] E. Post-processing module, used to perform type analysis on the edge detection results to obtain the defect type; and to post-process the coarse inspection results, positioning results and defect types of the contact lens images of the current production batch to obtain structured detection information;

[0074] Specifically, using For each The information is analyzed and judged, and then packaged into... .

[0075] F. Statistical Analysis Module: This module is used to perform batch quality statistics and defect feedback analysis on the structured inspection information of contact lens images in the current production batch, and obtain statistical analysis results.

[0076] The following are the implementation methods of each functional module in the specific embodiments of this application:

[0077] A. Initialization Configuration Module: Responsible for initializing the detection system and loading preset system parameters. Load the bright-field image data of the contact lens captured by the camera as... .

[0078] Figure 3 This is a schematic diagram of the initialization configuration process in one embodiment of this application, as shown below. Figure 3 As shown, the initialization configuration process in this application includes:

[0079] A1. Read the configuration file. The configuration table consists of three parts: the first is the system preset configuration, which includes size parameters, system settings, etc.; the second part is the meta information, which includes the location information of defects and detection parameters, including features. Color and geometric information, such as minimum detection area Shortest detection size Detection density range Detect the aspect ratio range Detect the contour smoothness range Detect grayscale value range The third is the model configuration parameters, including the confidence threshold for each object detected by the model and the model path, etc.

[0080] 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... ;

[0081] A3. Load the relevant parameters from A1, including size parameters such as the longest diameter range. Shortest diameter interval Maximum tolerance threshold for lens major and minor axes Lens aspect ratio wait.

[0082] A4. Initialize the detection results. Initialize the detection results for each part, mainly including the positioning detection results. Edge defect detection results Overall results of contact lens wait.

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

[0084] Figure 4 This is a schematic diagram of the preprocessing flow in one embodiment of this application, as shown below. Figure 4 As shown, the preprocessing procedure in this application includes:

[0085] B1. Perform Gaussian filtering on the contact lens image to obtain a filtered image;

[0086] Specifically, contact lens images Performing verification The Gaussian filtering process is used to obtain the filtered image, with the aim of reducing interference from environmental noise.

[0087] B2. Sharpen the filtered image to obtain the contact lens image.

[0088] An image sharpening algorithm is applied to the filtered image to highlight edge information, thereby revealing details of imperfections. This yields the contact lens image. .

[0089] B3. Binarize the contact lens image based on a preset fixed threshold to obtain a binary image; extract the vehicle region from the binary image and generate a positioning bounding box for the vehicle region to obtain positioning information, wherein the positioning information includes the center coordinates of the positioning bounding box, the width of the positioning bounding box, and the height of the positioning bounding box.

[0090] Specifically, the contact lens image output by B2 Vehicle localization in the image is performed using fixed-threshold binarization. Then, the foreground is extracted to generate bounding boxes, and information from these bounding boxes is used as the localization information. ,in, The coordinates of the center of the positioning frame. Indicates the width of the positioning box. This indicates the height of the positioning box.

[0091] C. Coarse detection and positioning module, through... The process involves further extracting the lens image edge contour information from the vehicle positioning information obtained from B, and then generating the lens geometry information Geo through ellipse fitting. Finally, combined with Pars from A, Geo is used to detect obvious defects such as lens size and presence.

[0092] Figure 5 This is a flowchart illustrating the coarse detection and localization process in one embodiment of this application, as shown below. Figure 5 As shown, the coarse detection and localization process in this application includes:

[0093] C1. Based on the positioning information, crop the contact lens image to obtain a positioning image; and process the positioning image using a flood fill algorithm to obtain a binarized image;

[0094] Specifically, the image generated by A Use Loc in B to crop the image. Then, the positioning image generated in C1... The flood filling algorithm is used for processing, with a minimum threshold of a and a minimum span of Δ, to generate a binary image bin.

[0095] C2. Extract contours from the binarized image to obtain multiple contour features; generate a rotating rectangle with multiple contour features; and save the contour features of the rotating rectangle with a length greater than a preset length threshold and a width greater than a preset width threshold as the target contour features.

[0096] Specifically, contours are extracted from the bin image, and contours that meet the criteria are filtered using the minimum rotation rectangle and stored. The filtering criteria are: This means that both sides of its rotated rectangle must be greater than a certain threshold.

[0097] C3, Judgment If the length is 0, it indicates that no lens was acquired; set... If the result is "No product", exit the entire testing process and proceed to step F; otherwise, continue.

[0098] C4. Draw the saved target outline onto the blank image and filter out the largest outline;

[0099] Specifically, the outline stored in C2 is drawn onto the blank image Pad, with its size and positioning image... same.

[0100] C5. Apply the contour outer envelope method to the maximum contour to obtain the outer contour;

[0101] Perform contour extraction on Pad again to find its maximum contour, and then apply the contour outer envelope method to this maximum contour to obtain its outer contour. ;

[0102] C6. Perform ellipse fitting on the outer contour to obtain a fitted ellipse (the fitted ellipse here is the positioning result when the lens is detected); and extract the ellipse contour information of the fitted ellipse, wherein the ellipse contour information includes the ellipse center, major axis and minor axis.

[0103] right Perform ellipse fitting to obtain the corresponding ellipse information, including the ellipse center. Major / minor axis ( ).

[0104] C7. Verify the ellipse contour information based on the pre-configured ellipse feature inspection parameters to obtain a coarse inspection result, wherein the coarse inspection result includes size mismatch, no product, and inspection passed.

[0105] Specifically, using a The ellipse information generated by C6 is verified, and its size is determined. and If all are smaller than the minimum detection size configured in A, then Set to "Size Mismatch"; if neither of the above two conditions (including "No Product" in step C3) is met, then Set to "Detection passed"; the expression is as follows:

[0106]

[0107] D. Edge detection module: If the positioning module in C passes, use the object geometry information obtained in C. right Image cropping and polar coordinate images The two generated images are then used to locate and identify defects using an improved YOLOv11 model. If edge defects exist, they are stored and their features are calculated for each defect. , It contains geometric and color information, such as length and width, outline smoothness, average gray level, and maximum gray level.

[0108] Figure 6 This is a flowchart of an embodiment of edge defect detection based on the improved YOLOv11, as shown below. Figure 6 As shown, the edge defect detection process includes:

[0109] D1. When the coarse inspection result is "pass", the contact lens image is cropped based on the elliptical contour information to obtain a single object image; and the single object image is transformed by polar coordinates to obtain a single object polar coordinate image.

[0110] First, initialize the relevant storage space, such as the model result array. The image is then cropped using the lens geometry information generated in C to obtain a single-object image. Combining as well as Perform polar coordinate transformation to generate a polar coordinate image of a single object. The expression is as follows. Finally, and Perform image transformation and set the size to 768x768;

[0111]

[0112] In the polar coordinate system, the horizontal axis represents the polar angle, and the vertical axis represents the polar radius. The polar coordinate reference formula is: Set sampling angle The number of samples can be obtained The interpolation method is nearest neighbor interpolation. In practice, the interpolation method can be replaced with bilinear interpolation, cubic interpolation, etc.

[0113] D2. Based on the pre-built improved YOLOv11 model, inference is performed on the single object image and the single object polar coordinate image to obtain the inference result;

[0114] In this application, an improved YOLOv11 model is used to generate D1. and Perform model inference and obtain the inference result res.

[0115] The model in this application is an improved YOLOv11 model. Based on the native YOLOv11 architecture, we have optimized it specifically for industrial testing scenarios involving wet contact lens inspection.

[0116] Building upon the native architecture, we innovatively upgraded the model operator layer twice at the backbone level, specifically for the industrial inspection scenario of wet contact lens testing. Firstly, the C2PSA module was improved to C2f_SimAM, incorporating both channel and spatial attention mechanisms. Secondly, the C3k2 module was upgraded to TVConv (Translation Variant Convolution) at the backbone level. The corresponding OBB output includes information about the object's rotation rectangle. Confidence information and detection category information The expression is as follows:

[0117]

[0118] Specifically, the upgrades for the operators are as follows:

[0119] The C2f module is a key design element in YOLOv8 used to optimize the backbone network. Its core idea originates from the local feature preservation strategy of CSPNet. By dividing the network layers into multiple stages and introducing cross-layer connections within each stage, it achieves efficient feature map fusion and information transfer. SimAM (Simple Gated Attention Module) is a lightweight attention mechanism. Its core lies in jointly optimizing the channel and spatial dimensions of the feature map through an adaptive gating mechanism. Compared to traditional attention mechanisms, SimAM simplifies the computation process, significantly reducing computational overhead while maintaining performance. Its expression is as follows.

[0120]

[0121] In the formula, Indicates the input feature map, This represents a feature map that incorporates attention weights. This represents the Sigmoid activation function. The L1 norm of the feature map is represented. This indicates the number of color channels in the feature map. Indicates the height of the feature map. Indicates the width of the feature map. and All of these represent learnable parameters.

[0122] This mechanism captures statistical information between channels through global mean pooling and dynamically adjusts feature weights through a gating function.

[0123] In the current scenario of contact lens edge defect detection, the combination of the C2f module and SimAM forms a C2f-SimAM composite structure, and its synergistic effect is reflected in the following aspects:

[0124] Feature representation is enhanced. C2f ensures the full fusion of multi-scale features through cross-stage connections, while SimAM further highlights the features of key target areas and suppresses redundant information through joint modulation of channel and spatial attention.

[0125] Balance of computational efficiency: C2f's local feature preservation strategy reduces redundant computation, while SimAM's lightweight design avoids the high overhead of traditional attention mechanisms.

[0126] Improved robustness: Through spatial adaptive adjustment of SimAM, the model's adaptability to abnormal industrial scenarios such as occlusion is significantly enhanced.

[0127] In summary, compared to the C2PSA module, C2f-SimAM performs better in small-size detection scenarios such as edge defects, especially for polar coordinate-based transformed images. Since transformed images may cause some interference and deformation to the original image defects, the C2f-SimAM operator has better feature representation capabilities in this regard, and can achieve better detection results.

[0128] Furthermore, by upgrading the C3k2 module to TVConv, a two-stage layout awareness mechanism was implemented. First, the learnable affinity map is generated using a lightweight convolutional network with a 5×5 local receptive field, and a spatial relationship descriptor is formed through softmax normalization. This affinity map can be viewed as a measure of the similarity between pixels in a local region, and its learning objective is to capture the topological relationships of key layout features such as object edges and textures. Second, the weight generation block uses a single-layer fully connected network to map the spatial statistical features of the affinity map to dynamic convolutional kernel parameters.

[0129] Furthermore, TVConv's weight generation process features "optimization during training and solidification during inference"—during training, the affinity graph is updated to generate the network through backpropagation, while during inference, only the convolutional kernel parameters corresponding to each spatial location need to be pre-computed and cached. This makes its computational cost during inference equivalent to that of standard convolution, while achieving high parameter efficiency. TVConv explicitly encodes local spatial relationships through affinity graphs, enabling convolutional kernels at different locations to capture position-sensitive feature responses. For example, in detection scenarios, this feature can enhance the model's spatial perception of target edges and background boundaries, resulting in better rendering and detection capabilities for edge defects in contact lens images.

[0130] The upgrades to the two operators mentioned above are based on our current industrial testing scenario for wet contact lenses. These upgrades further improve the overall testing accuracy of the system while ensuring testing efficiency and production capacity requirements. Furthermore, compared to the native C2PSA and C3k2 operators, our upgraded operators can further compress the model size, reducing model storage requirements by approximately 5%, thus simplifying the porting to edge devices.

[0131] The training process based on the improved YOLOv11 model includes:

[0132] (1) Obtain a sample image, wherein the sample image is a single contact lens image with edge defects or a single contact lens coordinate image;

[0133] (2) The sample images are labeled to obtain training samples, wherein the labeling information is the rotation matrix information, confidence information and detection category information of the defective region;

[0134] (3) The improved YOLOV11 network is trained based on the training samples to obtain the improved YOLOV11 model.

[0135] During training, with a learning rate of 0.001, a batch size of 32, and 300 iterations, the model achieved good performance on the test set, with a detection accuracy of over 97.2%, and high recall and F1 score.

[0136] Based on the relevant parameters configured in A, the two images generated in D1 are detected using a detection model. Two sets of detection results (res) are then generated. After obtaining the detection results, the detection boxes that meet the target conditions in the inference results are taken as target detection boxes. The target conditions include a size greater than a preset size threshold and a confidence level greater than a preset confidence level threshold. First, a filtering process is performed to select detection boxes that meet the basic size and confidence level requirements. This system sets the minimum detection size to 5 pixels and the confidence level to 0.4.

[0137] Store test results that meet the basic detection requirements. middle.

[0138] For the detection box generated based on the polar coordinate image of the single object, perform an inverse polar coordinate transformation on the vertex coordinates of the detection box to obtain the vertex coordinates and the detection box in the image coordinates.

[0139] Specifically, for images transformed in polar coordinates During result storage, the corresponding sample count and ellipse geometry information Geo in D1 are correlated. Specifically, for the rotated rectangle generated by the model, its four vertices are further obtained, and the four vertices of the rectangle are located. Perform an inverse polar coordinate transformation on the above four vertices to map them to the image coordinate system. The transformation formula is as follows:

[0140]

[0141] in, All of these are the geometric parameters of the fitted ellipse obtained in C. The number of samples in C. As vertices coordinate, Transform the corresponding vertices to the image coordinate system The coordinates.

[0142] Furthermore, remapping () is a rotated rectangle And store the rotated rectangle. middle.

[0143] D3, if D2 is successful If empty, it means the model did not detect edge defects. (Setting...) If the result is "Good", exit to F; otherwise, proceed to D4.

[0144] D4. Then, feature extraction is performed on the reasoning results to obtain defect features.

[0145] Based on the detection box in image coordinates, an example image of object grayscale information is extracted from the contact lens image, and defect features are extracted from the example image of object grayscale information extraction, wherein the defect features include grayscale features and geometric features.

[0146] Specifically, for Each detection box in the image is processed cyclically, and the corresponding rectangular image M is extracted as an example image for object grayscale information extraction. The rotated rectangle is converted into a regular rectangle as follows:

[0147] (1) Convert angles to radians and set the rotation matrix;

[0148] (2) Define the coordinates P of the four vertices of the unrotated rectangle relative to the center point;

[0149]

[0150] (3) Based on rotation matrix and the coordinates of the center point of the ellipse Vertex coordinates in image coordinates Perform a rotation transformation to obtain the vertex coordinates after the rotation transformation. Wherein, the vertex coordinates after the rotation transformation The mathematical expression is:

[0151]

[0152] Specifically, the four points in b) are transformed using a rotation matrix, and the coordinates of the center point are offset to obtain the four rotated vertices. :

[0153]

[0154] (4) Vertex coordinates after the rotation transformation Extract Maximum value in direction and minimum value , Maximum value in direction and minimum value ;

[0155] (5) Based on the above Maximum value in direction and Maximum value in direction Construct the coordinates of the top right corner of the rectangle and based on the Minimum value of direction and Minimum value of direction Construct the coordinates of the bottom left corner of the rectangle ; and based on the coordinates of the upper right corner point and the coordinates of the lower left corner point Construct a regular rectangle;

[0156] (6) Image of the single object Binarization is performed to obtain a binarized image of a single object. ; and based on the regular rectangle, respectively, the single object image is processed. The object image and the object binary image are cropped together to obtain the object image and the object binary image. ;

[0157]

[0158]

[0159] (7) Extract grayscale features and geometric features from the object image and the object binary image respectively, wherein the grayscale features include average grayscale and maximum grayscale; the geometric features include contour fullness, contour aspect ratio and contour smoothness.

[0160] Specifically, regarding (6) Based on the corresponding binary image Extract the corresponding grayscale information Such as average gray level Maximum grayscale And so on, combining the corresponding detection frame information to generate corresponding defect information. And store to In the middle. At the same time, according to Extract the corresponding contour to generate relevant geometric information, which includes (Contour fullness), (Aspect ratio of the outline) (Contour smoothness), etc.

[0161] E. Post-processing module, using Pars for each The information is analyzed and judged, and then packaged as a Defect.

[0162] Figure 7 This is a schematic diagram of the feature analysis process in one embodiment of this application, as shown below. Figure 7 As shown, the process analysis includes the following steps:

[0163] E1. Compare the values ​​of various defect parameters in the defect feature with the defect definitions of various pre-constructed defect types, wherein the defect definitions include a reference range of values ​​for various defect parameters;

[0164] When the values ​​of multiple defect parameters in the defect feature match the defect definition of any target defect type, the defect feature is determined to be a target defect type; when the values ​​of multiple defect parameters in the defect feature do not match the defect definition of any target defect type, the defect feature is determined to be a defect type of the interference category.

[0165] Specifically, first, the current configuration is loaded from the Pars information obtained from A, and then the configuration in D is... Each of them Filter the data and finally encapsulate the results into... middle. Information loading: It includes defect attributes, including various defect names and their corresponding geometric and color information. The Pars data is then assigned to new variables. Apply it.

[0166] pass The obtained parameter pair Perform filtering and analysis, and encapsulate the results into defects. middle. for A higher level of encapsulation, containing defect attributes. and characteristics Two parts. Stored in The classification results information after analysis The middle part contains the feature geometry and color information mentioned in A11.

[0167] right Each of them Perform the traversal. Using one... For example, based on the detection type obtained from D Find the corresponding Data, such as this type of defect not in In the middle, it is believed that such flaws are deliberately overlooked. It is judged as a distracting defect, and the defect category is set to "distracting". If not empty, then the current... Based on the defect attributes obtained from the corresponding defect type, filtering and classification are performed. If the conditions are met, the defect category is set to the corresponding detected defect category, i.e. If the conditions are not met, the defect category is set to "interference". .

[0168] Furthermore, The principle is as follows: by judging Are the various geometric and color information in the data present? Within the range of geometric and color information for each defect, if all information is satisfied, it is determined to be the corresponding defect, and the result is encapsulated into... If the condition is not met, skip the current defect and proceed to the next defect judgment, until all defects have been traversed. Each of t Some relevant expressions are as follows:

[0169]

[0170]

[0171] It is foreseeable that there may be more than one type of defect in the lens. Therefore, a single lens is repackaged, and its "defect" data package consists of a list whose length is the number of detected defects. Each single element in the list is a defect.

[0172] E2. For each contact lens image, if the localization result is not passed, or if the edge detection result shows a defective area, the corresponding defect type defect code is assigned to the detection information, and the contact lens image is labeled based on the localization result or the edge detection result. Structured detection information is constructed by combining the detection information and the labeled contact lens image.

[0173] The purpose of step E2 is to summarize and organize the defects, and to be responsible for the positioning results of the above-mentioned components. Model coarse test results Comprehensive results of the test items By combining the defect severity profile for comprehensive judgment, the system outputs the final result of contact lens edge defect detection and corresponding annotation information. Figure 8 This is a flowchart illustrating the process of summarizing and organizing defects in one embodiment of this application, as shown below. Figure 8 As shown, in the process of sorting and summarizing defects, all the results obtained in E2 will be... Combined into a defect pool Configure according to priority. The data is analyzed, and the highest priority defect information is assigned to the current image result. , Figure 9 This is a schematic diagram of the image defect detection and summarization process in one embodiment of this application, as shown below. Figure 9 As shown, it specifically includes:

[0174] E21, Initialization Results data It is "NG";

[0175] E22, Loading object localization results in module C If the result in the above module is not "Pass" (i.e., the location structure is not "passed detection"), then... Assign the corresponding defect code, convert the relevant annotation data to the original image size, and then copy it. In the corresponding data structure, proceed to E34; otherwise, proceed to E33.

[0176] E23, Loading model detection results in module D If the model detection is empty, set the lens detection result. If the result is "Pass", then based on the feature analysis results and the defect severity configuration file, combined with the detected defect type, the defect code with the highest severity will be assigned to [the appropriate defect]. The relevant annotation data is then converted to the original image size and then transferred to... In the corresponding data structure.

[0177] The aforementioned defect severity is obtained from the defect severity configuration file, specifically as follows: If an edge defect—edge breakage—is detected, it is considered a minor defect based on its detection size (11x20) in the current application scenario (the minimum detection size for severe edge defects is 30x30, for general edge defects it is 20x20, and for minor edge defects it is 10x10); if an edge defect—edge porosity—is detected, it is considered a severe defect (by setting a mandatory severe defect type, edge porosity), this type of defect has no size, and detection automatically indicates severity; if an edge defect—edge foreign object—is detected, it is considered a general defect based on its detection size (30x30) in the current application scenario (the minimum detection size for severe foreign objects is 40x40, for general foreign objects it is 30x30, and for minor foreign objects it is 20x20). This configuration file has different consideration indicators depending on the specific application scenario and needs to be adapted according to the actual production situation.

[0178] E24. Based on the corresponding test results, output the corresponding test information and labeling information to the cloud service data platform for statistical analysis of contact lens production.

[0179] F. The statistical analysis module performs statistical analysis on lens inspection data transmitted from the edge device via gRPC. This statistical analysis takes two approaches: firstly, for the current production batch, only the most severe result is retained for each lens; secondly,... This reflects the quality of the current production batch of contact lenses; on the other hand, by screening the defect list one by one, it can be determined whether the produced lenses can be further improved in the previous process and the current testing process. Figure 10 This is a flowchart of production batch data statistics in one embodiment of this application, as shown below. Figure 10 As shown, in the first aspect, data statistics are performed based on the edge detection results of the contact lens images of the current production batch to obtain the statistical data of the current production batch; and abnormal data are accumulated for the coarse inspection results of the contact lens images of the current production batch that do not contain lenses, and an alarm is executed when the accumulated number exceeds a preset threshold.

[0180] Specifically, after the relevant data is input, the statistical analysis platform uses the Defect list and The statistics for this single lens are mainly based on... When the Defect list is empty and A "Pass" indicates the lens is flawless and is directly included in the current production batch statistics. When the Defect list is not empty, there are two handling methods: first, when... If the initial inspection passes without being marked as "positioning failure," the lens is considered defective and directly included in the current production batch statistics. On the other hand, when... If the location fails, it indicates that the coarse detection has not passed and the lens is not visible in the captured image. This set of data is added to the anomaly database and saved separately. The number of abnormal alarms is accumulated. If the set number of abnormal alarms is met, the relevant alarm devices will be enabled to issue an overall alarm to the system, requiring manual intervention to investigate and handle the corresponding problems.

[0181] Figure 11 This is a flowchart of the defect feedback analysis in one embodiment of this application, as shown below. Figure 11 As shown, in the second aspect, a defect type statistical list is constructed based on the defect type analysis results of the contact lens images of the current production batch. The defect type statistical list includes cumulative statistical results of multiple defect types and is used to optimize the contact lens manufacturing process.

[0182] Specifically, after the relevant data is input, the statistical analysis platform uses the Defect list and Statistical analysis was performed on this single lens. When... If the result is "Pass", the lens is considered flawless. Record the relevant data for the lens and end the process. When it is not "Pass", there are two aspects to handle: first, when If the initial inspection fails (i.e., the lens passes but is considered defective), the Defect list is iteratively processed. Specifically, each element in the Defect list represents a specific defect to be detected and its label. The corresponding defect statistics are accumulated and statistically analyzed based on the elements in the list. After a period of actual production time (set according to actual production needs), a production defect status table is exported and generated. Next, based on actual production, this status table is analyzed to examine how to optimize the current production process, whether the detection module status needs improvement, etc., and finally, a relevant analysis and inspection report is output.

[0183] This application discloses an edge defect detection system for contact lenses based on gRPC and YOLOv11. This system balances detection accuracy and output efficiency, enabling rapid and accurate localization and classification of targets in images, providing strong technical support for sorting equipment. By applying machine vision and an improved YOLOv11 algorithm to the contact lens edge defect detection system, the advantages of both are fully utilized, achieving efficient and accurate detection of contact lens edge defects. This not only improves detection efficiency and reduces production costs but also enhances detection accuracy and reliability, effectively avoiding product quality problems caused by human error and providing strong assurance for the production quality of contact lenses. Furthermore, this application statistically analyzes defect results during the production process, thereby extracting real-time yield rates, anomaly rates, and high-frequency defect types from the production line, providing a data foundation for adjusting the contact lens production line.

[0184] This embodiment also provides an electronic terminal, including: a processor and a memory;

[0185] The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory so that the terminal performs any of the methods in this embodiment.

[0186] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0187] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication between them. The memory is used to store computer programs, the communication interface is used to perform communication, and the processor and the transceiver are used to run the computer programs, so that the electronic terminal performs the steps of the above method.

[0188] In this embodiment, the memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.

[0189] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0190] In the above embodiments, although the present application has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. The embodiments of the present application are intended to cover all such substitutions, modifications, and variations falling within the broad scope of the appended claims.

[0191] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. A contact lens edge defect detection system based on gRPC and YOLOv11 for edge devices, characterized in that, include: The preprocessing module is used to acquire images of contact lenses from the current production batch and to locate the contact lens images to obtain carrier positioning information. The coarse detection and positioning module is used to extract the positioning image from the contact lens image based on the vehicle positioning information, and to perform coarse detection and positioning on the contour features in the positioning image to obtain the coarse detection and positioning result. An edge detection module is used to detect the edge of the contact lens in the contact lens image based on the coarse detection positioning result when the coarse detection positioning result matches the pre-configured feature inspection parameters, and to obtain an edge detection result. The edge detection result includes whether there is a defect region. When a defect region is included, the edge detection result also includes the defect features of the defect region. The post-processing module is used to perform type analysis on the edge detection results to obtain the defect type; and to perform post-processing on the coarse detection positioning results and defect types of the contact lens images of the current production batch to obtain structured detection information. The statistical analysis module is used to perform batch quality statistics and defect feedback analysis on the structured inspection information of contact lens images of the current production batch, and obtain statistical analysis results.

2. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 1, characterized in that, The edge detection results are analyzed to determine the defect type. The preliminary inspection results, location results, and defect types of the contact lens images from the current production batch are post-processed to obtain structured inspection information, including: The values ​​of multiple defect parameters in the defect feature are compared with the defect definitions of multiple pre-constructed defect types, wherein the defect definitions include reference value ranges for multiple defect parameters; when the values ​​of multiple defect parameters in the defect feature match the defect definition of any one target defect type, the defect feature is determined to be a target defect type; when the values ​​of multiple defect parameters in the defect feature do not match the defect definition of any one target defect type, the defect feature is determined to be a defect type of the interference category. For each contact lens image, if the coarse detection localization result is not passed, or if the edge detection result shows a defective area, the corresponding defect type defect code is assigned to the detection information, and the contact lens image is labeled based on the coarse detection localization result or the edge detection result, and structured detection information is constructed by combining the detection information and the labeled contact lens image.

3. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 1, characterized in that, Structured inspection information from images of contact lenses in the current production batch is used to perform batch quality statistics and defect feedback analysis, yielding statistical analysis results, including: Data statistics are obtained by performing edge detection on the contact lens images of the current production batch; and abnormal data are accumulated for the coarse inspection results of the contact lens images of the current production batch that do not contain lenses. When the accumulated number exceeds a preset threshold, an alarm is triggered. A defect type statistical list is constructed based on the defect type analysis results of the images of contact lenses from the current production batch. The defect type statistical list includes cumulative statistical results of multiple defect types and is used to optimize the contact lens manufacturing process.

4. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 1, characterized in that, The coarse detection and localization results include elliptical contour information. Based on the localization information, the edges of the contact lenses in the contact lens image are detected to obtain edge detection results, including: The contact lens image is cropped based on the elliptical contour information to obtain a single object image; The single object image is transformed into polar coordinates to obtain a single object polar coordinate image. Inference is performed on the single object image and the single object polar coordinate image based on the pre-built improved YOLOv11 model to obtain the inference result, wherein the inference result includes the object's rotation matrix information, confidence information and detection category information; Feature extraction is performed on the reasoning results to obtain defect features, wherein the defect features include grayscale features and geometric features.

5. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 4, characterized in that, The improved YOLOv11 model is obtained by training a pre-built improved YOLOv11 network using training data. The method for constructing the improved YOLOv11 network includes: The improved YOLOv11 network is obtained by replacing the C2PSA module in the backbone network with the C2f_SimAM module and replacing the C3k2 module with the TVConv module. The C2f_SimAM module is a C2f module that incorporates a similarity attention mechanism, the mathematical expression of which is: In the formula, Indicates the input feature map, This represents a feature map that incorporates attention weights. This represents the Sigmoid activation function. The L1 norm of the feature map is represented. This indicates the number of color channels in the feature map. Indicates the height of the feature map. Indicates the width of the feature map. and All of these represent learnable parameters.

6. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 4, characterized in that, Feature extraction is performed on the reasoning results to obtain defect features, including: The detection boxes that meet the target conditions in the inference results are taken as target detection boxes, wherein the target conditions include a size greater than a preset size threshold and a confidence level greater than a preset confidence threshold. For the detection box generated based on the polar coordinate image of the single object, perform an inverse polar coordinate transformation on the vertex coordinates of the detection box to obtain the vertex coordinates and the detection box in the image coordinates. Based on the detection box in image coordinates, an example image of object grayscale information is extracted from the contact lens image, and defect features are extracted from the example image of object grayscale information extraction, wherein the defect features include grayscale features and geometric features.

7. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 6, characterized in that, Based on the detection box in image coordinates, an example image of object grayscale information is extracted from the contact lens image, and defect features are extracted from the example image of object grayscale information, including: Based on rotation matrix and the coordinates of the center point of the ellipse Vertex coordinates in image coordinates Perform a rotation transformation to obtain the vertex coordinates after the rotation transformation. Wherein, the vertex coordinates after the rotation transformation The mathematical expression is: From the vertex coordinates after the rotation transformation Extract Maximum value in direction and minimum value , Maximum value in direction and minimum value ; Based on the above Maximum value in direction and Maximum value in direction Construct the coordinates of the top right corner of the rectangle and based on the Minimum value of direction and Minimum value of direction Construct the coordinates of the bottom left corner of the rectangle ; and based on the coordinates of the upper right corner point and the coordinates of the lower left corner point Construct a regular rectangle; The single object image is binarized to obtain a single object binarized image; and the single object image and the single object binarized image are cropped based on the regular rectangle to obtain an object image and an object binarized image. Gray-scale features and geometric features are extracted from the object image and the object binary image, respectively. The gray-scale features include average gray-scale and maximum gray-scale. The geometric features include contour fullness, contour aspect ratio, and contour smoothness.

8. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 1, characterized in that, The contact lens image is a grayscale image. The method for locating the contact lens image to obtain vehicle positioning information includes: The contact lens image is binarized based on a preset fixed threshold to obtain a binary image; The vehicle region is extracted from the binary image, and a positioning bounding box for the vehicle region is generated to obtain positioning information, wherein the positioning information includes the center coordinates of the positioning bounding box, the width of the positioning bounding box, and the height of the positioning bounding box.

9. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 1, characterized in that, The coarse detection and localization result includes localization result and coarse detection result. Coarse detection and localization are performed on the contour features in the localization image to obtain the coarse detection and localization result, including: The positioning image is processed by a flood filling algorithm to obtain a binarized image; Contour extraction is performed on the binarized image to obtain multiple contour features; a rotating rectangle with multiple contour features is generated; and the contour features of the rotating rectangle with a length greater than a preset length threshold and a width greater than a preset width threshold are saved as target contour features. The saved target contour is drawn onto a blank image, and the largest contour is selected. The contour outer envelope method is then applied to the largest contour to obtain the outer contour. Ellipse fitting is performed on the outer contour to obtain a fitted ellipse; and the ellipse contour information of the fitted ellipse is extracted, wherein the fitted ellipse is the positioning result, and the ellipse contour information includes the ellipse center, major axis and minor axis; The ellipse contour information is verified based on pre-configured ellipse feature inspection parameters to obtain a coarse inspection result, which includes size discrepancy, no product, and inspection passed.

10. The edge device contact lens edge defect detection system based on gRPC and YOLOv11 according to claim 1, characterized in that, The statistical analysis module is configured in the edge device, and the coarse inspection results and defect type analysis results of the contact lens images of the current production batch are sent to the edge device via the gRPC protocol.