Visual inspection method, device and system of sighting device lens

Through the analysis of front and backlight images at different wavelengths, the backlight fusion image is synthesized, and the gradient value and edge information of the front light image are combined to identify and reduce the interference of internal defects on surface defect recognition, which solves the problem of inaccurate surface defect recognition in the prior art and improves the accuracy and completeness of defect detection.

CN119804500AActive Publication Date: 2025-04-11HUNAN MANJI ELECTRONIC TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411861684.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-11
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

In the prior art, the inaccurate and incomplete surface defects of the sight lens are recognized by the front light image, mainly due to the abnormal reflection and scattering manifestations of the identification of surface defects by internal defects.

Method used

The front light image and back light image of the sight lens at different wavelengths are obtained, and the back light image is synthesized by analyzing the internal defect area and its grayscale distribution in the back light image; combining the gradient value and edge information in the front light image, the interference of internal defects on surface defect recognition is identified and reduced.

Benefits of technology

It improves the accuracy and completeness of the identification of surface defects on the sight lens, reduces the interference of internal defects on the identification of surface defects, and enhances the visibility and accuracy of defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119804500A_ABST
    Figure CN119804500A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image analysis, in particular to a visual inspection method, device and system for a sighting device lens. The method comprises the following steps: acquiring a front illumination light image and a back illumination light image of a sighting device lens; obtaining an internal defect area according to the gray value of the pixel point in the back illumination light image; according to the gray level distribution of the internal defect area in the back illumination light image under each wavelength, obtaining a back illumination light fusion image; obtaining a surface defect area based on the gradient value of the pixel points in the front illumination light image, the position of the edge pixel points, the size of the internal defect area and the gray level distribution in the back illumination light fusion image; and acquiring flaws in the lens of the sighting device according to the gray level distribution of the back light fusion image and the surface flaw area in the front light image under each wavelength. According to the method, the surface flaw area is acquired on the basis of acquiring the internal flaw area of the sighting device lens, so that the interference of internal flaws on surface flaw identification is reduced, and the accuracy of acquiring the flaws of the sighting device lens is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image analysis, and in particular to a method, device and system for visual inspection of a sight lens. Background Art

[0002] In current industrial production, the quality inspection of sight lenses is very important to ensure that the sight lenses meet the requirements of accuracy and reliability. The existing visual inspection methods for sight lenses usually involve two imaging technologies: front light inspection and back light inspection, which are used to identify the surface defects and internal defects of the sight lenses and inspect the quality of the sight lenses.

[0003] In the existing method, the optimal wavelength is manually selected to obtain the front light image and the back light image, and the back light image is processed by the Otsu threshold to obtain the internal defects of the sight lens, such as bubbles and cracks; the front light image is processed by edge detection to obtain the surface defects of the sight lens, such as scratches and stains. However, in actual situations, the principle of front light is to judge defects based on the performance of reflected light. When there are internal defects such as bubbles and cracks in the area where some surface defects are located, abnormal reflection and scattering will occur, which will weaken the performance of surface defects in the front light image, resulting in inaccurate and incomplete surface defects of the sight lens identified by the front light image, affecting the accurate detection of the quality of the sight lens. Summary of the invention

[0004] In order to solve the technical problem that the surface defects of the sight lens identified by the front light image are inaccurate and incomplete, the purpose of the present invention is to provide a method, device and system for visual inspection of the sight lens, and the technical solution adopted is as follows:

[0005] In a first aspect, an embodiment of the present invention provides a method for visually inspecting a sight lens, the method comprising the following steps:

[0006] Acquire front-light images and back-light images of the sight lens at different wavelengths;

[0007] According to the gray value of each pixel in the backlight image at each wavelength, the internal defect area of ​​the sight lens is obtained; according to the gray distribution of the internal defect area in the backlight image at each wavelength, the backlight fusion image is obtained;

[0008] Based on the gradient value of each pixel point and the position of the edge pixel point in the front-light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back-light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back-light fusion image, the surface defect area of ​​the sight lens is obtained;

[0009] The defects in the sight lens are obtained based on the grayscale distribution of the backlight fusion image and the frontlight image of the surface defect area at each wavelength.

[0010] Furthermore, the method for obtaining the internal defect area is:

[0011] Obtain the mean grayscale value of all pixels in the backlight image at each wavelength as the target grayscale value of the backlight image at each wavelength;

[0012] A two-dimensional coordinate system is constructed with the designated position of the backlight image at each wavelength as the origin; wherein the size of the backlight image at each wavelength is the same;

[0013] For any coordinate in the two-dimensional coordinate system, obtain the difference between the grayscale value of the pixel point in the backlight image at each wavelength and the target grayscale value of the backlight image at the same wavelength as the grayscale difference value of the pixel point at the coordinate at each wavelength;

[0014] Arrange the grayscale difference values ​​in ascending order according to the corresponding wavelengths to obtain a grayscale difference value sequence as the wavelength-grayscale difference value sequence of the pixel point at the coordinate;

[0015] The pixel points with a gray value of 0 after threshold segmentation of the backlight image at the specified wavelength are used as the initial internal defect pixel points of the sight lens;

[0016] The coordinates corresponding to the initial internal defect pixel points are all used as the target coordinates. For any non-target coordinate, the DTW algorithm is used to obtain the matching degree of the wavelength-grayscale difference value sequence between the pixel point on the non-target coordinate and the pixel point on each target coordinate, which are all used as the suspected internal defect reference value of the pixel point on the non-target coordinate;

[0017] Normalizing the average of the suspected internal defect reference values ​​as the suspected internal defect degree of the pixel point at the non-target coordinate;

[0018] Obtaining internal defect pixel points of the sight lens based on the suspected internal defect degree;

[0019] The area formed by the initial internal defect pixel points and the internal defect pixel points is used as the internal defect area of ​​the sight lens.

[0020] Furthermore, the method for obtaining the internal defect pixel points of the sight lens based on the suspected internal defect degree is:

[0021] Evenly divide the value range of the suspected internal defect degree into a first preset number of reference intervals from small to large, and obtain the number of suspected internal defect degrees contained in each reference interval as the first number of the corresponding reference interval;

[0022] Obtain the difference of the first quantity between each reference interval and its previous adjacent reference interval, both as the first difference;

[0023] The dividing value between the two reference intervals corresponding to the largest first difference is used as the threshold value of the suspected internal defect degree;

[0024] When the suspected internal defect level is greater than the suspected internal defect level threshold, the pixel point on the corresponding non-target coordinate is used as the internal defect pixel point of the sight lens.

[0025] Furthermore, the method for acquiring the backlight fusion image is:

[0026] For a backlight image at any wavelength, the average of the grayscale values ​​of the pixels corresponding to the internal defect area in the backlight image is used as the internal defect grayscale reference value of the backlight image;

[0027] Obtaining the average grayscale value of all pixels in the backlight image except the pixels corresponding to the internal defect area as a normal grayscale reference value of the backlight image;

[0028] Obtaining a difference between an internal defect grayscale reference value and a normal grayscale reference value of the backlight image as a first characteristic value of the backlight image;

[0029] The backlight image at the wavelength corresponding to the largest first eigenvalue is used as the backlight fusion image.

