Resin lens spot defect detection device and method adopting cross contrast method
The device and method for detecting point defects in resin lenses using the cross-comparison method utilizes a rotating inspection platform and a vision inspection module, combined with a grating light source and an industrial camera, to achieve automated dust removal and high-accuracy detection of resin lenses, solving the problems of dust interference and single-shot imaging in existing technologies.
Patent Information
- Application Number
- CN202410614015.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-08-23
AI Technical Summary
Existing technologies for detecting defects in resin lenses, especially point defects, suffer from problems such as difficulty in distinguishing them due to dust interference, and the inability to fully image certain defects in a single imaging session, resulting in insufficient detection accuracy.
A device and method for detecting point defects in resin lenses using cross-comparison is presented. This method utilizes a rotating inspection platform, a vision inspection module, and a dust removal module. Two industrial cameras are used for image registration and cross-comparison, and a grating light source is combined to improve contrast, thereby achieving image correspondence before and after dust removal and detecting abnormal points.
It achieves automated dust removal and online detection of point defects in resin lenses with high accuracy, reduces labor costs, and effectively distinguishes dust from defects through cross-comparison, thus improving the accuracy of detection.
Smart Images

Figure CN118533868A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision detection, and in particular to a device and method for detecting point-shaped defects of a resin lens by using a cross-contrast method. Background Art
[0002] Lens quality inspection of glasses is the last and most critical link before lenses are put on the market. Currently, lens defect detection relies heavily on manual inspection. Lens defects are of various types, their locations are random, and the inspection standards are complex. There are few automated inspection equipment for lens defects on the market.
[0003] Most of the existing methods for detecting surface defects of resin lenses tend to detect the lenses by imaging them once. For example, the patent number is: CN 115825078 A "A resin lens defect detection device and method", which uses one-time imaging of the lens, and obtains accurate internal defects of the resin lens by comparing the lens image with surface defects eliminated with the original lens defect image; the patent number is: CN 113393438 A "A resin lens defect detection method based on convolutional neural network", which marks the defect position and category of the resin lens image, and finally outputs information such as defect category, position and confidence through neural network training and prediction. The shape and grayscale value of the dust in the image are similar to some point defects. Dust removal on the lens cannot completely remove the dust and may introduce new dust. The existing inventions are all single-shot imaging, which does not take into account the impact of dust on the detection results, and does not effectively distinguish point defects from dust; secondly, single imaging has the problem that some defects cannot be completely imaged. Summary of the invention
[0004] The purpose of the present invention is to address the deficiencies of the prior art and to provide a device and method for detecting point defects of a resin lens using a cross-comparison method.
[0005] The technical solution of the present invention to solve the above problem is: a device for detecting point defects of resin lenses using a cross-comparison method, comprising a rotating detection platform, a visual detection module, a dust removal module and an upper and lower unloading module;
[0006] The visual inspection module includes a first industrial camera and a second industrial camera;
[0007] Eight inspection stations are evenly distributed on the rotating inspection platform, the visual inspection module includes a first industrial camera and a second industrial camera, and the eight inspection stations are stations 1 to 8, wherein station 1 is a loading station, the first industrial camera is arranged above station 2, the dust removal module is arranged at station 3, the second industrial camera is arranged above station 4, and station 8 is an unloading station;
[0008] The loading and unloading module is used for loading and unloading lenses.
[0009] Furthermore, grating light sources are respectively provided directly below the No. 2 station and the No. 4 station.
[0010] Furthermore, the grating power supply is movably connected below the rotating detection platform through an adjusting mechanism.
[0011] Furthermore, the dust removal module includes an upper dust removal mechanism and a lower dust removal mechanism, the upper dust removal mechanism is arranged directly above the No. 3 station, and the lower dust removal mechanism is arranged directly below the No. 3 station.
[0012] A method for detecting point defects of a resin lens using a cross-comparison method comprises the following steps:
[0013] Step 1, aligning two cameras for photographing the lens before and after dust removal; specifically comprising the following steps:
[0014] Step 101: fix the calibration plate on the detection platform, switch the workstations, and take images of the calibration plate from two camera workstations respectively;
[0015] Step 102: extracting feature points from two calibration plate images respectively by using threshold segmentation;
[0016] Step 103: Select more than 9 corresponding feature points of the two calibration plate images, and calculate the center coordinates of each corresponding feature point;
[0017] Step 104: The homography transformation matrix H of the point pair can be calculated from the corresponding feature points on the calibration plate image;
[0018] Step 105: The two cameras at the front and rear dust removal stations respectively take images of the lens, apply the homography transformation matrix obtained in step 104 to the front and rear images, calculate the pixel offsets in the horizontal and vertical directions of the lens images after projection transformation, and complete the camera alignment;
[0019] Step 2, respectively obtain the dark field images of the resin lens before and after dust removal, apply projection transformation to the lens images before and after dust removal, so that the lens areas in the image correspond one to one, and use the cross-contrast method to generate a rectangular frame on the dark field image of the lens after dust removal with the defect position of the dark field image of the lens before dust removal as the center, and detect abnormal points in the rectangular frame area. If there are abnormal points in the rectangular frame, it is considered to be a lens defect, and if there are no defects in the rectangular frame, it is considered that the dust interference has been removed.
[0020] Furthermore, the specific process of step 104 is as follows:
[0021] The point pairs on two images with different viewpoints can be expressed by a projection transformation in homogeneous coordinates, namely:
[0022] X l =H*Xr
[0023] Where, X l , X r are the coordinates of corresponding points on the images of the same object taken by two cameras, and H is the projection transformation matrix of corresponding point pairs in the two images;
[0024] X l =H*X r The specific expression is:
[0025]
[0026] Where X l , X r are the corresponding points on the two images, H is the transformation matrix, A 2×2 represents the affine transformation parameters, T 2×1 Represents the translation transformation parameter, V T =[v1,v2] represents the edge intersection after transformation, s is the intersection with V T The relevant scaling factor can be normalized to make s=1, that is, the homography transformation matrix H can be expressed as:
[0027]
[0028] The transformation matrix H has 8 unknowns. Two sets of equations can be listed from a set of corresponding points, as shown below:
[0029]
[0030]
[0031]
[0032] Four sets of corresponding points can obtain the unique solution of the transformation matrix H.
[0033] Furthermore, step 2 specifically includes the following steps:
[0034] Step 201, taking four lens grating modulation images before and after dust removal;
[0035] Step 202, performing lens image preprocessing, lens dark field image stitching and lens image defect extraction on the lens grating modulation images before and after dust removal respectively;
[0036] Step 203: cross-comparison is performed on the defective areas of the lens before and after dust removal, and the projection transformation matrix H obtained in the previous registration step 104 is applied to the resin lens images before and after dust removal, so that the lens areas of the before and after images correspond one to one; a rectangular frame is generated on the dark field image of the lens after dust removal with the defect position of the lens before dust removal as the center, and abnormal points are detected in the rectangular frame area. If there are abnormal points in the rectangular frame, it is considered to be a lens defect, and if there are no defects in the rectangular frame, it is considered that the dust interference has been removed.
[0037] Furthermore, the specific process of lens image preprocessing is as follows:
[0038] Step 2021a: convolve the four lens grating modulation images with the first-order gradient respectively to obtain the grating edge in the image;
[0039] Step 2021b: In view of the misalignment of the grating at the edge of the lens due to the sudden change in the refractive index of the resin lens in the image, a morphological opening operation is used to filter and denoise the grating, and the grating is divided into two parts: the grating in the lens area and the grating in the background area;
[0040] Step 2021c: retain the lens area grating through target screening, calculate the circumscribed circle of the lens area grating, fit and generate the lens area (ROI area), and obtain four fitted lens images.
[0041] Furthermore, the specific process of lens dark field image stitching is as follows:
[0042] Step 2022a: Calculate the second-order gradient of the four fitted lens images obtained in step 2021c to obtain a second-order gradient image, in which isolated points, impurities and noise produce a stronger response;
[0043] Step 2022b: Perform rectangular mask convolution on the second-order gradient image. The new grayscale value of the image at the convolution kernel is the difference between the maximum and minimum grayscale values of the mask area, so as to achieve the purpose of image enhancement. The bright spot area of the first image of the lens and the bright spot area and dark background area of the subsequent three images are extracted respectively, and the bright spot images and dark background images of the subsequent three images are overlaid on the bright spot image of the first image to complete the dark field image stitching of the lens.
[0044] The present invention has the beneficial effects:
[0045] The invention provides a device and method for detecting point defects of a resin lens by a cross-contrast method. The detection device comprises a rotating detection platform, a visual detection module, a dust removal module and a vacuum suction cup module, so as to realize automatic dust removal and online detection of point defects of the resin lens, with high accuracy and greatly reducing the labor cost of the enterprise. The grating light source adopts an LED parallel backlight source with a surface in the shape of light and dark interval stripes, wherein the dark stripe area does not emit light, and the light color of the light in the bright stripe area is white, so as to generate modulated light, and improve the contrast between the defect and the background in the dark stripe area. The grating modulated image of the resin lens before and after dust removal is photographed, and the dark field images of the lens before and after dust removal are spliced for processing and comparison, and projection transformation is applied to the dark field images of the lens before and after dust removal, so that the lens areas of the front and back images correspond to each other. The cross-contrast method is adopted, and a rectangular frame is generated on the dark field image of the lens after dust removal with the defect position of the dark field image of the lens before dust removal as the center, and abnormal points are detected for the rectangular frame area. If the abnormal point exists in the rectangular frame, it is considered to be a lens defect, and if there is no defect in the rectangular frame, it is considered to be dust interference. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a schematic diagram of the structure of the device for detecting point defects of a resin lens according to the present invention;
[0047] Figure 2 is a schematic diagram of the grating light source of the present invention;
[0048] Figure 3 This is the industrial camera registration flow chart of the present invention;
[0049] Figure 4 Four original images of resin lens grating modulation taken by the industrial camera of the present invention;
[0050] Figure 5 This is a flowchart of lens image preprocessing according to the present invention;
[0051] Figure 6 This is a schematic diagram of lens image preprocessing according to the present invention;
[0052] Figure 7 This is a flowchart of the dark field image stitching of the lens according to the present invention;
[0053] Figure 8 This is a schematic diagram of dark field image stitching according to the present invention;
[0054] Fig. 9 This is a schematic diagram of a dark field image of a whole lens spliced with resin lenses according to the present invention;
[0055] Fig.10 This is a schematic diagram of the comparative extraction effect of point defects on the resin lens described in the present invention.
[0056] In the figure: 1-rotating detection platform, 2-first industrial camera, 3-second industrial camera, 4-dust removal module, 5-grating light source. DETAILED DESCRIPTION
[0057] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood by specific circumstances.
[0058] A method for detecting point defects of a resin lens using a cross-comparison method comprises the following steps:
[0059] Step 1: Offline modeling, align the two cameras that take pictures of the lens before and after dust removal; the two cameras take pictures of the same object at different positions, and there are differences in the positions of the objects in the images, which will affect the subsequent image processing comparison results of the two. Therefore, it is necessary to align the cameras and calculate the transformation relationship between the point pairs in the two images.
[0060] The point pairs on two images with different viewpoints can be expressed by a projection transformation in homogeneous coordinates, namely:
[0061] X l =H*X r
[0062] In the formula, X l , X r are the coordinates of corresponding points on the images of the same object taken by two cameras, and H is the projection transformation matrix of corresponding point pairs in the two images.
[0063] like Figure 3 As shown, the specific steps include:
[0064] Step 101: fix the calibration plate on the detection platform, switch the workstations, and take images of the calibration plate from two camera workstations respectively.
[0065] Step 102: Using threshold segmentation to extract feature points in the two calibration plate images respectively.
[0066] Step 103: Select more than 9 corresponding feature points of the two calibration plate images, and calculate the center coordinates of each corresponding feature point.
[0067] Step 104: The homography transformation matrix H of the point pair can be calculated from the corresponding feature points on the calibration plate image. The specific process is:
[0068] Xl =H*X r The specific expression is:
[0069]
[0070] Where X l , X r are the corresponding points on the two images, H is the transformation matrix, A 2×2 represents the affine transformation parameters, T 2×1 Represents the translation transformation parameter, V T =[v1,v2] represents the edge intersection after transformation, s is the intersection with V T The relevant scaling factor can be normalized to make s=1, that is, the homography transformation matrix H can be expressed as:
[0071]
[0072] The transformation matrix H has 8 unknowns. Two sets of equations can be listed from a set of corresponding points, as shown below:
[0073]
[0074]
[0075]
[0076] Four sets of corresponding points can obtain the unique solution of the transformation matrix H.
[0077] Step 105: The two cameras at the front and rear stations of dust removal respectively take images of the lens, apply the homography transformation matrix obtained in step 104 to the front and rear images, calculate the pixel offsets in the horizontal and vertical directions of the lens images after projection transformation, and complete the camera alignment.
[0078] Step 2, online processing, respectively obtain the dark field images of the resin lens before and after dust removal, apply projection transformation to the lens images before and after dust removal, so that the lens areas in the image correspond one to one, and use the cross-contrast method to generate a rectangular frame on the dark field image of the lens after dust removal with the defect position of the dark field image of the lens before dust removal as the center, and detect abnormal points in the rectangular frame area. If there are abnormal points in the rectangular frame, it is considered to be a lens defect, and if there are no defects in the rectangular frame, it is considered that the dust interference has been removed.
[0079] The specific steps include:
[0080] Step 201, four lens grating modulation images are taken before and after dust removal. The four lens grating modulation images are as follows: Figure 4 As shown;
[0081] Step 202, performing lens image preprocessing, lens dark field image stitching and lens image defect extraction on the lens grating modulation images before and after dust removal respectively;
[0082] like Figure 5 and 6 As shown in the figure, the specific process of lens image preprocessing is:
[0083] Step 2021a: convolve the four lens grating modulation images with the first-order gradient respectively to obtain the grating edge in the image;
[0084] Step 2021b: In view of the misalignment of the grating at the edge of the lens due to the sudden change in the refractive index of the resin lens in the image, a morphological opening operation is used to filter and denoise the grating, and the grating is divided into two parts: the grating in the lens area and the grating in the background area;
[0085] Step 2021c: retain the lens area grating through target screening, calculate the circumscribed circle of the lens area grating, fit and generate the lens area (ROI area), and obtain four fitted lens images.
[0086] like Figure 7 and 8 As shown in the figure, the specific process of lens dark field image stitching is:
[0087] Step 2022a: Calculate the second-order gradient of the four fitted lens images obtained in step 2021c to obtain a second-order gradient image, in which isolated points, impurities and noise produce a stronger response;
[0088] Step 2022b: The second-order gradient image is convolved with a rectangular mask. The new grayscale value of the image at the convolution kernel is the difference between the maximum and minimum grayscale values of the mask area, so as to achieve the purpose of image enhancement. The bright spot area (defect area) of the first lens image and the bright spot areas (defect areas) and dark background areas (background areas) of the subsequent three images are extracted respectively. The bright spot images and dark background images of the subsequent three images are overlaid on the bright spot image of the first image, so as to complete the dark field image stitching of the lens.
[0089] The specific process of lens image defect extraction is as follows: the dark field image of the lens before and after dust removal is segmented by threshold value, and the defect areas of the lens are extracted respectively, such as Fig. 9 shown.
[0090] Step 203: Cross-comparison is performed on the defective areas of the lens before and after dust removal. The projection transformation matrix H obtained in the registration step 104 is applied to the resin lens images before and after dust removal to make the lens areas of the images before and after correspond to each other. A rectangular frame is generated on the dark field image of the lens after dust removal with the defective position of the lens before dust removal as the center. Abnormal points are detected for the rectangular frame area. If there are abnormal points in the rectangular frame, it is considered to be a lens defect. If there are no defects in the rectangular frame, it is considered that the dust interference has been removed. Fig.10 shown.
[0091] The above detection method is carried out using a detection device, such as Figure 1 and 2 As shown, the detection device includes a rotating detection platform, a visual detection module, a dust removal module and an upper and lower unloading module.
[0092] Eight inspection stations are evenly distributed on the rotating inspection platform, the visual inspection module includes a first industrial camera and a second industrial camera, and the loading and unloading module includes a loading vacuum suction cup module and a unloading vacuum suction cup module.
[0093] The 8 inspection stations are No. 1-8, among which No. 1 is the loading station, the loading vacuum suction cup module is arranged at No. 1 station, the first station camera is arranged above No. 2 station, the dust removal module is arranged at No. 3 station, the second industrial camera is arranged above No. 4 station, No. 8 station is the unloading station, the unloading vacuum suction cup module is arranged at No. 8 station, and other stations are used for other inspections.
[0094] Grating light sources are respectively provided directly below the No. 2 and No. 4 stations. The grating power supply is movably connected to the bottom of the rotating detection platform through an adjustment mechanism. The adjustment mechanism includes a servo motor and a lead screw. The lead screw is connected to the output shaft of the servo motor through a coupling. The grating power supply is screwed on the lead screw. The rotation of the servo motor drives the grating power supply to move along the length direction of the lead screw. The grating light source uses an LED parallel backlight source with light and dark stripes on the surface. The dark stripe area does not emit light, and the light color of the bright stripe area is white, forming modulated light; the size of the LED parallel backlight source is 200mm*200mm, which can improve the contrast between the point defects of the resin lens and the background, and the light source can cover the camera field of view.
[0095] The resolution of the workstation camera is 18 million pixels, the target size is 1", and the data transmission is USB3.0. The fixed-focus lens of the industrial camera has a focal length of 16mm, a resolution of 20 million pixels, and a minimum working distance of 100mm.
[0096] The dust removal module comprises an upper dust removal mechanism and a lower dust removal mechanism. The upper dust removal mechanism is arranged directly above the No. 3 station, and the lower dust removal mechanism is arranged directly below the No. 3 station to remove dust from the upper and lower surfaces of the lens.
[0097] The above description is only a preferred embodiment of the present invention and does not limit the present invention in other forms. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A device for detecting point defects of resin lenses using a cross-comparison method, characterized in that: It includes a rotating inspection platform, a visual inspection module, a dust removal module, and a loading and unloading module; The visual inspection module includes a first industrial camera and a second industrial camera; Eight inspection stations are evenly distributed on the rotating inspection platform, the visual inspection module includes a first industrial camera and a second industrial camera, and the eight inspection stations are stations 1 to 8, wherein station 1 is a loading station, the first industrial camera is arranged above station 2, the dust removal module is arranged at station 3, the second industrial camera is arranged above station 4, and station 8 is an unloading station; The loading and unloading module is used for loading and unloading lenses.
2. A device for detecting point defects of a resin lens using a cross-comparison method as claimed in claim 1, characterized in that: Grating light sources are respectively arranged directly below the No. 2 station and the No. 4 station.
3. A device for detecting point-shaped defects of a resin lens using a cross-comparison method as claimed in claim 2, characterized in that: The grating power supply is movably connected below the rotating detection platform through an adjusting mechanism.
4. The device for detecting point defects of a resin lens using a cross comparison method as claimed in claim 1, characterized in that: The dust removal module comprises an upper dust removal mechanism and a lower dust removal mechanism, wherein the upper dust removal mechanism is arranged directly above the No. 3 station, and the lower dust removal mechanism is arranged directly below the No. 3 station.
5. A method for detecting point defects of resin lenses using a cross-comparison method, characterized in that: The following steps are involved: Step 1, aligning two cameras for photographing the lens before and after dust removal; specifically comprising the following steps: Step 101: fix the calibration plate on the detection platform, switch the workstations, and take images of the calibration plate from two camera workstations respectively; Step 102: extracting feature points from two calibration plate images respectively by using threshold segmentation; Step 103: Select more than 9 corresponding feature points of the two calibration plate images, and calculate the center coordinates of each corresponding feature point; Step 104: The homography transformation matrix H of the point pair can be calculated from the corresponding feature points on the calibration plate image; Step 105: The two cameras at the front and rear dust removal stations respectively take images of the lens, apply the homography transformation matrix obtained in step 104 to the front and rear images, calculate the pixel offsets in the horizontal and vertical directions of the lens images after projection transformation, and complete the camera alignment; Step 2, respectively obtain the dark field images of the resin lens before and after dust removal, apply projection transformation to the lens images before and after dust removal, so that the lens areas in the image correspond one to one, and use the cross-contrast method to generate a rectangular frame on the dark field image of the lens after dust removal with the defect position of the dark field image of the lens before dust removal as the center, and detect abnormal points in the rectangular frame area. If there are abnormal points in the rectangular frame, it is considered to be a lens defect, and if there are no defects in the rectangular frame, it is considered that the dust interference has been removed.
6. A method for detecting point defects of a resin lens using a cross comparison method as claimed in claim 5, characterized in that: The specific process of step 104 is: The point pairs on two images with different viewpoints can be expressed by a projection transformation in homogeneous coordinates, namely: X l =H*X r In the formula, X l , X r are the coordinates of corresponding points on the images of the same object taken by two cameras, and H is the projection transformation matrix of corresponding point pairs in the two images; X l =H*X r The specific expression is: Where X l , X r are the corresponding points on the two images, H is the transformation matrix, A 2×2 represents the affine transformation parameters, T 2×1 Represents the translation transformation parameter, V T =[v1,v2] represents the edge intersection after transformation, s is the intersection with V T The relevant scaling factor can be normalized to make s=1, that is, the homography transformation matrix H can be expressed as: The transformation matrix H has 8 unknowns. Two sets of equations can be listed from a set of corresponding points, as shown below: Four sets of corresponding points can obtain the unique solution of the transformation matrix H.
7. A method for detecting point defects of a resin lens using a cross comparison method as claimed in claim 5, characterized in that: Step 2 specifically includes the following steps: Step 201, taking four lens grating modulation images before and after dust removal; Step 202, performing lens image preprocessing, lens dark field image stitching and lens image defect extraction on the lens grating modulation images before and after dust removal respectively; Step 203: cross-comparison is performed on the defective areas of the lens before and after dust removal, and the projection transformation matrix H obtained in the previous registration step 104 is applied to the resin lens images before and after dust removal, so that the lens areas of the before and after images correspond one to one; a rectangular frame is generated on the dark field image of the lens after dust removal with the defect position of the lens before dust removal as the center, and abnormal points are detected in the rectangular frame area. If there are abnormal points in the rectangular frame, it is considered to be a lens defect, and if there are no defects in the rectangular frame, it is considered that the dust interference has been removed.
8. A method for detecting point defects of a resin lens using a cross comparison method as claimed in claim 7, characterized in that: The specific process of lens image preprocessing is: Step 2021a: convolve the four lens grating modulation images with the first-order gradient respectively to obtain the grating edge in the image; Step 2021b: In view of the misalignment of the grating at the edge of the lens due to the sudden change in the refractive index of the resin lens in the image, a morphological opening operation is used to filter and denoise the grating, and the grating is divided into two parts: the grating in the lens area and the grating in the background area; Step 2021c: retain the lens area grating through target screening, calculate the circumscribed circle of the lens area grating, fit and generate the lens area (ROI area), and obtain four fitted lens images.
9. A method for detecting point-shaped defects of a resin lens using a cross-comparison method as claimed in claim 8, characterized in that: The specific process of lens dark field image stitching is: Step 2022a: Calculate the second-order gradient of the four fitted lens images obtained in step 2021c to obtain a second-order gradient image, in which isolated points, impurities and noise produce a stronger response; Step 2022b: Perform rectangular mask convolution on the second-order gradient image. The new grayscale value of the image at the convolution kernel is the difference between the maximum and minimum grayscale values of the mask area, so as to achieve the purpose of image enhancement. The bright spot area of the first image of the lens and the bright spot area and dark background area of the subsequent three images are extracted respectively, and the bright spot images and dark background images of the subsequent three images are overlaid on the bright spot image of the first image to complete the dark field image stitching of the lens.
