Lens surface water mist and oil mist detection method, device, equipment and medium
By acquiring lens images from multiple angles and combining Hough circle transformation and contour analysis methods, the problem of difficulty in accurately detecting water mist and oil mist on the lens surface in the prior art is solved, and high-precision lens detection and model identification are achieved.
Patent Information
- Application Number
- CN202411763778.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-29
AI Technical Summary
The existing lens detection methods are difficult to accurately detect water mist and oil mist on the lens surface, and the automated detection methods only collect images from the upper part of the lens, making it difficult to capture overall information.
The camera is set up multiple angles to obtain lens images of multiple viewing angles, and combined with the Hough circular transformation algorithm and contour analysis method, the water mist and oil mist distribution on the lens surface are identified and analyzed.
Accurate detection and quantitative analysis of water mist and oil mist on the surface of the lens is realized, the accuracy and reliability of the detection are improved, and the lens model and content can be automatically judged.
Smart Images

Figure CN119904410A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of lens detection, and in particular relates to a method, device, equipment and medium for detecting water mist and oil mist on a lens surface. Background Art
[0002] In all aspects of lens manufacturing and use, testing the lens surface quality is a crucial step. Generally, when water mist or oil mist appears on the lens surface, it not only affects the transparency and optical performance of the lens, but also may cause blurred vision for the user. Therefore, it is necessary to promptly test the lens surface, detect water mist and oil mist, and deal with it in a timely manner.
[0003] Existing lens inspection methods mainly rely on visual methods. Although simple and easy to use, they are limited by the subjectivity of the human eye, the observation angle, and the inspection time, and it is difficult to ensure timely, consistent, and accurate inspections. Some automated inspection methods based on image processing technology have improved the inspection efficiency to a certain extent, but they only collect images from the upper part of the lens, making it difficult to accurately capture the water mist and oil mist information on the lens surface. Moreover, existing lens inspection methods only analyze the captured images, such as color analysis or grayscale analysis, and detect the state of water mist or oil mist from an overall analysis. This results in inaccurate contour analysis of water mist or oil mist, and it is impossible to accurately extract the water mist and oil mist characteristics on the lens surface, affecting the inspection accuracy. Summary of the invention
[0004] The present invention provides a method for detecting water mist and oil mist on the surface of a lens. The method obtains characteristic images of the lens from multiple angles, thereby avoiding errors generated when analyzing a single image and facilitating automatic determination of the model of the lens and the content of water mist and oil mist on the lens.
[0005] Methods include: Based on the multi-angle camera, the lens images taken from multiple viewing angles are obtained; Analyze the lens information of the lens image, obtain the lens type of the lens, and determine the lens area, lens thickness, and coating color; Extract the lens image obtained based on the upper part of the lens, and use the Hough circle to identify the circle in the lens image and the corresponding center of the circle; Taking the center of the circle as the base point, the circle is divided into at least four regions, and the contour area of the water mist in each region of the lens image is analyzed based on the contour analysis method; The method also extracts a lens image obtained from the side of the lens, divides the circle in the lens image obtained from the side of the lens into at least four circular ring areas, analyzes the oil color in each circular ring area through a color analysis algorithm, and calculates the oil area.
[0006] It should be further explained that the step of analyzing the water mist contour area in each area of the lens image based on the contour analysis method also includes: Establish the oil mist retrieval coordinate system and obtain the circle center through the Hough circle transform algorithm; Define the field of view length as a, width as b, and resolution as c*d; Calculate the minimum pixel as (a / c)*(b / d); Based on the oil mist retrieval coordinate system, the position of each pixel is confirmed, and the pixel at the center of the circle and the proportion of each divided area are obtained.
[0007] It should be further explained that, in the method, the contour pixel points corresponding to the water mist contour in each divided area are obtained by the Canny edge detection algorithm, the area of the water mist contour in each divided area is calculated by the difference between each contour pixel point and the center pixel point, and the water mist contour area is calculated using the definite integral.
[0008] It should be further explained that, in the method, the color analysis algorithm includes: converting the lens image from BGR to HSV color space, creating a mask, applying morphological operations to the mask to remove noise, and obtaining the coating color; Find the maximum and minimum values of the lens image from the three BGR channels; If red R is the maximum value, the hue H is the difference between green G and blue B; If green G is the maximum value, the hue H is the difference between blue B and red R; If blue B is the maximum, the hue H is the difference between red R and green G; Set the base hue H to 150, the base saturation S to 255, and the base brightness V to 255; Based on the oil-containing colors in each circular area corresponding to the reference hue H of 150, the reference saturation S of 255, and the reference brightness V of 255, the oil-containing area is obtained by comparison, and the proportion of oil content in each area is calculated; The oil content ratio is compared with the set ratio threshold to determine whether the oil content on the lens surface exceeds the standard.
[0009] It should be further explained that the captured lens image includes: capturing the lens image perpendicular to the lens, and setting the camera on the side of the lens and capturing the lens image at an angle of 35 to 40 degrees to the lens.
[0010] It should be further explained that the step of parsing the lens information of the lens image also includes: calculating the lens thickness through the lens images taken from multiple viewing angles; The lens thickness is calculated by grayscale processing the lens image, then binarizing it, and using contour detection to confirm the location of the lens; Analyze the difference between the top pixel and the bottom pixel of the lens to obtain the number of virtual pixels, and determine the lens thickness based on the product of the number of virtual pixels and the pixel size; The lens image is also grayscaled and binarized, and the Hough circle method is used to identify the circle in the lens image, match the center of the circle, and calculate the lens area; The lens image is converted from BGR to HSV color space, and a mask is created. Morphological operations are applied to the mask to remove noise, and finally the coating color is obtained.
[0011] It should be further explained that, in the method, the calculated lens thickness, lens area and coating color are respectively compared with the preset lens thickness, preset lens area and preset coating color stored in the lens type library, and when the similarity is greater than the preset similarity threshold, the corresponding lens type is matched; The types of lenses include: protective lenses, focusing lenses, collimating lenses and biconvex lenses.
[0012] The present application also provides a device for detecting water mist and oil mist on a lens surface, the device comprising: An image acquisition module is used to photograph the lens at multiple angles and acquire images of the lens taken at multiple viewing angles; A lens type acquisition module is used to analyze the lens information of the lens image, obtain the lens type of the lens, and determine the lens area, lens thickness and coating color; A lens image recognition module, used to extract a lens image obtained based on the upper part of the lens, and use the Hough circle to recognize a circle in the lens image and a corresponding center of the circle; A water mist contour detection module is used to divide a circle into at least four regions based on the center of the circle, and analyze the water mist contour area in each region of the lens image based on a contour analysis method; The oil mist area detection module is used to extract the lens image obtained from the side of the lens, divide the circle in the lens image obtained from the side of the lens into at least four circular ring areas, analyze the oil color in each circular ring area through a color analysis algorithm, and calculate the oil area.
[0013] According to another embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the lens surface water mist and oil mist detection method when executing the program.
[0014] According to another embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for detecting water mist and oil mist on the lens surface are implemented.
[0015] It can be seen from the above technical solutions that the present invention has the following advantages: The lens surface water mist and oil mist detection method provided by the present invention improves the accuracy of lens surface water mist and oil mist detection by adjusting the light source angle, using a diffuse reflection plate, and shooting lens images from multiple angles to obtain data that meets the requirements of lens image analysis. The lens image is then subjected to denoising, edge detection, histogram processing, etc. to improve image quality and highlight the features of the lens surface. The SURF algorithm is used for feature point detection and matching, and images from different perspectives are unified into the same coordinate system by calculating the transformation relationship to achieve accurate and seamless image stitching. Based on the stitched image, information such as the area, thickness, and coating process of the lens can be extracted. By comparing the information with a pre-established lens type library, the system can accurately identify the model of the lens, ensuring the accuracy and reliability of the recognition.
[0016] The present invention uses the Hough circle transform algorithm to identify circles in the spliced image and find the center of the circle to divide the area. By performing contour analysis on different areas, the system can accurately detect the distribution of water mist and oil mist on the lens surface, and realize quantitative analysis and visual display of water mist and oil mist. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0018] Figure 1 This is a flow chart of the method for detecting water mist and oil mist on the lens surface; Figure 2 Shoot schematics for multiple viewing angles; Figure 3 It is a schematic diagram of the water mist profile; Figure 4 This is a schematic diagram of oil mist detection; Figure 5 It is a schematic diagram of a device for detecting water mist and oil mist on the lens surface; Figure 6 Schematic diagram of an electronic device. DETAILED DESCRIPTION
[0019] The lens surface water mist and oil mist detection method provided by the present application obtains high-quality image data by adjusting the position of the light source and camera of the lens image process. The acquired multi-angle images need to go through a series of preprocessing steps, including denoising, edge detection, histogram processing, etc., to improve the image quality and highlight the features of the lens surface. Image stitching is achieved by unifying images of different perspectives into the same coordinate system. Based on the stitched images, information such as the area, thickness, and coating status of the lens is extracted. By comparing this information with a pre-established lens type library, the system can accurately identify the model of the lens.
[0020] The present invention uses the Hough circle transform algorithm to identify circles in the spliced image and find the center of the circle to divide the area. By performing contour analysis on different areas, the system can accurately detect the distribution of water mist and oil mist on the lens surface, and realize quantitative analysis and visual display of water mist and oil mist.
[0021] The specific process of the lens surface water mist and oil mist detection method will be described in detail below. For the purpose of explanation rather than limitation, specific details such as specific system structures and technologies are proposed to facilitate a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details.
[0022] It should be understood that when used in the present specification, the term "includes" indicates the presence of the described features, integral bodies, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integral bodies, steps, operations, elements, components and / or their collections. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] See also Figure 1 The figure is a flow chart of a method for detecting water mist and oil mist on a lens surface in a specific embodiment, the method comprising: S101: Based on a camera set at multiple angles, obtain lens images taken from multiple viewing angles.
[0025] like Figure 2As shown, after adjusting the light source angle, multi-angle shooting is achieved. In this embodiment, the light source is adjusted, the setting angle of the light source is tilted 5 degrees to the horizontal plane, and a diffuse reflection plate is used to fix it around the light source.
[0026] Optionally, the multi-angle image includes at least a first angle image taken from the front, a second angle image taken from the left side, and a third angle image taken from the right side.
[0027] In order to avoid the error generated when analyzing a single image and to help realize the automatic determination of the model of the lens and the content of water mist and oil mist on the lens, the present embodiment adopts multi-angle shooting images, and in order to obtain the basic lens information such as the size and model information of the lens and the oil content and water content on the lens surface, the multi-angle images at least include a first angle image shot from the front, a second angle image shot from the left side, and a third angle image shot from the right side.
[0028] In an embodiment of the present application, obtaining multi-angle images of the lens to be inspected specifically includes: fixing the lens directly blown by an air compressor using a machine, determining a front view position and two side view positions of the lens to be inspected; adjusting the exposure time of the camera to 50ms and the gain to 1, and controlling the camera to capture images based on the front view position and the side view position to obtain a first angle image, a second angle image, and a third angle image.
[0029] In some specific embodiments, a camera is placed above the air compressor direct blowing lens, and the height of the camera is adjusted according to a pre-set field of view. Then, a pre-shooting analysis is performed, and the aperture and focus knob on the lens are adjusted to achieve the minimum pixel size.
[0030] After determining the camera position, take a picture to get the image and check whether the lens in the image occupies 80% of the entire image. If it is lower than the threshold of 80%, the camera position needs to be readjusted until the lens occupies more than the threshold of 80% of the entire image.
[0031] A camera is placed at the lower left side of the lens to illuminate the lens at a certain angle. Since the light source's access position is inconsistent, the angle is also inconsistent. In this embodiment, the camera position can be set so that the lens and the camera are at 35 to 40 degrees to capture the lens image. At this time, the illuminated oil mist is clearest and the illuminated lens area is the largest, and an image from a second perspective is obtained.
[0032] Placing a camera and a second-view camera at the lower right side of the lens can present the same angle. Since the second-view camera is tilted, it cannot obtain a complete lens image, so a third-view camera can be used to compensate for the missing image of the second-view camera.
[0033] It should be noted that the lens image captured by the first viewing angle camera can be used to analyze the diameter of the lens, and the lens images captured by the second viewing angle camera and the third viewing angle camera can be used to analyze the information of the lens and obtain the specific model of the lens.
[0034] S102: Analyze the lens information of the lens image, obtain the lens type, and determine the lens area, lens thickness, and coating color.
[0035] In this embodiment, the types of lenses are divided into protective lenses, focusing lenses, collimating lenses, biconvex lenses, etc., and the collimating lenses are further divided into meniscus lenses and aspherical lenses.
[0036] It can be seen that there are many types of mirrors, and the test results of each are different, so the lens type should be analyzed before testing.
[0037] In this embodiment, the lens images taken by the second-view camera and the third-view camera are used as images for analyzing the lens type. The lens type library is pre-set with a variety of lens types, including protective lenses, focusing lenses, collimating lenses, biconvex lenses, etc. Each type has various related size models for easy matching. When establishing the lens class library, the shooting angle of the lens thickness should be consistent with the shooting angle when actually detecting oil mist, to avoid subtle changes in the lens thickness due to inconsistent shooting angles, resulting in misjudgment of the lens type.
[0038] This embodiment can obtain feature points of the lens image, including lens thickness, lens type, and lens coating color. The thickness of the lens can be calculated based on the actual field of view size and the theoretical field of view size through photos taken from the second and third viewing angles.
[0039] Specifically, the lens thickness is calculated by grayscale processing the lens image, then binarizing it, using a contour detection tool to confirm the location of the lens, and then calculating the difference between the top pixel and the bottom pixel of the lens to obtain the number of virtual pixels. Based on the pixel size calculated previously, the product of the number of virtual pixels and the pixel size is the actual lens thickness.
[0040] As an example of this embodiment, the lens thickness calculation method can convert the lens image into a grayscale image. In a grayscale image, the color value of each pixel is determined by the average or weighted average of the three color channels of red, green, and blue, thereby obtaining a grayscale value, and the grayscale value ranges from 0 (black) to 255 (white).
[0041] The grayscale image is binarized, and the grayscale value of each pixel in the pixel matrix of the lens image is set to 0 (black) or 255 (white), so that the image appears to be only black and white. The purpose of binarization is to simplify the image information and facilitate subsequent contour detection.
[0042] This embodiment uses a contour detection tool to confirm the position of the lens in the image. Contour detection can identify the edge of an object in an image, thereby determining the boundary of the lens.
[0043] After confirming the position of the lens, find the top and bottom pixels of the lens. Calculate the difference between these two pixels to get the number of virtual pixels. Based on the previously calculated pixel size (i.e. the actual physical size represented by each pixel), multiply the number of virtual pixels by the pixel size to get the actual lens thickness.
[0044] Among them, grayscale processing can use the weighted average method to convert the RGB image into a grayscale image. The formula is: Gray=0.299×R+0.587×G+0.114×B Among them, Gray represents the grayscale value, and R, G, and B represent the values of the red, green, and blue color channels respectively.
[0045] The binarization process can set a threshold value, set the pixel points with grayscale values less than or equal to the threshold value to 0 (black), and set the pixel points with grayscale values greater than the threshold value to 255 (white). The choice of threshold value can be adjusted according to the specific situation.
[0046] The contour detection algorithm is based on the edge detection operator to identify the edges of objects in the image. Set the coordinates of the top pixel of the lens to (x1, y1), the coordinates of the bottom pixel to (x2, y2), and the pixel size to p, then the calculation formula for the lens thickness is: lens thickness = (y2-y1) × p.
[0047] The above steps can realize the detection of water mist and oil mist on the lens surface and the calculation of the lens thickness.
[0048] S103: extracting a lens image obtained based on the upper part of the lens, and using the Hough circle to identify a circle in the lens image and a corresponding center of the circle.
[0049] In this embodiment, the Hough circle transform algorithm can be applied to detect circular structures in the image. The edge of the lens can be accurately identified by adjusting algorithm parameters, such as radius range, threshold, etc. For each identified circle, the coordinates of its center are calculated.
[0050] Specifically, the lens image taken by the first-person camera is obtained, the lens image is gray-scaled and then binarized, the Hough circle method is used to identify the circle in the photo after stitching, and then the center of the circle is found and the area of the circle is calculated.
[0051] Among them, this embodiment performs grayscale processing on the lens image taken at the first perspective to obtain a grayscale image, and the value range of the pixel value of the image is simplified to 0-255; the color image is converted into a grayscale image according to the grayscale processing, so that each pixel has only one brightness value, and then after binarization processing, the pixel points are divided into black and white parts by setting a threshold, thereby simplifying the image data and highlighting the outline and important features of the image.
[0052] After grayscale processing and binarization, the Hough circle transform is used to find the center of the circle in the photo and record the center area.
[0053] This embodiment uses the photos taken from the second and third viewing angles, converts the images from BGR to HSV color space, and then creates a mask. It should be noted that because the coating process of the lens is unknown, it is necessary to include multiple colors, and then apply morphological operations to the mask to remove noise, and finally obtain the coating color.
[0054] The calculated lens thickness, lens area and lens coating color are compared with the lens thickness, lens area and lens coating color preset in the lens type library, and when the similarity is greater than the preset similarity threshold, the corresponding lens type is matched. The preset similarity threshold can be set to 90% similarity or 95% similarity. The lens types can correspond to protective lenses, focusing lenses, collimating lenses and biconvex lenses.
[0055] S104: Taking the center of the circle as a base point, the circle is divided into at least four regions, and the contour area of the water mist in each region of the lens image is analyzed based on a contour analysis method.
[0056] In this embodiment, the circle is divided into at least four equal regions with the center of the circle as the base point. Optionally, the circle can be divided into four regions. The Canny edge detection algorithm is applied to identify the contour of the water mist in each region.
[0057] For each detected water mist contour, the area can be calculated using the pixel counting method.
[0058] After step S102, in step S105, the lens image obtained from the side of the lens is extracted, the circle in the lens image obtained from the side of the lens is divided into at least four circular ring areas, the oil color in each circular ring area is analyzed by a color analysis algorithm, and the oil area is calculated.
[0059] It should be noted that the circle is divided into at least four concentric ring areas with the center of the circle as the base point. A color analysis algorithm is applied to identify the oily color in each ring area. The identification can be performed based on the RGB value and HSV value of the oil stain. For the identified oil-bearing areas, the corresponding oil-bearing area can be obtained using pixel counting method or geometric calculation method.
[0060] This embodiment applies Hough circle recognition, contour analysis, and color analysis, and can accurately detect water mist and oil mist on the lens surface through steps such as preprocessing, recognition, analysis, and calculation.
[0061] Further, as a refinement and extension of the specific implementation of the above embodiment, the specific implementation process of detecting the water mist contour area in this embodiment will be described in detail below. Figure 3 As shown, the specific methods include: Based on the multi-angle camera, multi-angle shooting is performed. Optionally, the camera light source angle is tilted 5 degrees, and then a diffuse reflection plate is used to fix it around the light source. The photos taken by the camera lens can be divided into three perspectives, namely the first perspective, the second perspective and the third perspective.
[0062] The first viewing angle is to shoot directly above the lens to confirm the size of the field of view.
[0063] In order to accurately measure the area of water mist and oil mist, the minimum pixel point that can be seen is clear. The pixel information can be obtained based on the minimum pixel point calculation method. Specifically, if the field of view length is a, the width is b, and the camera resolution is c*d, after knowing the resolution, the corresponding pixel coordinate system can be established, and the minimum pixel point that can be obtained is (a / c)*(b / d), referred to as the pixel size. Establishing the coordinate system can also confirm the position of each pixel.
[0064] like Figure 2 As shown, the second viewing angle is located at the lower left side of the lens, and the lens is illuminated at a certain angle. Because the light source's visiting position is inconsistent, the angle is also inconsistent. This method assumes that the light source position is fixed, and the lens and the camera are 35 degrees. At this time, the irradiated oil mist is clearest and the irradiated lens area is the largest.
[0065] The third viewing angle is located at the lower right side of the lens and has the same angle as the camera of the second viewing angle. Considering that the second viewing angle is inclined and therefore cannot obtain a complete lens image, the third viewing angle can be used to compensate for the missing image of the second viewing angle camera.
[0066] This embodiment pre-processes the lens image, reads the photos taken at the second and third viewing angles, then denoises the pictures at the two viewing angles, uses the Canny edge detection algorithm to extract the edges in the images, and then performs histogram processing. The SURF algorithm is used to detect feature points in the two viewing angle images, and matching is performed based on the descriptors of the feature points to find the corresponding points of the second viewing angle image and the third viewing angle image.
[0067] The transformation relationship between images is calculated based on the matching points. The transformation relationship is usually described using a homography matrix or an affine transformation matrix. The images to be stitched are transformed into the same coordinate system based on the calculated transformation model so that the images are aligned in space. Finally, image fusion is performed. The fusion method used is Poisson image editing. The fusion process is performed in the overlapping areas of the images to eliminate the stitching traces.
[0068] In order to meet the needs of lens circle detection, Hough circle detection can be used. Specifically, you can select the photos taken from the first perspective for lens circle detection. Use the Canny edge detection algorithm to extract the edges in the image. Initialize the accumulator in the parameter space, each accumulator corresponds to a possible center and radius. For each edge point in the image, calculate its distance and angle to each accumulator, and add one to the corresponding accumulator. Find the point with the highest accumulated value in the parameter space, which corresponds to a circular object in the image. After finding the circular object in the image, draw it.
[0069] Combination Figure 3 In general, the oil mist coordinate system is established, and the center of the circle is obtained through the Hough circle transform algorithm. According to the minimum pixel calculation method: if the length of the field of view is a, the width is b, and the resolution of the camera is c*d, after knowing the resolution, the corresponding pixel coordinate system can be established, and the minimum pixel point that can be obtained is (a / c)*(b / d), referred to as the pixel size. The establishment of the coordinate system can also confirm the position of each pixel. At this time, the virtual pixel point of the center of the circle is obtained.
[0070] Figure 3 Regions ① and ④ account for 30% respectively, and regions ② and ③ account for 20% respectively. The contour pixel points corresponding to the water mist contour in each divided area are obtained through the Canny edge detection algorithm. The area of the water mist contour in each divided area is calculated by the difference between each contour pixel point and the center pixel point, and the water mist contour area is calculated using the definite integral.
[0071] For example, assuming that the coordinates of the center of the circle are (645, 458), the coordinates of the first pixel are (1256, 856), and the coordinates of the second pixel are (1256, 458). The calculated area is (1256-654)*(856-458)*0.5=500. These are two pixels, Y=Kx+b, and then the definite integral can be used for calculation.
[0072] In an embodiment of the present invention, based on step S105, a possible embodiment is given below to illustrate its specific implementation scheme in a non-limiting manner.
[0073] For the calculation of oil-bearing area, Figure 4 As shown, the circle is first divided into four regions to calculate the oil content in each sub-region. The lens images taken by the second-view camera and the third-view camera are converted from BGR to HSV color space, and then a mask is created, which contains multiple colors. Morphological operations are then applied to the mask to remove noise, and finally the coating color is obtained.
[0074] Convert the lens image from BGR to HSV color space, where the BGR color space obtained by taking a photo is based on the three primary colors, while the converted HSV color space is based on hue, saturation, and brightness. First, find the maximum value (max) and minimum value (min) from the three BGR channels. The calculation of hue H depends on the channel where the maximum value is located. If R is the maximum value, the calculation of H is based on the difference between G and B; if G is the maximum value, it is based on the difference between B and R; if B is the maximum value, it is based on the difference between R and G. Then, based on the ratio of these differences to the maximum and minimum differences, and the angle offset corresponding to the current maximum value, calculate the value of H; saturation S is the ratio of the difference between the maximum and minimum values to the maximum value, indicating the purity of the color; brightness V is the maximum value in BGR, indicating the brightness of the color.
[0075] Optionally, by setting the hue H to 150, the saturation S to 255, and the brightness V to 255, the size of the oil mist gradient color area can be obtained. After obtaining the area, the total number of pixels is calculated, and then the pixel point is multiplied by the pixel size and then multiplied by the ratio of each area to calculate the oil content on the lens.
[0076] Among them, the oily areas are obtained by comparing the oily colors in each circular area with the reference hue H of 150, the reference saturation S of 255, and the reference brightness V of 255, and the oily content ratio of each area is calculated; the oily content ratio is compared with the set ratio threshold to determine whether the oil content on the lens surface exceeds the standard. If it exceeds the standard, an alarm can be issued.
[0077] According to the embodiment of the present application, the lens images taken from the second and third viewing angles are stitched together into a complete lens image, and then the Hough circle transform algorithm and the contour analysis method are applied again to detect water mist and oil mist. This method can effectively solve the problem of missing information caused by shooting from a single viewing angle and improve the comprehensiveness and accuracy of detection.
[0078] All steps in this embodiment are implemented based on an automated algorithm, thus greatly improving the efficiency and accuracy of detection. It can also be flexibly adjusted and optimized according to actual needs to meet the detection needs of lenses of different types and specifications, and can effectively detect water mist and oil mist on the lens surface.
[0079] The following is an embodiment of a device for detecting water mist and oil mist on a lens surface provided in an embodiment of the present disclosure. The device and the methods for detecting water mist and oil mist on a lens surface in the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiment of the device for detecting water mist and oil mist on a lens surface, reference can be made to the embodiments of the methods for detecting water mist and oil mist on a lens surface in the above-mentioned embodiments.
[0080] like Figure 5 As shown, the device comprises: An image acquisition module is used to photograph the lens at multiple angles and acquire images of the lens taken at multiple viewing angles; A lens type acquisition module is used to analyze the lens information of the lens image, obtain the lens type of the lens, and determine the lens area, lens thickness and coating color; A lens image recognition module, used to extract a lens image obtained based on the upper part of the lens, and use the Hough circle to recognize a circle in the lens image and a corresponding center of the circle; A water mist contour detection module is used to divide a circle into at least four regions based on the center of the circle, and analyze the water mist contour area in each region of the lens image based on a contour analysis method; The oil mist area detection module is used to extract the lens image obtained from the side of the lens, divide the circle in the lens image obtained from the side of the lens into at least four circular ring areas, analyze the oil color in each circular ring area through a color analysis algorithm, and calculate the oil area.
[0081] The lens surface water mist and oil mist detection device involved in this embodiment uses a camera to shoot the lens at multiple angles. At least the first angle image shot from the front, the second angle image shot from the left side, and the third angle image shot from the right side. The images at each angle carry different aspects of the lens information, and together constitute a comprehensive lens visual model.
[0082] During the shooting process, the position and parameter settings of the camera are key. Adjust the height of the camera according to the preset field of view to ensure that the lens occupies a suitable proportion in the image. By adjusting the aperture and focus knobs on the lens, the minimum pixel size is achieved, thereby improving the resolution and clarity of the image.
[0083] After the image is acquired, the lens information is extracted, such as lens area, thickness, coating process, etc. Through advanced image analysis technology, the lens model can be accurately identified.
[0084] After obtaining the lens image information and model information, further detection and analysis of water mist and oil mist are carried out.
[0085] This embodiment uses the Hough circle transform algorithm to identify circles in the spliced image and accurately locate the position of the center of the circle. A coordinate system centered on the center of the circle is established for subsequent area division and analysis. The lens image is divided into multiple areas according to the position of the center of the circle.
[0086] In this embodiment, we mainly focus on four areas: Area ① and Area ④ account for 30% each; Area ② and Area ③ account for 20% each. This area division method is determined based on the characteristics and rules of the distribution of water mist and oil mist on the lens, aiming to improve the accuracy and efficiency of detection.
[0087] For each area, we use contour analysis to identify and analyze the water mist contour. By extracting edge information from the image, calculating the area and shape characteristics of the contour, we can accurately identify the presence of water mist and quantify its degree. At the same time, combined with pre-set thresholds and judgment logic, we can also achieve automatic detection and classification of water mist and oil mist.
[0088] Finally, the analysis results of each area are integrated and evaluated. By combining the information of multiple areas and the overall characteristics of the lens, we can obtain a comprehensive and accurate water mist and oil mist detection result.
[0089] The oil mist area detection module uses a color analysis algorithm to analyze the oil color in each circular area. The area size of the oil mist gradient color can be obtained, and then the pixel points of each area are obtained. The total number of pixel points is calculated, and then the pixel points are multiplied by the pixel size and then multiplied by the ratio of each area to calculate the oil content on the lens.
[0090] like Figure 6 As shown, the present application also provides an electronic device, including a display module 103, a memory 102, a processor 101, and a computer program stored in the memory and executable on the processor 101, wherein the processor 101 implements the steps of a method for detecting water mist and oil mist on a lens surface when executing the program.
[0091] In embodiments of the present invention, electronic devices include, but are not limited to, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or required herein.
[0092] In the embodiment of the present application, the processor 101 can be implemented by using at least one of an application-specific integrated circuit (ASIC), a programmable logic device (PLD), a field programmable gate array (FPGA), a processor, a controller, a microcontroller, a microprocessor, and an electronic unit designed to perform the functions described herein. In some cases, such an implementation can be implemented in a controller. For software implementation, implementations such as processes or functions can be implemented with separate software modules that allow execution of at least one function or operation. The software code can be implemented by a software application (or program) written in any appropriate programming language, and the software code can be stored in a memory and executed by a controller.
[0093] The display module 103 is used to display information input by the user or information provided to the user. The display module 103 may include a display panel, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.
[0094] The memory 102 may be used to store software programs and various data. The memory 102 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0095] The present application also provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the lens surface water mist and oil mist detection method.
[0096] The storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0097] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting water mist and oil mist on a lens surface, characterized in that: Methods include: Based on the multi-angle camera, the lens images taken from multiple viewing angles are obtained; Analyze the lens information of the lens image, obtain the lens type of the lens, and determine the lens area, lens thickness, and coating color; Extract the lens image obtained based on the upper part of the lens, and use the Hough circle to identify the circle in the lens image and the corresponding center of the circle; Taking the center of the circle as the base point, the circle is divided into at least four regions, and the contour area of the water mist in each region of the lens image is analyzed based on the contour analysis method; The method also extracts a lens image obtained from the side of the lens, divides the circle in the lens image obtained from the side of the lens into at least four circular ring areas, analyzes the oil color in each circular ring area through a color analysis algorithm, and calculates the oil area.
2. The method for detecting water mist and oil mist on the lens surface according to claim 1, characterized in that: The step of analyzing the water mist contour area in each area of the lens image based on the contour analysis method also includes: Establish the oil mist retrieval coordinate system and obtain the circle center through the Hough circle transform algorithm; Define the field of view length as a, width as b, and resolution as c*d; Calculate the minimum pixel as (a / c)*(b / d); Based on the oil mist retrieval coordinate system, the position of each pixel is confirmed, and the pixel at the center of the circle and the proportion of each divided area are obtained.
3. The method for detecting water mist and oil mist on the lens surface according to claim 2, characterized in that: In this method, the contour pixel points corresponding to the water mist contour in each divided area are obtained by the Canny edge detection algorithm, the area of the water mist contour in each divided area is calculated by the difference between each contour pixel point and the center pixel point, and the water mist contour area is calculated using the definite integral.
4. The method for detecting water mist and oil mist on the lens surface according to claim 1 or 2, characterized in that: In the method, the color analysis algorithm includes: converting the lens image from BGR to HSV color space, creating a mask, applying morphological operations to the mask to remove noise, and obtaining the coating color; Find the maximum and minimum values of the lens image from the three BGR channels; If red R is the maximum value, the hue H is the difference between green G and blue B; If green G is the maximum value, the hue H is the difference between blue B and red R; If blue B is the maximum, the hue H is the difference between red R and green G; Set the base hue H to 150, the base saturation S to 255, and the base brightness V to 255; Based on the oil-containing colors in each circular area corresponding to the reference hue H of 150, the reference saturation S of 255, and the reference brightness V of 255, the oil-containing area is obtained by comparison, and the proportion of oil content in each area is calculated; The oil content ratio is compared with the set ratio threshold to determine whether the oil content on the lens surface exceeds the standard.
5. The method for detecting water mist and oil mist on the lens surface according to claim 1 or 2, characterized in that: The captured lens image includes: capturing the lens image perpendicular to the lens and arranging the camera on the side of the lens and capturing the lens image at an angle of 35 to 40 degrees to the lens.
6. The method for detecting water mist and oil mist on the lens surface according to claim 1 or 2, characterized in that: The step of parsing the lens information of the lens image also includes: calculating the lens thickness through the lens images taken from multiple viewing angles; The lens thickness is calculated by grayscale processing the lens image, then binarizing it, and using contour detection to confirm the location of the lens; Analyze the difference between the top pixel and the bottom pixel of the lens to obtain the number of virtual pixels, and determine the lens thickness based on the product of the number of virtual pixels and the pixel size; The lens image is also grayscaled and binarized, and the Hough circle method is used to identify the circle in the lens image, match the center of the circle, and calculate the lens area; The lens image is converted from BGR to HSV color space, and a mask is created. Morphological operations are applied to the mask to remove noise, and finally the coating color is obtained.
7. The method for detecting water mist and oil mist on the lens surface according to claim 6, characterized in that: In the method, the calculated lens thickness, lens area and coating color are respectively compared with the preset lens thickness, preset lens area and preset coating color stored in the lens type library, and when the similarity is greater than the preset similarity threshold, the corresponding lens type is matched; The types of lenses include: protective lenses, focusing lenses, collimating lenses and biconvex lenses.
8. A device for detecting water mist and oil mist on the surface of a lens, characterized in that: The device is used to implement the method for detecting water mist and oil mist on the lens surface as claimed in any one of claims 1 to 7; the device comprises: An image acquisition module is used to photograph the lens at multiple angles and acquire images of the lens taken at multiple viewing angles; A lens type acquisition module is used to analyze the lens information of the lens image, obtain the lens type of the lens, and determine the lens area, lens thickness and coating color; A lens image recognition module, used to extract a lens image obtained based on the upper part of the lens, and use the Hough circle to recognize a circle in the lens image and a corresponding center of the circle; A water mist contour detection module is used to divide a circle into at least four regions based on the center of the circle, and analyze the water mist contour area in each region of the lens image based on a contour analysis method; The oil mist area detection module is used to extract the lens image obtained from the side of the lens, divide the circle in the lens image obtained from the side of the lens into at least four circular ring areas, analyze the oil color in each circular ring area through a color analysis algorithm, and calculate the oil area.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method for detecting water mist and oil mist on the lens surface as claimed in any one of claims 1 to 7 are implemented.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for detecting water mist and oil mist on the lens surface as claimed in any one of claims 1 to 7 are implemented.