[0030] Furthermore, the method for obtaining the surface defect area is:

[0031] A two-dimensional coordinate system is constructed with the designated position of the front light image at each wavelength as the origin; wherein the size of the front light image and the back light image at each wavelength is the same;

[0032] When the pixels at the same coordinates in the front light image at each wavelength are all edge pixels, the pixels at the corresponding coordinates are used as the initial surface defect pixels of the sight lens;

[0033] Arrange the gradient values ​​of the pixels corresponding to each coordinate in the front light image at each wavelength in the two-dimensional coordinate system in ascending order according to the wavelength to obtain a wavelength-gradient value sequence of the pixels at each coordinate;

[0034] The coordinates corresponding to the initial surface defect pixel points are all used as reference coordinates. For any non-reference coordinate and any reference coordinate, the matching degree of the wavelength-gradient value sequence between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate is obtained by the DTW algorithm as the reference matching degree;

[0035] According to the size of each internal defect area and the grayscale difference of each internal defect area in the backlight image corresponding to the longest wavelength and the shortest wavelength, the overall surface interference degree of each internal defect area is obtained;

[0036] According to the positional relationship between the coordinates of the front-light image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, and the grayscale distribution of the internal defect area where the internal defect pixel points are located in the back-light fusion image, the surface defect interference degree of the pixel points at each coordinate is obtained;

[0037] For any coordinate in the two-dimensional coordinate system, the product of the surface defect interference degree of the pixel point at the coordinate and the surface overall interference degree of the internal defect area where the pixel point at the coordinate is located is used as the target surface defect degree of the pixel point at the coordinate;

[0038] The target surface defect degree of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate are added and normalized, and the result is used as the adjustment weight;

[0039] The product of the reference matching degree and the adjustment weight is used as a matching degree adjustment value;

[0040] The result of adding the reference matching degree and the matching degree adjustment value is used as the corrected matching degree between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate;

[0041] A result of normalizing the average of the corrected matching degrees between the pixel point on the non-reference coordinate and the pixel point on each reference coordinate is used as the suspected surface defect degree of the pixel point on the non-reference coordinate;

[0042] Evenly divide the value range of the suspected surface defect degree into a second preset number of target intervals from small to large, and obtain the number of suspected surface defect degrees contained in each target interval as the second number corresponding to the target interval;

[0043] Obtain the difference of the second quantity between each target interval and its previous adjacent target interval, both as the second difference;

[0044] The dividing value between the two target intervals corresponding to the largest second difference is used as the threshold value of the suspected surface defect degree;

[0045] When the suspected surface defect level is greater than the suspected surface defect level threshold, the pixel point on the corresponding non-reference coordinate is used as the surface defect pixel point of the sight lens;

[0046] The area formed by the initial surface defect pixel points and the surface defect pixel points is used as the surface defect area of ​​the sight lens.

[0047] Furthermore, the method for obtaining the overall interference degree of the surface is:

[0048] For any internal defect area, obtaining the average grayscale value of the pixel points in the backlight image corresponding to the longest wavelength of the internal defect area as the first grayscale value of the internal defect area;

[0049] Obtaining an average grayscale value of pixels in the backlight image corresponding to the shortest wavelength of the internal defect area as a second grayscale value of the internal defect area;

[0050] Negatively correlating and normalizing the difference between the first grayscale value and the second grayscale value, and using the result as the stability of the internal defect area;

[0051] The normalized result of the area of ​​the internal defect region and the average of the stability level are obtained as the overall surface interference level of the internal defect region.

[0052] Furthermore, the method for obtaining the interference degree of the surface defects is:

[0053] When the coordinates of the front light image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel point, the coordinates of the front light image in the two-dimensional coordinate system that are the same as the coordinates corresponding to the internal defect pixel point are taken as special coordinates; wherein the internal defect pixel point includes the initial internal defect pixel point;

[0054] For any special coordinate, the internal defect area where the internal defect pixel point on the special coordinate is located is used as the reference internal defect area, and the line segments from the centroid of the reference internal defect area to each edge pixel point thereof are obtained as reference line segments;

[0055] The reference line segment passing through the internal defect pixel at the special coordinate is used as the target line segment;

[0056] The grayscale values ​​of the pixels that the target line segment passes through in the back-illuminated fusion image are subjected to curve fitting according to the sequence from the centroid to the edge pixels of the target line segment to obtain the target curve;

[0057] The absolute value of the tangent slope of the grayscale value corresponding to the pixel point at the special coordinate on the target curve is used as the surface defect interference degree of the pixel point at the special coordinate;

[0058] When the coordinates of the current illumination image in the two-dimensional coordinate system are different from the coordinates corresponding to the internal defect pixel points, the surface defect interference degree of the pixel points at the corresponding coordinates is set to 0 by default.

[0059] Furthermore, the method for obtaining the defects in the sight lens according to the grayscale distribution of the backlight fusion image and the surface defect area in the frontlight image at each wavelength is:

[0060] For a front-light image at any wavelength, the average of the grayscale values ​​of the corresponding pixels of the surface defect area in the front-light image is used as the surface defect grayscale reference value of the front-light image;

[0061] Obtaining the average grayscale value of all pixels in the front-light image except the pixels corresponding to the surface defect area as a normal grayscale reference value of the front-light image;

[0062] Obtaining a difference between a surface defect grayscale reference value and a normal grayscale reference value of the front-light image as a second characteristic value of the front-light image;

[0063] The frontlight image at the wavelength corresponding to the largest second eigenvalue is used as the frontlight fusion image;

[0064] The backlight fusion image and the frontlight fusion image are fused into one image as the target image;

[0065] Perform defect detection on the target image to obtain defects in the sight lens.

[0066] In a second aspect, another embodiment of the present invention provides a visual inspection device for a sight lens, the device comprising: a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, the steps of any one of the above methods are implemented.

[0067] In a third aspect, another embodiment of the present invention provides a visual inspection system for a sight lens, the system comprising:

[0068] An image acquisition module, used for acquiring front-light images and back-light images of the sight lens at different wavelengths;

[0069] The backlight fusion image acquisition module is used to acquire the internal defect area of ​​the sight lens according to the gray value of each pixel in the backlight image at each wavelength; and acquire the backlight fusion image according to the gray distribution of the internal defect area in the backlight image at each wavelength;

[0070] A surface defect area acquisition module is used to acquire the surface defect area of ​​the sight lens based on the gradient value of each pixel point and the position of the edge pixel point in the front light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back light fusion image;

[0071] The processing module is used to obtain the defects in the sight lens according to the grayscale distribution of the backlight fusion image and the frontlight image of the surface defect area at each wavelength.

[0072] The present invention has the following beneficial effects:

