Lens plastic part front and back visual identification method and system

By calculating distortion using edge detection and optical flow, and combining grayscale consistency and weighted adjustment of Hu moment similarity, the distortion error problem in lens plastic part recognition is solved, achieving high-precision front and back recognition.

CN120912922BActive Publication Date: 2026-02-06YUYAO YAODA ELECTRONIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511430006.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2026-02-06
Estimated Expiration
2045-10-09

AI Technical Summary

Technical Problem

Existing technologies have significant errors in identifying the front and back of plastic lens parts due to distortion, resulting in missed detections and false detections.

Method used

An edge detection algorithm is used to extract the edge contour of the lens plastic parts, and the degree of distortion is calculated by combining the optical flow method. The matching weight is calculated by using grayscale consistency and the degree of distortion, and recognition is performed by weighting the Hu moment similarity.

Benefits of technology

It improves the accuracy of front and back recognition of lens plastic parts, reduces the probability of false judgment, and achieves high-precision front and back recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120912922B_ABST
    Figure CN120912922B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing, more particularly, to a lens plastic piece front and back visual identification method and system, the method comprising: collecting production video of lens plastic piece, extracting multiple edge contours of single lens plastic piece from the production video; using optical flow method to extract optical flow vector of each pixel point in single edge contour, to calculate distortion degree and gray consistency of single edge contour; based on the gray consistency and distortion degree of single edge contour, calculating the matching weight of single edge contour, using the matching weight of single edge to weight hu moment similarity, obtaining adjusted hu moment similarity, setting hu moment similarity value threshold, using hu moment similarity value threshold, completing lens plastic piece front and back identification. The present application can improve the accuracy of lens plastic piece front and back identification.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image processing. More particularly, it relates to a lens plastic piece front and back visual identification method and system. BACKGROUND

[0002] In the manufacturing process of electronic products such as smart phones, lens plastic parts are crucial to product quality. Lens plastic parts usually have front and back designs. To ensure accurate positioning and mounting operations, the front and back of the lens plastic part can be identified to ensure correct mounting of the lens plastic part.

[0003] In the prior art, when identifying the front and back of the lens plastic part, the front and back of the lens plastic part has a certain texture shape difference. Shape matching can be used to match the texture shape difference between the lens plastic part to be detected and the front lens plastic part, and the front and back of the lens plastic part can be identified according to the similarity matching result.

[0004] However, when using a camera to capture lens plastic part images, the lens plastic part is often small, and when the detection camera is too close to the lens plastic part, the lens plastic part is severely distorted, resulting in errors when using similarity matching to identify the front and back of the lens plastic part, resulting in missed detection and false detection. SUMMARY

[0005] To solve the above technical problems of missed detection and false detection of lens plastic part front and back identification due to lens plastic part distortion when calculating similarity, the present application provides solutions in the following aspects.

[0006] In a first aspect, the present application discloses a lens plastic piece front and back visual identification method, comprising:

[0007] Collecting a production video of a lens plastic part, extracting a single frame lens plastic part image from the production video, extracting a single lens plastic part region in the lens plastic part image, and extracting a plurality of edge contours of a single lens plastic part using an edge detection algorithm;

[0008] Obtaining a single edge contour from the plurality of edge contours of the single lens plastic part, extracting an optical flow vector of each pixel point in the single edge contour using an optical flow method, and calculating a distortion degree of the single edge contour;

[0009] Obtaining a contour region of the single edge contour, calculating the gray consistency of the single edge contour using the gray difference between the contour region of the single edge contour and the contour region of all edge contours of the front of the standard lens plastic part;

[0010] The matching weight of the single edge contour is calculated based on the gray consistency and the distortion degree of the single edge contour, the profile area of the single edge contour is weighted by the matching weight of the single edge in the hu moment similarity between the profile area of the single edge contour and the profile area of all edge contours of the front surface of the standard lens plastic part, and the adjusted hu moment similarity is obtained, the hu moment similarity value threshold is set, and the front and back surface identification of the lens plastic part is completed by using the hu moment similarity value threshold.