[0073] The present invention obtains the internal defect area of ​​the sight lens according to the gray value of each pixel in the backlight image at each wavelength, which is conducive to the subsequent analysis of the interference of the internal defects on the surface defect recognition of the sight lens, so that the surface defects of the sight lens can be more accurately identified; in order to improve the accuracy of the subsequent acquisition of the defects of the sight lens, the backlight fusion image is obtained according to the grayscale distribution of the internal defect area in the backlight image at each wavelength, so that the internal defect area is most prominent, and at the same time it is conducive to a more detailed analysis of the interference degree of each internal defect pixel point in the internal defect area on the surface defect recognition; and then based on the gradient value of each pixel point in the frontlight image at each wavelength and the position of the edge pixel point, the size of each internal defect area, each internal defect area, The surface defect area of ​​the sight lens is accurately obtained by the grayscale difference in the backlight image corresponding to the longest wavelength and the shortest wavelength of the defect area, and the grayscale distribution of the internal defect area in the backlight fusion image, which effectively reduces the interference of the internal defect area on the identification of the surface defect area; improves the integrity and accuracy of the surface defect area; in order to accurately obtain the defects in the sight lens, the frontlight fusion image is accurately determined according to the grayscale distribution of the surface defect area in the frontlight image at each wavelength, so that the surface defect area is most prominent; the backlight fusion image and the frontlight fusion image are further fused to enhance the visibility of the defects in the sight lens, improve the accuracy of the sight lens defect detection, and then accurately obtain the defects in the sight lens. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0075] Figure 1A schematic flow chart of a method for visual inspection of a sight lens provided by one embodiment of the present invention;

[0076] Figure 2 A flow chart of a method for obtaining a surface defect area provided by an embodiment of the present invention;

[0077] Figure 3 A flow chart of a method for obtaining a corrected matching degree provided by an embodiment of the present invention;

[0078] Figure 4 A structural diagram of a visual inspection system for a sight lens provided by one embodiment of the present invention;

[0079] Figure 5 A schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0080] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the visual inspection method, device and system of a sight lens proposed by the present invention, its specific implementation, structure, features and effects, in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0081] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0082] The following is a detailed description of a method, device and system for visual inspection of a sight lens provided by the present invention in conjunction with the accompanying drawings.

[0083] Embodiment 1:

[0084] The present invention proposes a method for visual inspection of sight lenses, see Figure 1 , which shows a schematic flow chart of a visual inspection method for a sight lens provided by an embodiment of the present invention, the method comprising the following steps:

[0085] Step S1: Acquire the front-light image and back-light image of the sight lens at different wavelengths.

[0086] Specifically, the sight lens is fixed on the stage, and the sight lens is illuminated by front light and back light respectively to obtain the front light image and back light image of the sight lens. The specific operation is as follows: turn off the back light, turn on the front light, and illuminate the light source on the surface of the sight lens. When there are defects on the surface of the sight lens, the defects on the surface of the sight lens will generate scattered light; when there are no defects on the surface of the sight lens, the surface of the sight lens will generate reflected light; the CMOS image sensor only receives scattered light but not reflected light. Therefore, when there are defects on the surface of the sight lens, the scattered light is presented on the CMOS image sensor through the telecentric lens to form a front light image with a dark background and bright defects. Turn off the front light, turn on the back light, and the light source is incident from the back of the sight lens. When there is no defect inside the sight lens, the light source is transmitted; when there is a defect inside the sight lens, the light source is refracted; the CMOS image sensor only receives the transmitted light but not the refracted light. Therefore, when there is a defect inside the sight lens, the transmitted light passes through the telecentric lens and is presented on the CMOS image sensor to form a backlight image with a bright background and dark defects. Therefore, the frontlight image mainly detects surface defects of the sight lens, such as scratches and stains, etc.; the backlight image mainly detects internal defects of the sight lens, such as bubbles and cracks, etc.

[0087] The light source selected red low-angle ring light as the front light and red parallel light as the back light. The acquisition system selected an object-side telecentric lens with a working distance of 110 mm, a magnification of 0.8x, and a depth of field of 1.52 nm.

[0088] In actual situations, collecting front-light images and back-light images of the sight lens through a light source at a fixed wavelength will result in inaccurate positioning of some defects. At the same time, sight lenses with different structural properties have different reflection, scattering, and transmission phenomena at different wavelengths. Therefore, the defects obtained through the front-light images and back-light images of the sight lens at a fixed wavelength are inaccurate. In addition, this embodiment obtains front-light images and back-light images of the sight lens at different wavelengths.

[0089] In this embodiment, the wavelength range is set to 380nm to 740nm, 380nm is set as the initial wavelength, the step length is set to 5nm, and the wavelength is increased according to the step length from the initial wavelength until the wavelength is 740nm, and then the front light image and back light image of the sight lens at each wavelength are obtained in sequence. It is known that the wavelength range of 380nm to 740nm is the visible light wavelength range, and some sight lenses may be optimized for specific wavelengths, such as the green light band in sunlight. At this time, the wavelength range of 495nm to 570nm can be used for step-by-step collection, and the step length can also be adjusted. The implementer can set the wavelength range and step size according to the actual situation, and it is not limited here.

[0090] In order to facilitate the subsequent accurate and efficient identification of defects in the sight lens, the present embodiment performs grayscale processing on both the front light image and the back light image of the sight lens at different wavelengths. The grayscale processing is a well-known technology and will not be described in detail.

[0091] Step S2: according to the gray value of each pixel in the backlight image at each wavelength, the internal defect area of ​​the sight lens is obtained; according to the gray distribution of the internal defect area in the backlight image at each wavelength, the backlight fusion image is obtained.

[0092] Specifically, in actual situations, changes in wavelength will change the light performance of the sight lens, such as the transmittance and reflectivity. Among them, the internal defects in the sight lens change more obviously with the change of wavelength, and are minimally affected by surface defects. Since the principle of the front light image is based on the performance of reflected light, when the sight lens has internal defects such as bubbles or inclusions, it will cause abnormal reflection or scattering of the front light to be weakened, and then cause the surface defects in the acquired front light image to be inaccurate, which indirectly shows that the detection of surface defects of the sight lens is greatly affected by internal defects. Therefore, this embodiment first obtains the internal defect area of ​​the sight lens according to the grayscale value of each pixel in the backlight image at each wavelength, and then optimizes the recognition effect of surface defects in the front light image based on the performance of the internal defect area, and finally optimizes the fusion result of the front light image and the backlight image to accurately obtain the defects of the sight lens.

[0093] In order to accurately reflect the internal defect area, so as to more accurately identify the surface defects of the sight lens and obtain the defects of the sight lens in the future, the present embodiment analyzes the grayscale distribution of the internal defect area in the backlight image at each wavelength. The more obvious the internal defect area is in the backlight image, the more accurate the backlight image at the corresponding wavelength is in the subsequent identification of the defects of the sight lens. Therefore, the present embodiment obtains the backlight fusion image according to the grayscale distribution of the internal defect area in the backlight image at each wavelength.

[0094] Preferably, in a method that can be implemented in this embodiment, the method for obtaining the internal defect area is: obtaining the mean grayscale value of all pixels in the backlight image at each wavelength as the target grayscale value of the backlight image at each wavelength; constructing a two-dimensional coordinate system with the designated position of the backlight image at each wavelength as the origin; wherein the size of the backlight image at each wavelength is the same; in this embodiment, the designated position is set to the lower left corner of each backlight image, and the implementer can set the designated position according to the actual situation, which is not limited here. It should be noted that the coordinate points corresponding to the pixels at the same position in the backlight image at each wavelength are the same. For any coordinate in the two-dimensional coordinate system, the difference between the grayscale value of the pixel point in the backlight image of the coordinate at each wavelength and the target grayscale value of the backlight image at the same wavelength is obtained as the grayscale difference value of the pixel point at the coordinate at each wavelength; the grayscale difference values ​​are arranged in ascending order according to the corresponding wavelength to obtain a grayscale difference value sequence as the wavelength-grayscale difference value sequence of the pixel point at the coordinate; wherein, when the area where the pixel point at a certain coordinate is located is the normal area of ​​the sight lens, the curve fitted by the wavelength-grayscale difference value sequence of the pixel point at the coordinate is almost a horizontal straight line;

[0095] In actual situations, changes in the wavelength of the backlight will significantly affect the light transmittance of the sight lens. When the wavelength of the backlight is longer, the edge of the internal defect is softer; when the wavelength of the backlight is shorter, the edge of the internal defect is sharper. Therefore, it can be inferred that the internal defects of the sight lens are more obvious when the wavelength of the backlight is shorter. In order to preliminarily and accurately determine the internal defect pixel points of the sight lens, this embodiment sets the initial wavelength of 380nm as the specified wavelength, and then threshold-segments the backlight image at the specified wavelength, and uses the pixel point with a grayscale value of 0 as the initial internal defect pixel point of the sight lens; wherein, threshold segmentation is a well-known technology and will not be described in detail. It should be noted that the position of the initial internal defect pixel point must be the internal defect area of ​​the sight lens. Therefore, the pixel points in the backlight image at each wavelength corresponding to the coordinates of the initial internal defect pixel point are all initial internal defect pixels;

[0096] It is known that backlights of different wavelengths have different effects on the light transmittance of the sight lens. In order to avoid incomplete identification of internal defect pixels in the sight lens, this embodiment compares the non-initial internal defect pixels with the initial internal defect pixels, screens out the internal defect pixels among the non-initial internal defect pixels, and accurately obtains the internal defect area of ​​the sight lens. Therefore, the coordinates corresponding to the initial internal defect pixel points are all taken as the target coordinates. For any non-target coordinate, the matching degree of the wavelength-grayscale difference value sequence between the pixel point on the non-target coordinate and the pixel point on each target coordinate is obtained through the dynamic time warping (DTW) algorithm, which is used as the suspected internal defect reference value of the pixel point on the non-target coordinate; the larger the suspected internal defect reference value, the more similar the wavelength-grayscale difference value sequence of the pixel point on the non-target coordinate is to the wavelength-grayscale difference value sequence corresponding to the initial internal defect pixel point, which indirectly indicates that the pixel point on the non-target coordinate is more likely to be an internal defect pixel point; among them, the dynamic time warping (DTW) algorithm is a well-known technology and will not be described in detail. In order to comprehensively analyze the possibility that the pixel point on the non-target coordinate is an internal defect pixel point, the result of normalizing the mean value of the suspected internal defect reference value is used as the suspected internal defect degree of the pixel point on the non-target coordinate; this embodiment normalizes the mean value of the suspected internal defect reference value through the norm normalization function; wherein, the greater the suspected internal defect degree, the more likely the pixel point on the non-target coordinate is to be an internal defect pixel point of the sight lens, and then this embodiment obtains the internal defect pixel point of the sight lens based on the suspected internal defect degree; finally, the area formed by the initial internal defect pixel point and the internal defect pixel point is used as the internal defect area of ​​the sight lens. It should be noted that the connected domain judgment is used in the process of obtaining the internal defect area, wherein the acquisition of the connected domain is a well-known technology and will not be repeated.

[0097] In one possible implementation of this embodiment, the method for obtaining the internal defect pixel points of the sight lens based on the suspected internal defect degree is: the value range of the suspected internal defect degree is evenly divided into a first preset number of reference intervals from small to large. It is known that the value range of the suspected internal defect degree is 0 to 1. In this embodiment, the first preset number is set to 10. The implementer can set the size of the first preset number according to the actual situation, and it is not limited here. Therefore, the value range of the suspected internal defect degree is evenly divided into 10 reference intervals from small to large, which are [0~0.1), [0.1~0.2),…, [0.9~1]. Obtain the number of suspected internal defect levels contained in each reference interval as the first number of the corresponding reference interval; obtain the absolute value of the difference between each reference interval and the first number of its previous adjacent reference interval, all as the first difference; use the dividing value between the two reference intervals corresponding to the largest first difference as the suspected internal defect level threshold; for example, if the first difference between [0.4~0.5) and [0.5,0.6) is the largest, then use 0.5 as the suspected internal defect level threshold. It should be noted that selecting the dividing value between the two reference intervals corresponding to the largest first difference as the suspected internal defect level threshold can more accurately distinguish the internal defect pixels of the sight lens from the normal pixels. When the suspected internal defect level is greater than the suspected internal defect level threshold, the pixel points on the corresponding non-target coordinates are used as the internal defect pixels of the sight lens, and the internal defect pixels are accurately screened out from the non-initial internal defect pixels.

[0098] Preferably, in a manner that can be implemented in this embodiment, the method for acquiring a backlight fusion image is: for a backlight image at any wavelength, taking the average of the grayscale values ​​of the pixels corresponding to the internal defect area in the backlight image as the internal defect grayscale reference value of the backlight image; acquiring the average of the grayscale values ​​of all the pixels in the backlight image except the pixels corresponding to the internal defect area as the normal grayscale reference value of the backlight image; when the difference between the internal defect grayscale reference value and the normal grayscale reference value of the backlight image is greater, it means that the internal defect area is more obvious in the backlight image, and then this embodiment acquires the absolute value of the difference between the internal defect grayscale reference value and the normal grayscale reference value of the backlight image as the first eigenvalue of the backlight image; the larger the first eigenvalue, the more likely the backlight image is to be a backlight fusion image that is subsequently fused to accurately acquire the defects of the sight lens; therefore, this embodiment uses the backlight image at the wavelength corresponding to the largest first eigenvalue as the backlight fusion image.

[0099] Step S3: Based on the gradient value of each pixel point and the position of the edge pixel point in the front light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back light fusion image, the surface defect area of ​​the sight lens is obtained.

[0100] In actual situations, as the wavelength of the front light changes, the surface defects of the sight lens may be enhanced or weakened in the front light image, that is, in the process of the change of the wavelength of the front light, the edge of the surface defect in the front light image may change to clear or blurred. Therefore, this embodiment first obtains the edge pixel points in the front light image at each wavelength through the Canny edge detection algorithm, and then preliminarily determines the initial surface defect pixel points of the sight lens based on the position of the edge pixel points in the front light image at each wavelength. Finally, based on the similarity of the gradient values ​​of the non-initial surface defect pixel points and the initial surface defect pixel points in the front light image at each wavelength, the surface defect pixel points in the non-initial surface defect pixel points are screened out, so that the surface defect area of ​​the sight lens can be accurately detected. Among them, the Canny edge detection algorithm is a well-known technology and will not be described in detail. It should be noted that the gradient value of each pixel point in the front light image at each wavelength can be obtained through the Canny edge detection algorithm.