[0011] Preferably, the extracting a plurality of edge contours of a single lens plastic part comprises: installing a camera at a fixed position above the lens plastic part production line, making the camera view angle perpendicular to the production line to collect the overhead view image of the lens plastic part on the production line; continuously collecting images of the lens plastic part to be detected by using the camera, and the production video of the lens plastic part can be collected; obtaining the image of the lens plastic part to be detected corresponding to the current frame in the collected production video as the current frame image, and using a grayscale algorithm to perform grayscale on the current frame image to obtain a grayscale image; using a pre-trained neural network to extract the ROI region of a single lens plastic part to be detected from the current frame image after grayscale; using a canny edge detection algorithm to extract the edge line of the ROI region of a single lens plastic part to be detected to obtain an edge detection result; preprocessing the edge detection result to connect the broken edges, and one connected domain extraction result in the preprocessed connected domain extraction result is an edge line as an edge contour, and then a plurality of edge contours of a single lens plastic part are obtained.

[0012] Preferably, the distortion degree of the single edge contour comprises: obtaining a plurality of edge contours of a single lens plastic part to be detected; calculating the optical flow vector of each edge pixel point of all edge contours of the single lens plastic part to be detected in two continuous frames by using an optical flow method, obtaining the standard deviation value of all edge pixel points of the single edge contour in the single lens plastic part to be detected; obtaining the optical flow acceleration of each edge pixel point on the single edge contour in the single lens plastic part to be detected in the horizontal and vertical directions, and calculating the average value of the optical flow acceleration of each edge pixel point on the single edge contour in the single lens plastic part to be detected in two directions; and based on the product of the standard deviation value and the average value of the optical flow acceleration, the distortion degree of the single edge contour in the single lens plastic part to be detected is obtained.

[0013] Preferably, the gray consistency of the single edge profile comprises: obtaining the coordinates of each pixel point on the single edge profile in the ROI region of the single lens plastic part to be inspected, obtaining the gray value of each pixel point on the single edge profile at the corresponding coordinates in the gray image of each pixel point on the single edge profile, and calculating the average of the corresponding gray values of all pixel points on the single edge profile; obtaining the gray values of each pixel point on the edge texture of the front of the standard lens plastic part, and calculating the gray average of all pixel points on the edge texture of the front of the standard lens plastic part; calculating the ratio of the average of the corresponding gray values of all pixel points on the single edge profile in the ROI region of the single lens plastic part to be inspected to the gray average of all pixel points on the edge texture of the front of the standard lens plastic part; obtaining the variance value of the corresponding pixel gray values of the single edge profile in the ROI region of the single lens plastic part to be inspected; based on the negative correlation between the variance value of the gray value and the gray consistency and the positive correlation between the ratio and the gray consistency, the gray consistency of the single edge profile in the ROI region of the single lens plastic part to be inspected is obtained.

[0014] Preferably, the matching weight of the single edge profile comprises: obtaining the distortion degree of the single edge profile in the ROI region of the single lens plastic part to be inspected; obtaining the gray consistency of the single edge profile in the ROI region of the single lens plastic part to be inspected; based on the negative correlation between the distortion degree of the single edge profile in the ROI region of the single lens plastic part to be inspected and the matching weight and the positive correlation between the gray consistency and the matching weight, the initial matching weight is solved, and then the initial matching weight is normalized to obtain the matching weight of the single edge profile in the ROI region of the single lens plastic part to be inspected.

[0015] Preferably, the front and back identification of the lens plastic part comprises: calculating the similarity between the lens plastic part to be inspected in the ROI region of the single lens plastic part to be inspected and the edge texture of the front of the standard lens plastic, and adjusting the similarity by using the matching weight of the single edge profile in the ROI region of the single lens plastic part to be inspected. The similarity adjustment value of the single lens plastic part to be inspected in the ROI region of the single lens plastic part to be inspected is obtained, and the similarity threshold value is set for the similarity adjustment value; the lens plastic part to be inspected less than or equal to the similarity threshold value is marked as the front, and vice versa, the front and back identification of the lens plastic part to be inspected is completed.

[0016] Preferably, the pre-trained neural network comprises: the pre-trained neural network is an instance segmentation network, which comprises a decoder and an encoder, and the data set is obtained by collecting the overhead image of the lens plastic part, marking the pixel points belonging to the lens plastic part in the overhead image of the lens plastic part as 1 and the background pixel points as 0 by manual marking method, and obtaining the labeled data set.