[0101] Considering that the internal defects of the sight lens will interfere with the identification of surface defects, that is, weaken the performance of surface defects in the front-light image. Therefore, this embodiment further combines the size of each internal defect area, the grayscale difference of each internal defect area in the back-light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back-light fusion image, to optimize the identification of the surface defect area of ​​the sight lens, and more accurately obtain the surface defect area of ​​the sight lens. Furthermore, this embodiment obtains the surface defect area of ​​the sight lens based on the gradient value of each pixel point and the position of the edge pixel point in the front-light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back-light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back-light fusion image.

[0102] Preferably, in one possible implementation of this embodiment, the method for obtaining the surface defect area can be found in Figure 2 , which shows a flow chart of a method for obtaining a surface defect area provided in this embodiment, the method comprising the following steps:

[0103] Step S201: Acquire initial surface defect pixel points.

[0104] First, a two-dimensional coordinate system is constructed with the designated position of the frontlight image at each wavelength as the origin. The designated position here is the same as the designated position in step S2, because the size of the frontlight image and the backlight image at each wavelength is the same, so the coordinate distribution of the pixels in the frontlight image is exactly the same as the coordinate distribution of the pixels in the backlight image. It is known that the frontlight image is a dark background with bright defects, so the edge pixel points in the backlight image are more likely to be the surface defect pixel points of the sight lens. Considering that the edge pixel points in the frontlight image obtained by frontlights of different wavelengths will be different, in order to accurately obtain the surface defect pixel points of the sight lens, when the pixels at the same coordinates in the frontlight image at each wavelength are all edge pixels, the pixels at the corresponding coordinates are used as the initial surface defect pixel points of the sight lens.

[0105] At this point, the initial surface defect pixel points of the sight lens are determined.

[0106] Step S202: Obtain a reference matching degree.

[0107] It is known that different wavelengths of front light will affect the performance of the surface defect pixel points of the sight lens. In order to completely identify the surface defect pixel points of the sight lens, the gradient values ​​of the corresponding pixels in the front light image of each coordinate in the two-dimensional coordinate system at each wavelength are arranged in order from small to large according to the wavelength, and the wavelength-gradient value sequence of the pixel points at each coordinate is obtained; then the coordinates corresponding to the initial surface defect pixel points are used as reference coordinates, and for any non-reference coordinate and any reference coordinate, the matching degree of the wavelength-gradient value sequence between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate is obtained by the dynamic time warping (DTW) algorithm as the reference matching degree. The larger the reference matching degree, the more similar the wavelength-gradient value sequence of the pixel point on the non-reference coordinate is to the pixel point on the reference coordinate, which indirectly indicates that the pixel point on the non-reference coordinate is more likely to be the surface defect pixel point of the sight lens.

[0108] Step S203: Obtain the corrected matching degree.

[0109] Taking into account that the internal defect area interferes with the identification of the surface defect area of ​​the sight lens, this embodiment corrects the reference matching degree based on the internal defect area to obtain the corrected matching degree, which is conducive to the subsequent accurate analysis of whether the pixel point on the non-reference coordinate is the surface defect pixel point of the sight lens.

[0110] Preferably, in one possible implementation of this embodiment, the method for obtaining the corrected matching degree can be found in Figure 3 , which shows a flow chart of a method for obtaining a corrected matching degree provided in this embodiment, the method comprising the following steps:

[0111] Step S203 - 1 : Obtain the overall surface interference degree of each internal defect region according to the size of each internal defect region and the grayscale difference of each internal defect region in the backlight image corresponding to the longest wavelength and the shortest wavelength.

[0112] The area size of each internal defect area is obtained by a contour algorithm, wherein the contour algorithm is a well-known technology and will not be described in detail. The larger the area of ​​a certain internal defect area, the greater the impact of the internal defect area on the front light, and the greater the interference generated when identifying the surface defect pixel points of the sight lens; at the same time, when the grayscale difference between the longest wavelength and the shortest wavelength of the internal defect area in the backlight image corresponding to the internal defect area is smaller, it means that the internal defect area is more stable, which indirectly reflects that the internal defect area generates greater interference when identifying the surface defect pixel points of the sight lens. Therefore, this embodiment obtains the overall surface interference degree of each internal defect area according to the size of each internal defect area and the grayscale difference between the longest wavelength and the shortest wavelength of each internal defect area in the backlight image corresponding to the longest wavelength. The greater the overall surface interference degree, the greater the interference generated by the corresponding internal defect area when identifying the surface defect pixel points of the sight lens.

[0113] Preferably, in a method that can be implemented in this embodiment, the method for obtaining the overall interference degree of the surface is: for any internal defect area, the average grayscale value of the pixel points in the backlight image corresponding to the longest wavelength of the internal defect area is obtained as the first grayscale value of the internal defect area; the average grayscale value of the pixel points in the backlight image corresponding to the shortest wavelength of the internal defect area is obtained as the second grayscale value of the internal defect area; when the first grayscale value and the second grayscale value are more equal, it means that the internal defect area is more stable and the interference caused in identifying the surface defect pixel points is greater, that is, the appearance of the surface defect pixel points in the frontlight image is weakened. In addition, this embodiment negatively correlates and normalizes the absolute value of the difference between the first grayscale value and the second grayscale value as the stability degree of the internal defect area; the greater the stability, the greater the interference degree of the internal defect area to the surface defect recognition in the frontlight image. It is known that the larger the area of ​​the internal defect region, the greater the interference of the internal defect region on the recognition of surface defects in the front light image. Then, the normalized result of the area of ​​the internal defect region and the average of the stability degree are obtained as the overall surface interference degree of the internal defect region.

[0114] Among them, the calculation formula for the overall interference degree of the surface is: In the formula, A n is the overall surface disturbance degree of the nth internal defect area; s n is the area of ​​the nth internal defect area; h n,1is the first gray value of the nth internal defect area; h n,2 is the second gray value of the nth internal defect area; || is the absolute value function; exp(-|h n,1 -h n,2 |) is the stability of the nth internal defect area; norm is the normalization function; exp is the exponential function with a natural constant as the base.

[0115] At this point, the overall surface disturbance level of each internal defect area is obtained.

[0116] Step S203-2: Obtain the surface defect interference degree of the pixel at each coordinate based on the positional relationship between the coordinates of the front-light image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, and the grayscale distribution of the internal defect area where the internal defect pixel points are located in the back-light fusion image.

[0117] In order to accurately identify the surface defect pixels in the front-light image, this embodiment first determines the pixels in the front-light image that coincide with the internal defect pixels based on the positional relationship between the coordinates of the front-light image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixels, and then analyzes the interference degree of the internal defect pixels on the identification of the surface defect pixels in combination with the grayscale distribution of the internal defect pixels in the back-light fusion image, which is conducive to the subsequent accurate acquisition of the possibility that each non-initial surface defect pixel is a surface defect pixel. Furthermore, this embodiment obtains the surface defect interference degree of the pixel at each coordinate based on the positional relationship between the coordinates of the front-light image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixels, and the grayscale distribution of the internal defect area where the internal defect pixels are located in the back-light fusion image, accurately reflecting the interference degree of the internal defects on the pixel at each coordinate when analyzing whether it is a surface defect pixel.

[0118] Preferably, in a manner that can be implemented in this embodiment, the method for obtaining the degree of interference of surface defects is as follows: when the coordinates of the front-light image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel points, the coordinates of the front-light image in the two-dimensional coordinate system that are the same as the coordinates corresponding to the internal defect pixel points are all taken as special coordinates; wherein the internal defect pixel points include initial internal defect pixel points; for any special coordinate, the internal defect area where the internal defect pixel point on the special coordinate is located is taken as the reference internal defect area, the centroid and edge pixel points of the reference internal defect area are obtained by a contour algorithm, and then the line segments from the centroid of the reference internal defect area to each edge pixel point are obtained, and are all taken as reference line segments; the reference line segment passing through the internal defect pixel point on the special coordinate is taken as the target line segment; the grayscale values ​​of the pixels through which the target line segment passes in the back-light fusion image are curve-fitted according to the order of the target line segment from the centroid to the edge pixel points to obtain the target curve; wherein the method of fitting the curve is a well-known technology and will not be described in detail. The absolute value of the tangent slope of the grayscale value corresponding to the pixel point at the special coordinate on the target curve is used as the surface defect interference degree of the pixel point at the special coordinate; the greater the surface defect interference degree, the greater the influence of the internal defect pixel point corresponding to the special coordinate on the performance of the front light, and the greater the interference degree of the internal defect on the pixel point at the special coordinate when identifying whether it is a surface defect pixel point;

[0119] When the coordinates of the front-light image in the two-dimensional coordinate system are different from the coordinates corresponding to the internal defect pixel points, it means that the internal defects will not affect the grayscale values ​​of the pixels in the front-light image. In this embodiment, the surface defect interference degree of the pixels at the corresponding coordinates, i.e., the coordinates that are not the same as the coordinates corresponding to the internal defect pixel points, is set to 0 by default.

[0120] At this point, the surface defect interference degree of the pixel point at each coordinate is obtained.

[0121] Step S203-3: Obtain the target surface defect degree.

[0122] In order to accurately indicate the degree of interference of internal defects on the pixel point at each coordinate, for any coordinate in the two-dimensional coordinate system, the product of the surface defect interference degree of the pixel point at the coordinate and the overall surface interference degree of the internal defect area where the pixel point at the coordinate is located is used as the target surface defect degree of the pixel point at the coordinate. The greater the target surface defect degree, the greater the degree of internal defect interference the pixel point at the coordinate is subjected to when analyzing whether it is a surface defect pixel point. It should be noted that if the pixel point at the coordinate is not in the internal defect area, the target surface defect degree of the pixel point at the coordinate is defaulted to 0.

[0123] At this point, the target surface defect degree of the pixel point at each coordinate is obtained.

[0124] Step S203-4: Obtain the corrected matching degree.

[0125] For a pixel point on a non-reference coordinate and a pixel point on a reference coordinate, the result of adding the target surface defect degree of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate and then normalizing it is used as the adjustment weight; the larger the adjustment weight, the greater the degree of interference of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate by the internal defect. In order to reduce the weakening effect of the internal defect on the recognition of the surface defect, the product of the reference matching degree of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate and the adjustment weight is obtained as the matching adjustment value; then the result of adding the reference matching degree of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate and the matching adjustment value is used as the corrected matching degree between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate. The larger the corrected matching degree, the more similar the performance of the non-initial surface defect pixel point corresponding to the non-reference coordinate is to the initial surface defect pixel point corresponding to the reference coordinate, and the non-initial surface defect pixel point corresponding to the non-reference coordinate is more likely to be the surface defect pixel point of the sight lens.

[0126] The calculation formula for the corrected matching degree is: Where D j,m ′ is the corrected matching degree between the pixel point on the jth non-reference coordinate and the pixel point on the mth reference coordinate; D j,m is the reference matching degree between the pixel point on the jth non-reference coordinate and the pixel point on the mth reference coordinate; is the target surface defect degree of the pixel point on the jth non-reference coordinate; is the target surface defect degree of the pixel point on the mth reference coordinate; norm is the normalization function; To adjust the weight; Adjust the value for the match.

[0127] Step S204: Acquire surface defect pixels.

[0128] In order to analyze the possibility that the pixel point on each non-reference coordinate is a surface defect pixel point, for any non-reference coordinate, the mean of the corrected matching degree between the pixel point on the non-reference coordinate and the pixel point on each reference coordinate is normalized as the suspected surface defect degree of the pixel point on the non-reference coordinate. The greater the suspected surface defect degree, the more likely the pixel point on the non-reference coordinate is to be a surface defect pixel point. It should be noted that in this embodiment, the mean of the corrected matching degree between the pixel point on the non-reference coordinate and the pixel point on each reference coordinate is normalized by the norm normalization function. At this point, the suspected surface defect degree of each pixel point on the non-reference coordinate is obtained. Among them, the value range of the suspected surface defect degree is 0 to 1.

[0129] In order to filter out the surface defect pixels among the non-initial surface defect pixels by the suspected surface defect degree, so as to make the surface defect recognition of the sight lens more complete, the present embodiment divides the value range of the suspected surface defect degree from small to large into a second preset number of target intervals. The present embodiment sets the second preset number to 10. The implementer can set the size of the second preset number according to the actual situation, which is not limited here. Therefore, the value range of the suspected surface defect degree is evenly divided into 10 target intervals from small to large, which are [0~0.1), [0.1~0.2), …, [0.9~1]. The number of suspected surface defect degrees contained in each target interval is obtained as the second number of the corresponding target interval; the absolute value of the difference between the second number of each target interval and its previous adjacent target interval is obtained, and both are used as the second difference; the boundary value between the two target intervals corresponding to the largest second difference is used as the threshold value of the suspected surface defect degree. When the suspected surface defect degree is greater than the suspected surface defect degree threshold, the pixel point on the corresponding non-reference coordinate is used as the surface defect pixel point of the sight lens; the surface defect pixel point is accurately screened out from the non-initial surface defect pixel points.

[0130] Step S205: Acquire the surface defect area.

[0131] The area formed by the initial surface defect pixel points and the surface defect pixel points is used as the surface defect area of ​​the sight lens. It should be noted that the connected domain determination is used in the process of obtaining the surface defect area.

[0132] Step S4: Obtain the defects in the sight lens according to the grayscale distribution of the backlight fusion image and the surface defect area in the frontlight image at each wavelength.

[0133] In order to enhance the visibility of defects in the sight lens and improve the accuracy of defect detection in the sight lens, this embodiment first obtains a frontlight fusion image based on the grayscale distribution of the surface defect area in the frontlight image at each wavelength; then the frontlight fusion image and the backlight fusion image are fused into one image through an image fusion algorithm; wherein the image fusion algorithm is a well-known technology and will not be described in detail. Finally, the fused image is defect-detected to ensure the integrity and accuracy of the defects and accurately obtain the defects in the sight lens.