[0017] In a second aspect, the present application also discloses a lens plastic part front and back visual identification system, comprising: a processor and a memory, the memory stores computer program instructions, when the computer program instructions are executed by the processor, the lens plastic part front and back visual identification method described above is realized.

[0018] The present application has the following beneficial effects:

[0019] The problem that the traditional shape matching algorithm based on hu moments may fail due to angle change is solved, and multiple detection is realized once; the optical flow vector of the edge point contained in a single independent contour is calculated, the distortion degree of a single independent contour is calculated, and the influence of the contour with high distortion degree on the matching result is avoided; the gray scale and texture consistency features of the pixel points in a single contour are established, the response capability to the front edge texture of the standard lens plastic part is improved, the weight of different contours in the ROI region of a single lens plastic part is calculated, the hu moment similarity calculation of different contours is weighted, the accuracy of shape matching using hu moments is improved, and the misjudgment probability of the front and back of the lens plastic part is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 is a method flowchart of steps S1-S4 in the lens plastic part front and back visual identification method of the embodiment of the present application.

[0021] Figure 2 is a structure block diagram of the lens plastic part front and back visual identification system of the embodiment of the present application. DETAILED DESCRIPTION

[0022] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments of the present application.

[0023] Referring to Figure 1 A lens plastic part front and back visual identification method comprises steps S1-S4, and specifically as follows:

[0024] S1: Collecting production video of the lens plastic part, extracting single-frame lens plastic part images from the production video, extracting a single lens plastic part region in the lens plastic part image, and extracting multiple edge contours of a single lens plastic part by using an edge detection algorithm.

[0025] A camera is installed at a fixed position above the lens plastic part production line, and the camera visual angle is perpendicular to the production line, so as to collect the overhead view image of the lens plastic part on the production line.

[0026] The camera continuously collects images of the lens plastic part to be detected, and a production video of the lens plastic part to be detected can be collected, wherein the production video is composed of images of the lens plastic part to be detected at continuous time points, and an image at a time point in the production video is an image of the lens plastic part to be detected collected in the production line at the time point.

[0027] An image of the lens plastic part to be detected corresponding to a frame at a current time in the collected production video is obtained as a current frame image, the current frame image is analyzed, the current frame image is first grayscaled by using a graying algorithm to obtain a grayscaled image, and a single lens plastic part ROI region is extracted from the grayscaled current frame by using a pre-trained neural network.

[0028] Since it is impossible to ensure that only one lens plastic part is in the camera collection field of view during production video collection by using the camera, the neural network needs to be used to extract a single lens plastic part to be detected, wherein the neural network is not directly used to identify the front and back of the single lens plastic part to be detected, because the front and back of the single lens plastic part to be detected are less different, the neural network has less learnable distinguishing features, and it is difficult to obtain a high-precision neural network identification model.

[0029] During production video collection, each frame of the image of the lens plastic part to be detected contains not only the lens plastic part but also more background content, and the lens plastic part and the background have great differences, so the pre-trained neural network can be used to extract a single lens plastic part, which is conducive to improving the accuracy of subsequent identification of the front and back of the single lens plastic part.

[0030] The pre-trained neural network is an instance segmentation network, which includes a decoder and an encoder, a data set is collected by using a top view image of the lens plastic part, pixel points belonging to the lens plastic part in the top view image of the lens plastic part are marked as 1 by using an artificial marking method, background pixel points are marked as 0, a marked data set is obtained, and an existing instance segmentation network model is used to train the marked data, wherein the existing instance segmentation network model can use a Mask R-CNN network, and the training process of the Mask R-CNN network is a known content, which will not be described herein again, and the trained neural network is used as the pre-trained neural network to extract a single lens plastic part to be detected in each frame of the image of the lens plastic part to be detected.

[0031] The grayscaled current frame image of the lens plastic part to be detected is input into the pre-trained neural network to obtain a mask image of each lens plastic part to be detected in the grayscaled current frame image of the lens plastic part to be detected, and the mask image of each lens plastic part to be detected is multiplied with the grayscaled current frame image of the lens plastic part to be detected to obtain an ROI region of a single lens plastic part to be detected.