[0134] Preferably, in a manner that can be implemented in this embodiment, the method for acquiring a frontlight fusion image is as follows: for a frontlight image at any wavelength, the average of the grayscale values ​​of the pixels corresponding to the surface defect area in the frontlight image is used as the surface defect grayscale reference value of the frontlight image; the average of the grayscale values ​​of all pixels in the frontlight image except the pixels corresponding to the surface defect area is obtained as the normal grayscale reference value of the frontlight image; when the difference between the surface defect grayscale reference value and the normal grayscale reference value of the frontlight image is greater, it means that the surface defect area is more obvious in the frontlight image, and then this embodiment obtains the absolute value of the difference between the surface defect grayscale reference value and the normal grayscale reference value of the frontlight image as the second eigenvalue of the frontlight image; the larger the second eigenvalue, the more likely the frontlight image is to be a frontlight fusion image that is subsequently fused to accurately obtain the defects of the sight lens; therefore, this embodiment uses the frontlight image at the wavelength corresponding to the largest second eigenvalue as the frontlight fusion image.

[0135] The backlight fusion image and the frontlight fusion image are fused into one image as the target image through the image fusion algorithm; the target image is subjected to defect detection, and then the defects in the sight lens are obtained, so that the defect identification of the sight lens is more accurate and complete, and then the quality of the sight lens is accurately detected.

[0136] In summary, the present embodiment obtains the frontlight image and backlight image of the sight lens; obtains the internal defect area according to the grayscale value of the pixel in the backlight image; obtains the backlight fusion image according to the grayscale distribution of the internal defect area in the backlight image at each wavelength; obtains the surface defect area based on the gradient value of the pixel in the frontlight image and the position of the edge pixel, the size of the internal defect area and the grayscale distribution in the backlight fusion image; obtains the defects in the sight lens according to the backlight fusion image and the grayscale distribution of the surface defect area in the frontlight image at each wavelength. The present invention obtains the surface defect area on the basis of first obtaining the internal defect area of ​​the sight lens, reduces the interference of the internal defects on the surface defect recognition, and improves the accuracy of obtaining the defects of the sight lens.

[0137] Embodiment 2:

[0138] The present invention also proposes a visual inspection system for sight lenses, see Figure 4 , which shows a structural diagram of a visual inspection system for a sight lens provided by an embodiment of the present invention, the system includes: an image acquisition module 10, a backlight fusion image acquisition module 20, a surface defect area acquisition module 30 and a processing module 40.

[0139] The image acquisition module 10 is used to acquire the front-light image and the back-light image of the sight lens at different wavelengths.

[0140] The backlight fusion image acquisition module 20 is used to obtain the internal defect area of ​​the sight lens according to the grayscale value of each pixel in the backlight image at each wavelength; and to obtain the backlight fusion image according to the grayscale distribution of the internal defect area in the backlight image at each wavelength.

[0141] The surface defect area acquisition module 30 is used to obtain the surface defect area of ​​the sight lens based on the gradient value of each pixel point and the position of the edge pixel point in the front light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back light fusion image.

[0142] The processing module 40 is used to obtain the defects in the sight lens according to the backlight fusion image and the grayscale distribution of the surface defect area in the frontlight image at each wavelength.

[0143] It should be noted that: the system provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the visual inspection system for a sight lens provided in the above embodiment and the visual inspection method embodiment for a sight lens belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0144] Embodiment 3:

[0145] The present invention also proposes a visual inspection device for a sight lens, the device comprising a memory and a processor, wherein the memory stores an executable program code, and the processor is used to call and execute the executable program code to perform a visual inspection method for a sight lens provided in an embodiment of the present application. The device can be a chip, a component or a module, and the chip can include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a visual inspection method for a sight lens provided in the above embodiment.

[0146] In addition, the present application embodiment also protects a computer device, see Figure 5 The computer device includes a memory 401, a processor 402, and a computer program 403 stored in the memory 401 and running on the processor 402, wherein when the processor 402 executes the computer program 403, the computer device can execute any one of the visual inspection methods for the sight lens introduced above.

[0147] Embodiment 4:

[0148] This embodiment also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is run on a computer, the computer executes the above-mentioned related method steps to implement a visual inspection method for a sight lens provided in the above embodiment.

[0149] Embodiment 5:

[0150] This embodiment also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement a visual inspection method for a sight lens provided in the above-mentioned embodiment.

[0151] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0152] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0153] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

Claims

1. A method for visual inspection of a sight lens, characterized in that: The method comprises the following steps: Acquire front-light images and back-light images of the sight lens at different wavelengths; According to the gray value of each pixel in the backlight image at each wavelength, the internal defect area of ​​the sight lens is obtained; according to the gray distribution of the internal defect area in the backlight image at each wavelength, the backlight fusion image is obtained; Based on the gradient value of each pixel point and the position of the edge pixel point in the front-light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back-light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back-light fusion image, the surface defect area of ​​the sight lens is obtained; The defects in the sight lens are obtained based on the grayscale distribution of the backlight fusion image and the frontlight image of the surface defect area at each wavelength.

2. A method for visual inspection of a sight lens as claimed in claim 1, characterized in that: The method for obtaining the internal defect area is: Obtain the mean grayscale value of all pixels in the backlight image at each wavelength as the target grayscale value of the backlight image at each wavelength; A two-dimensional coordinate system is constructed with the designated position of the backlight image at each wavelength as the origin; wherein the size of the backlight image at each wavelength is the same; For any coordinate in the two-dimensional coordinate system, obtain the difference between the grayscale value of the pixel point in the backlight image at each wavelength and the target grayscale value of the backlight image at the same wavelength as the grayscale difference value of the pixel point at the coordinate at each wavelength; Arrange the grayscale difference values ​​in ascending order according to the corresponding wavelengths to obtain a grayscale difference value sequence as the wavelength-grayscale difference value sequence of the pixel point at the coordinate; The pixel points with a gray value of 0 after threshold segmentation of the backlight image at the specified wavelength are used as the initial internal defect pixel points of the sight lens; The coordinates corresponding to the initial internal defect pixel points are all used as the target coordinates. For any non-target coordinate, the DTW algorithm is used to obtain the matching degree of the wavelength-grayscale difference value sequence between the pixel point on the non-target coordinate and the pixel point on each target coordinate, which are all used as the suspected internal defect reference value of the pixel point on the non-target coordinate; Normalizing the average of the suspected internal defect reference values ​​as the suspected internal defect degree of the pixel point at the non-target coordinate; Obtaining internal defect pixel points of the sight lens based on the suspected internal defect degree; The area formed by the initial internal defect pixel points and the internal defect pixel points is used as the internal defect area of ​​the sight lens.

3. A method for visual inspection of a sight lens as claimed in claim 2, characterized in that: The method for obtaining the internal defect pixel points of the sight lens based on the suspected internal defect degree is: Evenly divide the value range of the suspected internal defect degree into a first preset number of reference intervals from small to large, and obtain the number of suspected internal defect degrees contained in each reference interval as the first number of the corresponding reference interval; Obtain the difference of the first quantity between each reference interval and its previous adjacent reference interval, both as the first difference; The dividing value between the two reference intervals corresponding to the largest first difference is used as the threshold value of the suspected internal defect degree; When the suspected internal defect level is greater than the suspected internal defect level threshold, the pixel point on the corresponding non-target coordinate is used as the internal defect pixel point of the sight lens.

4. A method for visual inspection of a sight lens as claimed in claim 2, characterized in that: The method for acquiring the backlight fusion image is as follows: For a backlight image at any wavelength, the average of the grayscale values ​​of the pixels corresponding to the internal defect area in the backlight image is used as the internal defect grayscale reference value of the backlight image; Obtaining the average grayscale value of all pixels in the backlight image except the pixels corresponding to the internal defect area as a normal grayscale reference value of the backlight image; Obtaining a difference between an internal defect grayscale reference value and a normal grayscale reference value of the backlight image as a first characteristic value of the backlight image; The backlight image at the wavelength corresponding to the largest first eigenvalue is used as the backlight fusion image.

5. A method for visual inspection of a sight lens as claimed in claim 2, characterized in that: The method for obtaining the surface defect area is: A two-dimensional coordinate system is constructed with the designated position of the front light image at each wavelength as the origin; wherein the size of the front light image and the back light image at each wavelength is the same; When the pixels at the same coordinates in the front light image at each wavelength are all edge pixels, the pixels at the corresponding coordinates are used as the initial surface defect pixels of the sight lens; Arrange the gradient values ​​of the pixels corresponding to each coordinate in the front light image at each wavelength in the two-dimensional coordinate system in ascending order according to the wavelength to obtain a wavelength-gradient value sequence of the pixels at each coordinate; The coordinates corresponding to the initial surface defect pixel points are all used as reference coordinates. For any non-reference coordinate and any reference coordinate, the matching degree of the wavelength-gradient value sequence between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate is obtained by the DTW algorithm as the reference matching degree; According to the size of each internal defect area and the grayscale difference of each internal defect area in the backlight image corresponding to the longest wavelength and the shortest wavelength, the overall surface interference degree of each internal defect area is obtained; According to the positional relationship between the coordinates of the front-light image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, and the grayscale distribution of the internal defect area where the internal defect pixel points are located in the back-light fusion image, the surface defect interference degree of the pixel points at each coordinate is obtained; For any coordinate in the two-dimensional coordinate system, the product of the surface defect interference degree of the pixel point at the coordinate and the surface overall interference degree of the internal defect area where the pixel point at the coordinate is located is used as the target surface defect degree of the pixel point at the coordinate; The target surface defect degree of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate are added and normalized, and the result is used as the adjustment weight; The product of the reference matching degree and the adjustment weight is used as a matching degree adjustment value; The result of adding the reference matching degree and the matching degree adjustment value is used as the corrected matching degree between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate; A result of normalizing the average of the corrected matching degrees between the pixel point on the non-reference coordinate and the pixel point on each reference coordinate is used as the suspected surface defect degree of the pixel point on the non-reference coordinate; Evenly divide the value range of the suspected surface defect degree into a second preset number of target intervals from small to large, and obtain the number of suspected surface defect degrees contained in each target interval as the second number corresponding to the target interval; Obtain the difference of the second quantity between each target interval and its previous adjacent target interval, both as the second difference; The dividing value between the two target intervals corresponding to the largest second difference is used as the threshold value of the suspected surface defect degree; When the suspected surface defect level is greater than the suspected surface defect level threshold, the pixel point on the corresponding non-reference coordinate is used as the surface defect pixel point of the sight lens; The area formed by the initial surface defect pixel points and the surface defect pixel points is used as the surface defect area of ​​the sight lens.

6. A method for visual inspection of a sight lens as claimed in claim 5, characterized in that: The method for obtaining the overall interference degree of the surface is: For any internal defect area, obtaining the average grayscale value of the pixel points in the backlight image corresponding to the longest wavelength of the internal defect area as the first grayscale value of the internal defect area; Obtaining an average grayscale value of pixels in the backlight image corresponding to the shortest wavelength of the internal defect area as a second grayscale value of the internal defect area; Negatively correlating and normalizing the difference between the first grayscale value and the second grayscale value, and using the result as the stability of the internal defect area; The normalized result of the area of ​​the internal defect region and the average of the stability level are obtained as the overall surface interference level of the internal defect region.

7. A method for visual inspection of a sight lens as claimed in claim 5, characterized in that: The method for obtaining the interference degree of the surface defects is: When the coordinates of the front light image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel point, the coordinates of the front light image in the two-dimensional coordinate system that are the same as the coordinates corresponding to the internal defect pixel point are taken as special coordinates; wherein the internal defect pixel point includes the initial internal defect pixel point; For any special coordinate, the internal defect area where the internal defect pixel point on the special coordinate is located is used as the reference internal defect area, and the line segments from the centroid of the reference internal defect area to each edge pixel point thereof are obtained as reference line segments; The reference line segment passing through the internal defect pixel at the special coordinate is used as the target line segment; The grayscale values ​​of the pixels that the target line segment passes through in the back-illuminated fusion image are subjected to curve fitting according to the sequence from the centroid to the edge pixels of the target line segment to obtain the target curve; The absolute value of the tangent slope of the grayscale value corresponding to the pixel point at the special coordinate on the target curve is used as the surface defect interference degree of the pixel point at the special coordinate; When the coordinates of the current illumination image in the two-dimensional coordinate system are different from the coordinates corresponding to the internal defect pixel points, the surface defect interference degree of the pixel points at the corresponding coordinates is set to 0 by default.

8. A method for visual inspection of a sight lens as claimed in claim 1, characterized in that: The method for obtaining the defects in the sight lens according to the grayscale distribution of the backlight fusion image and the surface defect area in the frontlight image at each wavelength is: For a front-light image at any wavelength, the average of the grayscale values ​​of the corresponding pixels of the surface defect area in the front-light image is used as the surface defect grayscale reference value of the front-light image; Obtaining the average grayscale value of all pixels in the front-light image except the pixels corresponding to the surface defect area as a normal grayscale reference value of the front-light image; Obtaining a difference between a surface defect grayscale reference value and a normal grayscale reference value of the front-light image as a second characteristic value of the front-light image; The frontlight image at the wavelength corresponding to the largest second eigenvalue is used as the frontlight fusion image; The backlight fusion image and the frontlight fusion image are fused into one image as the target image; Perform defect detection on the target image to obtain defects in the sight lens.

9. A visual inspection device for a sight lens, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When executing the computer program, the processor implements the steps of the visual inspection method of a sight lens as described in any one of claims 1 to 8.

10. A visual inspection system for a sight lens, characterized in that: The system comprises: An image acquisition module, used for acquiring front-light images and back-light images of the sight lens at different wavelengths; The backlight fusion image acquisition module is used to acquire the internal defect area of ​​the sight lens according to the gray value of each pixel in the backlight image at each wavelength; and acquire the backlight fusion image according to the gray distribution of the internal defect area in the backlight image at each wavelength; A surface defect area acquisition module is used to acquire the surface defect area of ​​the sight lens based on the gradient value of each pixel point and the position of the edge pixel point in the front light image at each wavelength, the size of each internal defect area, the grayscale difference of each internal defect area in the back light image corresponding to the longest wavelength and the shortest wavelength, and the grayscale distribution of the internal defect area in the back light fusion image; The processing module is used to obtain the defects in the sight lens according to the grayscale distribution of the backlight fusion image and the frontlight image of the surface defect area at each wavelength.

Citation Information

Patent Citations

  • Defect detection method for precision lens

    CN117686514A

  • Quality detection system based on computer vision

    CN118275439A

  • Defect inspection method and apparatus

    US20130343632A1

  • Light-receiving element and distance measurement module

    US20200028017A1