[0032] To obtain the ROI region of the i-th lens plastic part to be inspected, since the front and back recognition is achieved by utilizing the difference in texture between the front and back of the current lens plastic part to be inspected and the front of the standard front lens plastic part, the edge line of the ROI region of the i-th lens plastic part to be inspected is extracted using the Canny edge detection algorithm to obtain the edge detection result. In the edge detection result, the edge pixels that make up the edge line are pixels with a gray value of 255, and the gray value of the pixels that are not on the edge line is 0. Therefore, the edge detection result is a binary image.

[0033] The edge detection results contain multiple disconnected edge contours, each corresponding to a different shape. If the global hu moment is calculated directly, it will confuse the features of all shapes. Therefore, it is necessary to separate the independent edges first and then match them one by one.

[0034] The edge detection results are preprocessed to connect the broken edges. The preprocessing process is as follows: For the first... The edge detection results of the ROI region of the plastic lens to be inspected are obtained by using the image closing operation method. The edge detection results after closing operation are then obtained by using the connected component analysis method. In the connected component extraction results, each connected component extraction result is an edge line, which is considered as an edge contour. Thus, multiple edge contours of a single plastic lens are obtained. The connected component analysis and image closing operation methods are known techniques and will not be described in detail in this solution.

[0035] S2: Obtain a single edge contour from multiple edge contours of a single lens plastic part, and use optical flow method to extract the optical flow vector of each pixel in the single edge contour in order to calculate the degree of distortion of the single edge contour.

[0036] Get the The connected component extraction results of the ROI region of the plastic part of the lens to be inspected are obtained. Multiple edge contours of the ROI area of ​​the plastic part of the lens to be inspected.

[0037] Get the The ROI area of ​​the plastic component to be inspected is the first The first edge contour The logarithm of the hu moments is .

[0038] When using Hu moments to calculate similarity and match the edge of the plastic lens under test with the front edge of the standard plastic lens under test, image distortion of the plastic lens under test is caused by the field of view of the acquisition camera, which will affect the similarity calculation results of Hu moments.

[0039] Since the actual size of the plastic part of the lens under inspection is constant, the pixel changes between two consecutive image frames should be consistent. However, due to the distortion of the plastic part of the lens under inspection captured by the camera, the pixels that should change consistently may change inconsistently. Therefore, the overall change of different edge contours can be used to measure the distortion of the plastic part of the lens under inspection, and this can be used to correct the similarity calculation when using Hu moments, thereby improving the accuracy of front and back identification of the plastic part of the lens under inspection.

[0040] In the first of two consecutive frames In the ROI region of the plastic part to be inspected, the sparse optical flow method is used to calculate the... The optical flow vector of each edge pixel in the ROI region of the plastic part of the lens to be inspected is used. The sparse optical flow method is a well-known technique and will not be described in detail in this solution.

[0041] Among them, the The first ROI region of the plastic part to be inspected On the edge contour of the first The optical flow vector of each edge pixel is .

[0042] No. The first ROI region of the plastic part to be inspected The degree of distortion of each edge contour :

[0043]

[0044] In the formula, For the first The first ROI region of the plastic part to be inspected Each edge contour contains the standard deviation of the optical flow vectors of all edge pixels. A larger value indicates a greater interval between two consecutive frames. The higher the difference in optical flow vectors of edge pixels within an edge contour, the higher the degree of distortion.

[0045] For the first Each edge contour contains the number of edge pixels. and edge pixels The horizontal and vertical components of the optical flow vector. and edge pixels Optical flow acceleration in the horizontal and vertical directions.

[0046] Optical flow vectors are the motion vectors of pixels in an image between two consecutive frames, reflecting the intensity of local deformation of an object. When distortion occurs, the difference in the motion rate of pixels in different regions increases, such as the near end moving quickly and the far end moving slowly. Therefore, the degree of distortion of different shapes in the ROI region of a single plastic part of a lens under inspection is different.

[0047] S3: Obtain the contour region of a single edge contour, and calculate the grayscale consistency of the single edge contour by utilizing the grayscale difference between the contour region of the single edge contour and the contour regions of all edge contours on the front of the standard lens plastic part.

[0048] After obtaining the ROI region of a single lens plastic part to be inspected, since the problem features represented by different edge contours on the lens plastic part to be inspected are inconsistent, if the edge texture on the lens plastic part to be inspected is consistent with the edge texture on the front of the standard lens plastic part, then when using Hu moments for similarity calculation, it should have a higher approximation, and vice versa.

[0049] Since the edge texture of the plastic part of the lens under test is not obvious, in order to further amplify the difference in edge texture between the front and back of the plastic part of the lens under test, the difference between a single edge contour and the edge texture of the front of the standard lens plastic part is obtained, so as to achieve the purpose of amplifying the difference in edge texture between the front and back of the plastic part of the lens under test.

[0050] Get the The first ROI region of the plastic part to be inspected The coordinates of each pixel on the edge contour are obtained. The coordinates of each pixel on the edge contour are in the th... Calculate the grayscale value at the corresponding coordinates of each pixel point in the grayscale image on the edge contour, and calculate the i-th... The mean gray value of all pixels on the edge contour .

[0051] Similarly, obtain the grayscale value of each pixel on the edge texture of the front side of the standard lens plastic part, and calculate the average grayscale value of all pixels on the edge texture of the front side of the standard lens plastic part. The edge texture of the front side of the standard lens plastic part is obtained through the edge detection result acquisition step in step S1 above.

[0052] In obtaining the Within the ROI area of ​​the plastic component to be inspected, the first... Variance of pixel grayscale values ​​corresponding to edge contours This reflects the uniformity of the grayscale distribution of pixels within the contour.

[0053] Get the first The gray consistency of the jth edge contour in the ROI region of the to-be-inspected lens plastic part :

[0054]

[0055] In the formula, The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The ratio of the average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part to the average value of the gray values of all pixel points on the edge texture of the front surface of the standard lens plastic part, the closer the ratio is to 1, the greater the possibility that the pixel points inside the jth edge contour belong to the edge texture of the front surface of the to-be-inspected lens plastic part. The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part

[0056] The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part

[0057] The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part

[0058] The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part

[0059] The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part

[0060] The average value of the gray values corresponding to all pixel points on the jth edge contour in the ROI region of the to-be-inspected lens plastic part

[0061] In the formula, For the first The total number of edge contours within the ROI area of ​​each plastic part of the lens to be inspected.

[0062] To account for the degree of distortion, and to avoid the contours with a high degree of distortion having a significant impact on the matching results, their matching weight should be appropriately reduced.

[0063] As a consistency index, to avoid the background region contour from interfering with the matching process and results, contours with higher consistency are assigned higher weights.

[0064] S4: Based on the grayscale consistency and distortion degree of a single edge contour, calculate the matching weight of the single edge contour. Using the matching weight of the single edge, perform hu moment similarity weighting on the contour region of the single edge contour and the contour region of all edge contours on the front of the standard lens plastic part to obtain the adjusted hu moment similarity. Set the hu moment similarity value threshold and use the hu moment similarity value threshold to complete the front and back recognition of the lens plastic part.

[0065] Using steps S2 and S3, the result is calculated based on the first... Within the ROI area of ​​the plastic component to be inspected, the first... After considering the grayscale consistency and distortion degree of each edge contour, the similarity calculation formula for the Hu moments is weighted to obtain the first... The new similarity value between the ROI region of the plastic part to be inspected and the front face of the plastic part of the standard lens is used as a similarity adjustment value. .

[0066]

[0067] In the formula, 7 represents the number of hu matrices, which are 7 invariant moments derived from the image moments. This will not be elaborated further in existing techniques.

[0068] For the first Within the ROI area of ​​the plastic component to be inspected, the first... The logarithmic distance between the moment of the edge contour and the moment of the texture shape on the front of the standard lens plastic, taken as the Euclidean distance, is used to reflect the similarity.

[0069] For the first Within the ROI area of ​​the plastic component to be inspected, the first... Each edge contour has a matching weight; a larger weight indicates that the edge contour is more important in the matching process. The smaller the value, the higher the similarity between the edge texture of the plastic part of the lens under test and that of the standard lens plastic. Therefore, an exponential function is used. right Perform negative correlation mapping.

[0070] Calculation yields the first The similarity adjustment value between the edge texture of the lens plastic part under test and the standard lens plastic in the ROI area of ​​the lens plastic part under test. , The smaller the value, the higher the similarity between the front of the data and the front of the standard lens plastic, and the better. The threshold value is set to 0.6. This threshold is a hyperparameter and should be selected according to the actual situation.

[0071] The plastic parts of the lens under inspection with a similarity adjustment value of less than or equal to 0.6 are marked as the front side, and the rest are marked as the back side, thus completing the front and back identification of the plastic parts of the lens under inspection.

[0072] This invention also provides a visual recognition system for the front and back of a lens plastic part. For example... Figure 2 As shown, the system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a method for visually recognizing the front and back of a lens plastic part according to the present invention. The system also includes other components well-known to those skilled in the art, such as a communication bus and a communication interface. Their configuration and functions are known in the art and will not be described further here.

[0073] It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of this invention. Therefore, the scope of protection of this patent should be determined by the appended claims.

Claims

1. A method for visually identifying the front and back of a lens plastic part, characterized in that, include: The production video of lens plastic parts is collected, a single frame image of the lens plastic parts is extracted from the production video, the ROI region of a single lens plastic part to be inspected is extracted from the lens plastic part image, and multiple edge contours of a single lens plastic part to be inspected are extracted using an edge detection algorithm. A single edge contour is obtained from multiple edge contours of a single plastic part of a lens under inspection. The optical flow vector of each pixel in the single edge contour is extracted using the optical flow method to calculate the degree of distortion of the single edge contour. Obtain the contour region of a single edge contour, and calculate the grayscale consistency of the single edge contour by utilizing the grayscale difference between the contour region of the single edge contour and the contour regions of all edge contours on the front of the standard lens plastic part. Based on the grayscale consistency and distortion degree of a single edge contour, the matching weight of the single edge contour is calculated. The Hu moment of the contour region of the single edge contour of the single lens plastic part under inspection is calculated. The Hu moment of the contour region of all edge contours on the front of the standard lens plastic part is calculated. The Hu moment similarity between the single edge contour and the contour regions of all edge contours on the front of the standard lens plastic part is calculated. The corresponding Hu moment similarity is weighted based on the matching weight of the single edge contour to obtain the Hu moment similarity of the contour region of the single edge contour. The Hu moment similarity of the contour regions of all single edge contours is summed. A Hu moment similarity value threshold is set. Using the Hu moment similarity value threshold, the front and back of the single lens plastic part under inspection is identified.

2. The method for visually identifying the front and back of a lens plastic part according to claim 1, characterized in that, The extraction of multiple edge contours of a single plastic lens component under inspection includes: A camera is installed at a fixed position above the lens plastic parts production line, with the camera's viewing angle perpendicular to the production line, in order to capture a top-view image of the lens plastic parts on the production line. By continuously capturing images of the plastic lens parts under inspection using a camera, production videos of the lens plastic parts can be obtained. The image of the plastic part of the lens to be inspected in the current frame of the captured production video is obtained as the current frame image. The current frame image is first converted to grayscale using a grayscale algorithm to obtain the grayscale image. The ROI region of a single plastic part of the lens to be inspected is extracted from the grayscale current frame image using a pre-trained neural network. The edge lines of the ROI region of a single plastic lens under inspection are extracted using the Canny edge detection algorithm to obtain the edge detection results. The edge detection results are then preprocessed to connect the broken edges. In the preprocessed connected component extraction results, each connected component extraction result is an edge line, which is used as an edge contour. Thus, multiple edge contours of a single plastic lens under inspection are obtained.

3. The method for visually identifying the front and back of a lens plastic part according to claim 1, characterized in that, The degree of distortion of the individual edge contour includes: Obtain multiple edge contours of the ROI region of a single plastic part to be inspected; The optical flow method is used to calculate the optical flow vector of each edge pixel in all edge contours of a single plastic part ROI region of a single lens under inspection in two consecutive frames, and the standard deviation of the optical flow vectors of all edge pixels in a single edge contour of a single plastic part ROI region of a single lens under inspection is obtained. Obtain the optical flow acceleration of each edge pixel on a single edge contour in the ROI region of a single lens plastic part under inspection in the horizontal and vertical directions, calculate the sum of the optical flow acceleration of each edge pixel on a single edge contour in the ROI region of a single lens plastic part under inspection in the two directions, and then calculate the average of the sum of the optical flow acceleration of all edge pixels on the single edge contour. The degree of distortion of a single edge profile in the ROI region of a single lens plastic part is obtained based on the product of the standard deviation and the average value.

4. The method for visually identifying the front and back of a lens plastic part according to claim 1, characterized in that, The grayscale consistency of the individual edge contour includes: Obtain the coordinates of each pixel on a single edge contour in the ROI region of a single plastic part of a single lens under inspection. Obtain the gray value of the coordinates of each pixel on the single edge contour in the grayscale image of each pixel on the single edge contour. Calculate the mean of the gray values ​​of all pixels on the single edge contour. Obtain the grayscale value of each pixel on the contour area of ​​all edge contours on the front of the standard lens plastic part, and calculate the average grayscale value of all pixels on the contour area of ​​all edge contours on the front of the standard lens plastic part. Calculate the ratio of the mean gray value of all pixels on a single edge contour within the ROI region of a single lens plastic part to the mean gray value of all pixels on the contour region of all edge contours on the front side of a standard lens plastic part. Obtain the variance of the grayscale values ​​of a single edge contour within the ROI region of a single plastic part of the lens under inspection; Based on the negative correlation between the variance of the grayscale value and grayscale consistency, and the positive correlation between the ratio and grayscale consistency, the grayscale consistency of a single edge contour in the ROI region of a single plastic part of a single lens under inspection is obtained.

5. The method for visually identifying the front and back of a lens plastic part according to claim 1, characterized in that, The matching weights for a single edge contour include: Obtain the degree of distortion of a single edge contour within the ROI region of a single plastic part of the lens under inspection; Obtain the grayscale consistency of a single edge contour within the ROI region of a single plastic part to be inspected; The initial matching weight is calculated based on the negative correlation between the distortion degree of a single edge contour in the ROI region of a single lens plastic part under inspection and the matching weight, and the positive correlation between the grayscale consistency and the matching weight. Then, the initial matching weight is normalized to obtain the matching weight of a single edge contour in the ROI region of a single lens plastic part under inspection.

6. The method for visually identifying the front and back of a lens plastic part according to claim 1, characterized in that, The identification of the front and back of the lens plastic component includes: The similarity between the contour regions of a single edge profile of the lens plastic part under inspection and all edge profiles of the front face of a standard lens plastic part is calculated within the ROI region of the lens plastic part under inspection. The matching weights of the single edge profiles within the ROI region of the lens plastic part under inspection are then used. The similarity adjustment is performed, and then the adjusted similarities of the contour regions of all edge contours on the lens plastic part under test in the ROI region of a single lens plastic part under test are summed to obtain the similarity adjustment value of the contour regions of all edge contours on the front side of the lens plastic part under test and the standard lens plastic part in the ROI region of a single lens plastic part under test. A similarity threshold is set for the similarity adjustment value; wherein Indicates the first Within the ROI area of ​​the plastic component to be inspected, the first... Matching weights for each edge contour; The plastic parts of the lens under inspection that are less than or equal to the similarity threshold are marked as the front side, and those that are greater than the similarity threshold are marked as the back side, thus completing the front and back identification of the plastic parts of the lens under inspection.

7. The method for visually identifying the front and back of a lens plastic part according to claim 2, characterized in that, The pre-trained neural network includes: the pre-trained neural network is an instance segmentation network, which includes a decoder and an encoder. The dataset is obtained by collecting top-view images of lens plastic parts, and manually labeling the pixels belonging to the lens plastic parts in the top-view images as 1 and the background pixels as 0, thus obtaining the labeled dataset.

8. A visual recognition system for the front and back of a lens plastic part, characterized in that, include: A processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement a method for visually recognizing the front and back of a lens plastic part according to any one of claims 1-7.

Citation Information

Patent Citations

  • Objective evaluation method for image quality

    CN106023208A

  • Video noise reduction method and device, electronic equipment and computer readable medium

    CN111833269A