Lens testing methods, testing equipment, and computer equipment
By taking multiple images of the lens at different focal lengths, the target focal length is determined and vignetting and dirt detection are performed, solving the problems of complex and inefficient lens inspection in existing technologies and achieving efficient multi-indicator detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2026-04-03
AI Technical Summary
The existing lens inspection process requires testing multiple indicators using different equipment on different inspection lines, resulting in a complex and inefficient inspection process.
By acquiring multiple images of the subject taken at different focal lengths, the target focal length is determined, and vignetting and dirt detection are performed at the target focal length, enabling the detection of multiple indicators using a single device.
It simplifies the testing process, improves testing efficiency, and reduces testing costs.
Smart Images

Figure CN116823683B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to lens detection methods, detection equipment, and computer equipment. Background Technology
[0002] During lens production, multiple parameters need to be tested, such as focusing, dirt, and vignetting, to ensure image quality after the lens leaves the factory. However, current lens testing requires different testing equipment on different testing lines, making the process complex and inefficient. Summary of the Invention
[0003] Therefore, it is necessary to provide lens inspection methods, inspection equipment, and computer equipment that are simple to use and have high inspection efficiency to address the above-mentioned technical problems.
[0004] Firstly, this application provides a lens detection method, applied to a detection device, comprising:
[0005] Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length;
[0006] Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0007] If the vignetting detection is passed, a dirt detection image taken by the lens at the target focal length is obtained, and dirt detection is performed based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0008] In one embodiment, acquiring multiple images of the lens to be detected at different focal lengths, and determining the target focal length based on the multiple images to be detected, includes:
[0009] The lens focal length is adjusted sequentially according to a preset order, and the image to be detected is captured at the current focal length after each adjustment.
[0010] In response to each acquired image to be detected, occlusion detection is performed on the image to be detected, and the sharpness of the image to be detected is determined after the image to be detected passes the occlusion detection.
[0011] The highest resolution is selected from all determined resolutions, and the focal length of the image to be detected corresponding to the highest resolution is taken as the target focal length.
[0012] In one embodiment, the occlusion detection of the image to be detected includes:
[0013] Obtain the reference image corresponding to the focal length of the image to be detected;
[0014] Multiple boundary regions of the reference image are cropped to obtain a reference boundary image, and multiple boundary regions of the image to be detected are cropped to obtain a detection boundary image, wherein the coordinate values of all pixels included in the multiple boundary regions of the reference image are the same as the coordinate values of all pixels included in the multiple boundary regions of the multiple images to be detected.
[0015] Calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
[0016] In one embodiment, the vignetting detection based on the vignetting detection image includes:
[0017] Four vignetting detection sub-images and an optical center detection image are identified from the vignetting detection image;
[0018] Determine the average brightness value of the four vignetting detection sub-images, and the brightness value of the optical center of the optical center detection image;
[0019] If the difference between the average brightness value and the optical center brightness value is less than the preset vignetting threshold, then vignetting detection is passed.
[0020] In one embodiment, prior to performing vignetting detection based on the vignetting detection image, the method further includes:
[0021] Obtain the optical center point with the highest brightness value in the vignetting detection image, and the center point of the vignetting detection image;
[0022] If the distance between the center point and the optical center point is less than a preset offset threshold, then optical center offset detection is passed.
[0023] In one embodiment, the dirt detection based on the dirt detection image includes:
[0024] Determine the binarized image corresponding to the dirt detection image;
[0025] The binarized image is processed using dilation and erosion algorithms to obtain the processed image.
[0026] The area of the dirty region is determined based on the processed image. If the area of the dirty region is less than a preset dirt threshold, then the dirt detection is passed.
[0027] Secondly, this application also provides a testing device, comprising:
[0028] The focusing module is used to acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length.
[0029] The vignetting detection module is used to acquire a vignetting detection image captured by the lens at the target focal length, and to perform vignetting detection based on the vignetting detection image;
[0030] The dirt detection module is used to acquire a dirt detection image taken by the lens at the target focal length if the vignetting detection is passed, and to perform dirt detection based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0031] Thirdly, this application also provides a computer device, the computer device including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0032] Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length;
[0033] Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0034] If the vignetting detection is passed, a dirt detection image taken by the lens at the target focal length is obtained, and dirt detection is performed based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0035] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0036] Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length;
[0037] Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0038] If vignetting detection is passed, obtain the dirt detection image captured by the lens at the target focal length, and perform dirt detection based on the dirt detection image. If the dirt detection is passed, determine that the detection result of the lens is qualified.
[0039] In a fifth aspect, the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the following steps are implemented:
[0040] Obtain multiple images to be detected captured by the lens to be detected at different focal lengths, determine the target focal length based on the multiple images to be detected, and adjust the focal length of the lens to the target focal length;
[0041] Obtain the vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0042] If vignetting detection is passed, obtain the dirt detection image captured by the lens at the target focal length, and perform dirt detection based on the dirt detection image. If the dirt detection is passed, determine that the detection result of the lens is qualified.
[0043] The above-mentioned lens detection method, detection device, computer device, storage medium and computer program product. The above-mentioned lens detection method is applied to the detection device. By capturing multiple images to be detected at different focal lengths by the lens, determining the target focal length according to the multiple images to be detected, and adjusting the focal length of the lens to the target focal length to complete the focusing of the lens, obtaining the vignetting detection image captured by the lens at the target focal length, performing vignetting detection according to the vignetting detection image, obtaining the dirt detection image captured by the lens at the target focal length, and performing dirt detection according to the dirt detection image; after the lens passes the vignetting detection and dirt detection, determining that the detection result of the lens is qualified. Through the above-mentioned lens detection method, multiple indicators can be detected by one detection device, the detection process is simple, and the detection efficiency is improved. Description of the Drawings
[0044] Figure 1 It is a schematic flowchart of the lens detection method in an embodiment;
[0045] Figure 2 It is a schematic flowchart of the lens detection method in a specific embodiment;
[0046] Figure 3 It is a structural block diagram of the detection device in an embodiment;
[0047] Figure 4 It is an internal structure diagram of the computer device in an embodiment. Detailed Embodiments
[0048] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0049] In one embodiment, such as Figure 1 As shown, a method for detecting lenses is provided. This embodiment illustrates the application of this method to a detection device. In this embodiment, the method includes the following steps:
[0050] S101: Acquire multiple images of the lens to be tested taken at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length.
[0051] The multiple images to be detected have different focal lengths. These images are obtained by taking pictures of a focusing plate (with a focusing pattern) after each adjustment of the lens's focal length. The lens can capture a clear image at the target focal length. The lens can be an infrared binocular camera.
[0052] Specifically, the lens focal length is adjusted in a preset order, and after each focal length adjustment, the lens is controlled to shoot the focusing plate to obtain the image to be tested; multiple images to be tested are acquired, the sharpness of each image to be tested is determined, the highest sharpness is determined among the sharpness of each image to be tested, and the focal length corresponding to the highest sharpness is taken as the target focal length, and the lens focal length is adjusted to the target focal length.
[0053] Determining the sharpness of each image to be detected can be done in real time after each image is acquired, or it can be done after acquiring multiple images to be detected.
[0054] S102, acquire the vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image.
[0055] The vignetting detection image can be the image among the multiple images to be detected that corresponds to the target focal length, or it can be a vignetting detection image reshot by controlling the lens at the target focal length. The vignetting detection is used to determine whether the lens's vignetting correction is effective. If the lens fails the vignetting detection, the lens's vignetting correction algorithm needs to be modified.
[0056] At the four corners of the vignetting detection image, four sub-images of the vignetting detection image are obtained. The sub-images of the vignetting detection image are the vignetting detection sub-images. Calculate the average brightness values of the four vignetting detection sub-images, and determine the optical center brightness value of the vignetting detection image. If the difference between the optical center brightness value and the average brightness value is less than the preset vignetting threshold, the lens passes the vignetting detection. The preset vignetting threshold can be an empirical value of vignetting detection, or the preset vignetting threshold can be set according to actual requirements.
[0057] If the difference between the optical center brightness value and the average brightness value is greater than or equal to the preset vignetting threshold, it is determined that the lens fails the vignetting detection, a first prompt is issued, and the lens detection process ends. The first prompt is used to reflect that the detection result of the lens is: the vignetting detection fails.
[0058] S103, if the vignetting detection is passed, obtain the dirt detection image taken by the lens at the target focal length, and perform dirt detection based on the dirt detection image. If the dirt detection is passed, determine that the detection result of the lens is qualified.
[0059] Among them, the dirt detection image is an image obtained by the lens taking a white board with uniform supplementary light at the target focal length. The distance between the white board and the lens is the same as the distance between the focusing board and the lens. The dirt detection is used to detect whether there is dirt on the lens. If there is dirt on the lens, the image taken of the white board can show the dirt.
[0060] Specifically, determine the binary image of the vignetting detection image. If there is dirt on the lens, the binary image can show the dirt area. If there is no dirt area in the binary image, the lens passes the dirt detection; at this point, the lens has completed focusing and passed the vignetting detection and dirt detection, and it can be determined that the detection result of the lens is qualified.
[0061] If the lens fails the dirt detection, a second prompt is issued, and the lens detection process ends. The second prompt is used to reflect that the detection result of the lens is: the dirt detection fails.
[0062] In the above lens detection method, multiple images to be detected at different focal lengths are taken by the lens, the target focal length is determined according to the multiple images to be detected, the focal length of the lens is adjusted to the target focal length to complete the focusing of the lens, the vignetting detection image taken by the lens at the target focal length is obtained, vignetting detection is performed according to the vignetting detection image. After the lens passes the vignetting detection, the dirt detection image taken by the lens at the target focal length is obtained, dirt detection is performed according to the dirt detection image. After the lens passes the vignetting detection and dirt detection, it is determined that the detection result of the lens is qualified. Through the above lens detection method, multiple indicators can be detected by one detection device, the detection process is simple, the detection efficiency is improved, and the detection cost is reduced.
[0063] In one embodiment, S101, acquiring multiple images of the lens to be detected at different focal lengths, and determining the target focal length based on the multiple images to be detected, includes:
[0064] S111, adjust the focal length of the lens sequentially according to a preset order, and after each focal length adjustment, acquire the image to be detected captured at the current focal length.
[0065] Specifically, the preset order can be an order from smallest to largest focal length, that is, first adjust the lens focal length to the minimum focal length, and then adjust the lens focal length multiple times in the order from smallest to largest focal length until the maximum focal length is adjusted; or, the preset order can also be an order from largest to smallest focal length, that is, first adjust the lens focal length to the maximum focal length, and then adjust the lens focal length multiple times in the order from largest to smallest focal length until the minimum focal length is adjusted; the maximum focal length is the maximum value within the adjustable focal length range of the lens, and the minimum focal length is the minimum value within the adjustable focal length range of the lens.
[0066] After each focus adjustment, the lens is controlled to capture the image to be detected at the current focus, and the image to be detected is acquired, resulting in multiple images to be detected.
[0067] S112, in response to each acquired image to be detected, occlusion detection is performed on the image to be detected, and after the image to be detected passes the occlusion detection, the clarity of the image to be detected is determined.
[0068] Specifically, during the process of adjusting the lens focus, there may be situations where objects obstruct the lens. For example, when manually adjusting the lens focus, a finger may block the lens, or the components used to fix the lens may be improperly installed, resulting in lens obstruction.
[0069] High-resolution images have sharp edges, resulting in a larger gradient. If an image is occluded, the occluded area will cause the gradient to be very small, leading to the identification of occluded images as having low resolution. In reality, however, the resolution of an occluded image may be very high, resulting in inaccurate resolution identification. In other words, if the image to be detected is occluded, it will lead to inaccurate resolution. Therefore, it is necessary to remove occluded images and indicate the presence of occlusion.
[0070] In one embodiment, since occlusion typically occurs at the edges of an image, to reduce the computational cost of occlusion detection, a boundary image of the image to be detected is cropped, and occlusion detection is performed using this boundary image. S112 includes:
[0071] S1121, Obtain the reference image corresponding to the focal length of the image to be detected.
[0072] Specifically, the reference image and the image to be detected are photographed from the same object. If the image to be detected is an image obtained by photographing the focusing plate, then the reference image is also an image obtained by photographing the focusing plate. The reference lens that photographs the reference image has the same field of view as the lens. When the reference lens photographs the reference image, its position relative to the object is the same as when the lens photographs the image to be detected, so that the content of the reference image is consistent with the content of the object to be detected. The reference image is not occluded.
[0073] S1122, multiple boundary regions of the reference image are cropped to obtain a reference boundary image, and multiple boundary regions of the image to be detected are cropped to obtain a detection boundary image.
[0074] The plurality of boundary regions include: an upper boundary region, a lower boundary region, a left boundary region, and a right boundary region. The coordinate values of all pixels within the plurality of boundary regions of the reference image are the same as the coordinate values of all pixels within the plurality of boundary regions of the images to be detected. For example, the coordinate values of all pixels within the upper boundary region of the reference image are the same as the coordinate values of all pixels within the upper boundary region of the images to be detected.
[0075] For example, let the coordinates of the top-left pixel in both the reference image and the detection image be (1,1). Let the coordinates of all pixels in the upper boundary region of the reference image be (a,b), where 1≤a≤20, 1≤b≤20. Let the coordinates of all pixels in the upper boundary region of the image to be detected be (c,d), where 1≤c≤20, 1≤d≤20. For any pixel in the upper boundary region of the reference image, there exists a pixel in the upper boundary region of the image to be detected with the same coordinates. Therefore, it can be concluded that the coordinates of all pixels in the upper boundary region of the reference image are identical to the coordinates of all pixels in the upper boundary region of the image to be detected.
[0076] Specifically, the upper boundary region, lower boundary region, left boundary region, and right boundary region of the reference image are cropped to obtain the reference boundary image, and the upper boundary region, lower boundary region, left boundary region, and right boundary region of the image to be detected are cropped to obtain the boundary image to be detected.
[0077] Based on the preset boundary width, the upper boundary region, lower boundary region, left boundary region, and right boundary region are determined. The boundary width can be represented by the number of pixels and can be set according to actual needs.
[0078] For example, if the boundary width is 50, and the size of the reference image and the image to be detected is 400*400, then all pixels with row coordinates 1 to 50 are taken as pixels of the upper boundary region, all pixels with row coordinates 351 to 400 are taken as pixels of the lower boundary region, all pixels with column coordinates 1 to 50 are taken as pixels of the left boundary region, and all pixels with column coordinates 351 to 400 are taken as pixels of the lower boundary region. Therefore, the reference boundary image includes all pixels with row coordinates 1 to 50 and 351 to 400, and all pixels with column coordinates 1 to 50 and 351 to 400 in the reference image. The image to be detected includes all pixels with row coordinates 1 to 50 and 351 to 400, and all pixels with column coordinates 1 to 50 and 351 to 400 in the image to be detected.
[0079] S1123, calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
[0080] Specifically, the preset similarity threshold can be set according to requirements. A first histogram is determined based on the brightness value of the reference boundary image, and a second histogram is determined based on the brightness value of the boundary image to be detected. The similarity is calculated based on the first and second histograms. If the similarity is greater than the preset similarity threshold, the image to be detected passes the occlusion detection.
[0081] If the similarity is not greater than the preset similarity threshold, the image to be detected fails the occlusion detection. The image to be detected is then removed, and a third prompt is issued, which is used to reflect that the lens is occluded.
[0082] S113, Select the highest resolution among all the determined resolutions, and take the focal length of the image to be detected corresponding to the highest resolution as the target focal length.
[0083] Specifically, the focal length corresponding to the highest resolution among all resolutions is taken as the target focal length.
[0084] In one embodiment, S101 includes:
[0085] The lens focal length is adjusted sequentially according to a preset order. After each focal length adjustment, an image to be tested is captured at the current focal length. In response to each acquired image to be tested, occlusion detection is performed on the image to be tested. After the image to be tested passes the occlusion detection, the sharpness of the image to be tested is determined. If the determined sharpness is greater than a preset sharpness threshold, the focal length corresponding to the determined sharpness is taken as the target focal length.
[0086] For example, adjust the lens focal length to f1 and acquire the image P1 to be tested taken by the lens at f1. If P1 passes the occlusion detection, the sharpness s1 of P1 is determined. If s1 is not greater than the preset sharpness threshold, adjust the lens focal length to f2 and acquire the image P2 to be tested taken by the lens at f2. If P2 passes the occlusion detection, the sharpness s2 of P2 is determined. If s2 is not greater than the preset sharpness threshold, adjust the lens focal length to f3 and acquire the image P3 to be tested taken by the lens at f3. If P3 passes the occlusion detection, the sharpness s3 of P1 is determined. If s3 is greater than the preset sharpness threshold, the target focal length is determined to be f3.
[0087] In one embodiment, S102, the vignetting detection based on the vignetting detection image includes:
[0088] S1021, four vignetting detection sub-images and an optical center detection image are determined from the vignetting detection image.
[0089] Specifically, the four vignetting detection sub-images are designated as a first vignetting detection sub-image, a second vignetting detection sub-image, a third vignetting detection sub-image, and a fourth vignetting detection sub-image. The first vignetting detection sub-image is determined based on the pixels of the first corner of the vignetting detection image and a preset side length; the second vignetting detection sub-image is determined based on the pixels of the second corner of the vignetting detection image and a preset side length; the third vignetting detection sub-image is determined based on the pixels of the third corner of the vignetting detection image and a preset side length; and the fourth vignetting detection sub-image is determined based on the pixels of the fourth corner of the vignetting detection image and a preset side length. The center of the optical center detection image is the optical center of the vignetting detection image, and the optical center detection image is determined based on the optical center and a preset side length. The optical center detection image has the same size as any of the vignetting detection sub-images.
[0090] For example, assuming a preset side length of 50 pixels, the pixels at the four corners of the vignetting detection image include: (1,1), (1,400), (400,1), (400,400). The first vignetting detection sub-image includes all pixels with row coordinates from 1 to 50 and column coordinates from 1 to 50. The second vignetting detection sub-image includes all pixels with row coordinates from 351 to 400 and column coordinates from 1 to 50. The third vignetting detection sub-image includes all pixels with row coordinates from 1 to 50 and column coordinates from 351 to 400. The fourth vignetting detection sub-image includes all pixels with row coordinates from 351 to 400 and column coordinates from 351 to 400.
[0091] S1022, determine the average brightness value of the four vignetting detection sub-images, and the brightness value of the optical center detection image.
[0092] S1023, if the difference between the average brightness value and the optical center brightness value is less than the preset vignetting threshold, then the vignetting detection image passes the vignetting detection.
[0093] Specifically, the preset vignetting threshold can be set according to actual needs. If the difference is less than the preset vignetting threshold, the lens passes the vignetting detection. If the difference is not less than the preset vignetting threshold, the lens fails the vignetting detection, a first prompt is issued, and the lens detection process ends.
[0094] Prior to S1021, it also included;
[0095] S01, obtain the optical center point with the largest brightness value in the vignetting detection image, and the center point of the vignetting detection image.
[0096] Specifically, the brightness value of each pixel in the vignetting detection image is determined, the point with the largest brightness value is taken as the optical center point of the vignetting detection image, and the center point is determined according to the coordinate value of each pixel in the vignetting detection image.
[0097] S02, if the distance between the center point and the optical center point is less than a preset offset threshold, then optical center offset detection is passed.
[0098] Specifically, the center coordinates of the center point and the optical center coordinates of the optical center point are determined, and the distance between the center coordinates and the optical center coordinates is calculated. If the distance is less than a preset offset threshold, the lens passes the optical center offset detection. The preset offset threshold can be set according to actual needs.
[0099] If the distance is not less than the preset offset distance, it is determined that the lens has failed the optical center offset detection, a fourth prompt is issued, and the lens detection process ends. The fourth prompt is used to reflect the lens detection result as: optical center offset detection failed.
[0100] In one embodiment, S103, the dirt detection based on the dirt detection image includes:
[0101] S1031, determine the binarized image corresponding to the dirt detection image.
[0102] Specifically, since the lens itself has gradient shadows, which are quite similar to the appearance of dirt on the lens, ordinary binarization processing is not easy to separate dirt from shadows. Therefore, adaptive binarization processing is performed on the dirt detection image to obtain a binarized image. The adaptive binarization processing is to obtain a binarization threshold suitable for the dirt detection image based on the gray-level histogram of the image, and then obtain the binarized image based on the binarization threshold and the dirt detection image.
[0103] S1032, The binarized image is processed using dilation and erosion algorithms to obtain the processed image.
[0104] Specifically, in a binarized image, white areas may be dirty areas, while black areas may not be. A dilation algorithm is used to fill in the area around multiple small white dots in the binarized image, connecting adjacent small white dots to obtain a dilated image. This dilated image is then processed using an erosion algorithm to shrink the connected white areas, ensuring that the area of the shrunken white areas is the same as the area occupied by the connected small white dots, resulting in the processed image.
[0105] S1033, determine the area of the dirty region based on the processed image. If the area of the dirty region is less than a preset dirty threshold, then the dirty detection is passed.
[0106] Specifically, the area of the white region in the processed image is calculated to obtain the area of the dirty region. This area can be calculated using the edge area calculation method built into OpenCV. The preset dirt threshold can be set according to actual needs. If the dirty region area is smaller than the preset dirt threshold, then the dirty region passes the dirt detection.
[0107] Although the steps in the various embodiments of the lens detection method described above are written in ascending order of their numbers, these steps are not necessarily performed sequentially in ascending order of their numbers. This is in addition to the steps described in the appendix of the lens detection method. Figure 1 In this document, the steps are displayed sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order in which these steps are executed, and they can be performed in other orders.
[0108] In one specific embodiment, see Figure 2 The lens detection method includes:
[0109] a1. Start the test;
[0110] a2. Acquire the image to be detected captured by the lens, and perform occlusion detection on the image to be detected;
[0111] a3. Determine if the occlusion detection passes. If it fails, proceed to a4; if it passes, proceed to a5.
[0112] a4. Remove the images to be detected and proceed to a6;
[0113] a5. Determine the sharpness of the image to be detected, then proceed to a6;
[0114] a6. Determine if the lens focal length is the maximum value of the adjustable focal length range. If not, proceed to a7; if yes, proceed to a8.
[0115] a7, adjust the lens focal length according to the preset order, then enter a2;
[0116] a8. Use the focal length of the image to be detected corresponding to the highest resolution as the target focal length;
[0117] a9. Adjust the lens to the target focal length;
[0118] a10. Obtain the vignetting detection image captured by the lens at the target focal length, and perform optical center shift detection based on the vignetting detection image;
[0119] a11. Determine whether the optical center offset detection is successful. If the optical center offset detection fails, proceed to a12; if the optical center offset detection is successful, proceed to a13.
[0120] a12. The optical center offset test failed, and the lens test result is unqualified.
[0121] a13. Perform vignetting detection based on the vignetting detection image;
[0122] a14. Determine if the vignetting detection passes. If the vignetting detection fails, proceed to a15. If the vignetting detection passes, proceed to a16.
[0123] a15. The vignetting test failed, and the lens test result is unqualified.
[0124] a16. Obtain the dirt detection image captured by the lens at the target focal length;
[0125] a17. Perform dirt detection based on dirt detection images;
[0126] a18. Determine whether the dirt detection has passed. If the dirt detection has failed, proceed to a19. If the dirt detection has passed, proceed to a20.
[0127] a19. The dirt test failed, and the lens test result is unqualified.
[0128] a20. The lens's test results are qualified.
[0129] The lens inspection method described above ensures that the lens is qualified only after successful focusing, optical center shift detection, vignetting detection, and dirt detection. This guarantees the quality of lens inspection. When a large number of lenses need to be inspected, each lens can be inspected using the above-mentioned a1 to a20 methods, enabling rapid batch inspection of lenses. This method is suitable for application scenarios involving the inspection of a large number of lenses.
[0130] Although the embodiment of the above lens detection method is implemented according to steps a1 to a20, it involves the following appendices. Figure 2 Steps a1 to a20 are shown sequentially as indicated by the arrows, but these steps are not necessarily performed in the exact order indicated by the arrows. Unless otherwise specified in this document, there is no strict order in which these steps are performed; they can be executed in other orders. For example, steps a1 to a9 can be performed first to adjust the lens to the target focal length, followed by steps a16 to a19 for dirt detection, and then steps a10 to a15 for optical center detection and vignetting detection.
[0131] In this embodiment, multiple images to be tested are captured by the lens at different focal lengths. The target focal length is determined based on the multiple images, and the lens is adjusted to the target focal length to complete the lens focusing. A vignetting detection image is obtained by the lens at the target focal length, and vignetting detection is performed based on the vignetting detection image. A dirt detection image is obtained by the lens at the target focal length, and dirt detection is performed based on the dirt detection image. After the lens passes the vignetting detection and dirt detection, the lens is determined to be qualified. Through the above lens testing method, multiple indicators can be tested with one testing device. The testing process is simple, improves testing efficiency, and reduces testing costs.
[0132] It should be understood that at least some steps in the flowcharts involved in the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.
[0133] Based on the same inventive concept, this application also provides a testing device for implementing the lens testing method described above. The solution provided by this testing device is similar to the solution described in the above method; therefore, the specific limitations in the testing device embodiments provided below can be found in the limitations of the lens testing method described above, and will not be repeated here.
[0134] In one embodiment, such as Figure 3 As shown, a detection device is provided, comprising:
[0135] The focusing module 100 is used to acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length.
[0136] The vignetting detection module 200 is used to acquire a vignetting detection image captured by the lens at the target focal length, and to perform vignetting detection based on the vignetting detection image;
[0137] The dirt detection module 300 is used to acquire a dirt detection image taken by the lens at the target focal length if the vignetting detection is passed, and to perform dirt detection based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0138] In one embodiment, the focusing module includes:
[0139] The focusing unit is used to adjust the focal length of the lens sequentially according to a preset order, and to acquire the image to be detected at the current focal length after each adjustment.
[0140] An occlusion detection unit is used to perform occlusion detection on the image to be detected in response to each acquired image to be detected, and to determine the sharpness of the image to be detected after the image to be detected passes the occlusion detection.
[0141] The target focal length determination unit is used to select the highest resolution among all determined resolutions and take the focal length of the image to be detected corresponding to the highest resolution as the target focal length.
[0142] In one embodiment, the occlusion detection unit includes:
[0143] The first processing unit is used to obtain a reference image corresponding to the focal length of the image to be detected;
[0144] The second processing unit is used to extract multiple boundary regions of the reference image to obtain a reference boundary image, and to extract multiple boundary regions of the image to be detected to obtain a detection boundary image, wherein the coordinate values of all pixels included in the multiple boundary regions of the reference image are the same as the coordinate values of all pixels included in the multiple boundary regions of the multiple images to be detected.
[0145] The third processing unit is used to calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
[0146] In one embodiment, the vignetting detection module includes:
[0147] An image determination unit is used to determine four vignetting detection sub-images and an optical center detection image in the vignetting detection image;
[0148] A brightness value determination unit is used to determine the average brightness value of the four dark corner detection sub-images and the brightness value of the optical center detection image;
[0149] The vignetting detection unit is used to detect vignetting if the difference between the average brightness value and the optical center brightness value is less than a preset vignetting threshold.
[0150] In one embodiment, the detection device further includes:
[0151] The optical center offset detection module is used to obtain the optical center point with the largest brightness value in the vignetting detection image, as well as the center point of the vignetting detection image; if the distance between the center point and the optical center point is less than a preset offset threshold, then the optical center offset detection is passed.
[0152] In one embodiment, the dirt detection module includes:
[0153] The binarization processing unit is used to determine the binarized image corresponding to the dirt detection image;
[0154] The dilation and erosion processing unit is used to process the binarized image using a dilation algorithm and an erosion algorithm to obtain the processed image.
[0155] A dirt detection unit is used to determine the area of the dirty region based on the processed image. If the area of the dirty region is less than a preset dirt threshold, the dirt detection is passed.
[0156] Each module in the aforementioned testing equipment can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0157] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 4As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a lens detection method. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0158] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0159] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0160] Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length;
[0161] Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0162] If the vignetting detection is passed, a dirt detection image taken by the lens at the target focal length is obtained, and dirt detection is performed based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0163] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0164] Acquiring multiple images of the lens to be tested at different focal lengths, and determining the target focal length based on the multiple images, includes:
[0165] The lens focal length is adjusted sequentially according to a preset order, and the image to be detected is captured at the current focal length after each adjustment.
[0166] In response to each acquired image to be detected, occlusion detection is performed on the image to be detected, and the sharpness of the image to be detected is determined after the image to be detected passes the occlusion detection.
[0167] The highest resolution is selected from all determined resolutions, and the focal length of the image to be detected corresponding to the highest resolution is taken as the target focal length.
[0168] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0169] The occlusion detection of the image to be detected includes:
[0170] Obtain the reference image corresponding to the focal length of the image to be detected;
[0171] Multiple boundary regions of the reference image are cropped to obtain a reference boundary image, and multiple boundary regions of the image to be detected are cropped to obtain a detection boundary image, wherein the coordinate values of all pixels included in the multiple boundary regions of the reference image are the same as the coordinate values of all pixels included in the multiple boundary regions of the multiple images to be detected.
[0172] Calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
[0173] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0174] The vignetting detection based on the vignetting detection image includes:
[0175] Four vignetting detection sub-images and an optical center detection image are identified from the vignetting detection image;
[0176] Determine the average brightness value of the four vignetting detection sub-images, and the brightness value of the optical center of the optical center detection image;
[0177] If the difference between the average brightness value and the optical center brightness value is less than the preset vignetting threshold, then vignetting detection is passed.
[0178] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0179] Before performing vignetting detection based on the vignetting detection image, the method further includes:
[0180] Obtain the optical center point with the highest brightness value in the vignetting detection image, and the center point of the vignetting detection image;
[0181] If the distance between the center point and the optical center point is less than a preset offset threshold, then optical center offset detection is passed.
[0182] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0183] The dirt detection based on the dirt detection image includes:
[0184] Determine the binarized image corresponding to the dirt detection image;
[0185] The binarized image is processed using dilation and erosion algorithms to obtain the processed image.
[0186] The area of the dirty region is determined based on the processed image. If the area of the dirty region is less than a preset dirt threshold, then the dirt detection is passed.
[0187] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0188] Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length;
[0189] Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0190] If the vignetting detection is passed, a dirt detection image taken by the lens at the target focal length is obtained, and dirt detection is performed based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0191] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0192] Acquiring multiple images of the lens to be tested at different focal lengths, and determining the target focal length based on the multiple images, includes:
[0193] The lens focal length is adjusted sequentially according to a preset order, and the image to be detected is captured at the current focal length after each adjustment.
[0194] In response to each acquired image to be detected, occlusion detection is performed on the image to be detected, and the sharpness of the image to be detected is determined after the image to be detected passes the occlusion detection.
[0195] The highest resolution is selected from all determined resolutions, and the focal length of the image to be detected corresponding to the highest resolution is taken as the target focal length.
[0196] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0197] The occlusion detection of the image to be detected includes:
[0198] Obtain the reference image corresponding to the focal length of the image to be detected;
[0199] Multiple boundary regions of the reference image are cropped to obtain a reference boundary image, and multiple boundary regions of the image to be detected are cropped to obtain a detection boundary image, wherein the coordinate values of all pixels included in the multiple boundary regions of the reference image are the same as the coordinate values of all pixels included in the multiple boundary regions of the multiple images to be detected.
[0200] Calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
[0201] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0202] The vignetting detection based on the vignetting detection image includes:
[0203] Four vignetting detection sub-images and an optical center detection image are identified from the vignetting detection image;
[0204] Determine the average brightness value of the four vignetting detection sub-images, and the brightness value of the optical center of the optical center detection image;
[0205] If the difference between the average brightness value and the optical center brightness value is less than the preset vignetting threshold, then vignetting detection is passed.
[0206] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0207] Before performing vignetting detection based on the vignetting detection image, the method further includes:
[0208] Obtain the optical center point with the highest brightness value in the vignetting detection image, and the center point of the vignetting detection image;
[0209] If the distance between the center point and the optical center point is less than a preset offset threshold, then optical center offset detection is passed.
[0210] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0211] The dirt detection based on the dirt detection image includes:
[0212] Determine the binarized image corresponding to the dirt detection image;
[0213] The binarized image is processed using dilation and erosion algorithms to obtain the processed image.
[0214] The area of the dirty region is determined based on the processed image. If the area of the dirty region is less than a preset dirt threshold, then the dirt detection is passed.
[0215] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0216] Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length;
[0217] Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image;
[0218] If the vignetting detection is passed, a dirt detection image taken by the lens at the target focal length is obtained, and dirt detection is performed based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
[0219] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0220] Acquiring multiple images of the lens to be tested at different focal lengths, and determining the target focal length based on the multiple images, includes:
[0221] The lens focal length is adjusted sequentially according to a preset order, and the image to be detected is captured at the current focal length after each adjustment.
[0222] In response to each acquired image to be detected, occlusion detection is performed on the image to be detected, and the sharpness of the image to be detected is determined after the image to be detected passes the occlusion detection.
[0223] The highest resolution is selected from all determined resolutions, and the focal length of the image to be detected corresponding to the highest resolution is taken as the target focal length.
[0224] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0225] The occlusion detection of the image to be detected includes:
[0226] Obtain the reference image corresponding to the focal length of the image to be detected;
[0227] Multiple boundary regions of the reference image are cropped to obtain a reference boundary image, and multiple boundary regions of the image to be detected are cropped to obtain a detection boundary image, wherein the coordinate values of all pixels included in the multiple boundary regions of the reference image are the same as the coordinate values of all pixels included in the multiple boundary regions of the multiple images to be detected.
[0228] Calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
[0229] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0230] The vignetting detection based on the vignetting detection image includes:
[0231] Four vignetting detection sub-images and an optical center detection image are identified from the vignetting detection image;
[0232] Determine the average brightness value of the four vignetting detection sub-images, and the brightness value of the optical center of the optical center detection image;
[0233] If the difference between the average brightness value and the optical center brightness value is less than the preset vignetting threshold, then vignetting detection is passed.
[0234] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0235] Before performing vignetting detection based on the vignetting detection image, the method further includes:
[0236] Obtain the optical center point with the highest brightness value in the vignetting detection image, and the center point of the vignetting detection image;
[0237] If the distance between the center point and the optical center point is less than a preset offset threshold, then optical center offset detection is passed.
[0238] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0239] The dirt detection based on the dirt detection image includes:
[0240] Determine the binarized image corresponding to the dirt detection image;
[0241] The binarized image is processed using dilation and erosion algorithms to obtain the processed image.
[0242] The area of the dirty region is determined based on the processed image. If the area of the dirty region is less than a preset dirt threshold, then the dirt detection is passed.
[0243] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0244] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0245] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0246] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for detecting a lens, characterized in that, Applied to testing equipment, including: Acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length; Acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image; wherein, performing vignetting detection based on the vignetting detection image includes: Four vignetting detection sub-images and a light center detection image are determined in the vignetting detection image; wherein, the center of the light center detection image is the light center of the vignetting detection image, and the light center detection image is determined based on the light center and a preset side length; the vignetting detection sub-images are determined based on the pixels of the vignetting detection image and the preset side length; Determine the average brightness value of the four vignetting detection sub-images, and the brightness value of the optical center of the optical center detection image; If the difference between the average brightness value and the optical center brightness value is less than a preset vignetting threshold, then vignetting detection is passed; If the vignetting detection is passed, a dirt detection image taken by the lens at the target focal length is obtained, and dirt detection is performed based on the dirt detection image. If the dirt detection is passed, the detection result of the lens is determined to be qualified.
2. The detection method according to claim 1, characterized in that, The process of acquiring multiple images of the lens to be detected at different focal lengths, and determining the target focal length based on the multiple images to be detected, includes: The lens focal length is adjusted sequentially according to a preset order, and the image to be detected is captured at the current focal length after each adjustment. In response to each acquired image to be detected, occlusion detection is performed on the image to be detected, and the sharpness of the image to be detected is determined after the image to be detected passes the occlusion detection. The highest resolution is selected from all determined resolutions, and the focal length of the image to be detected corresponding to the highest resolution is taken as the target focal length.
3. The detection method according to claim 2, characterized in that, The occlusion detection of the image to be detected includes: Obtain the reference image corresponding to the focal length of the image to be detected; Multiple boundary regions of the reference image are cropped to obtain a reference boundary image, and multiple boundary regions of the image to be detected are cropped to obtain a detection boundary image, wherein the coordinate values of all pixels included in the multiple boundary regions of the reference image are the same as the coordinate values of all pixels included in the multiple boundary regions of the multiple images to be detected. Calculate the similarity between the reference boundary image and the boundary image to be detected. If the similarity is greater than a preset similarity threshold, the image to be detected passes the occlusion detection.
4. The detection method according to any one of claims 1 to 3, characterized in that, Before performing vignetting detection based on the vignetting detection image, the method further includes: Obtain the optical center point with the highest brightness value in the vignetting detection image, and the center point of the vignetting detection image; If the distance between the center point and the optical center point is less than a preset offset threshold, then optical center offset detection is passed.
5. The detection method according to claim 1, characterized in that, The dirt detection based on the dirt detection image includes: Determine the binarized image corresponding to the dirt detection image; The binarized image is processed using dilation and erosion algorithms to obtain the processed image. The area of the dirty region is determined based on the processed image. If the area of the dirty region is less than a preset dirt threshold, then the dirt detection is passed.
6. The detection method according to claim 5, characterized in that, Determining the binarized image corresponding to the dirt detection image includes: An adaptive binarization process is performed on the dirt detection image to obtain a binarized image; wherein the adaptive binarization process includes determining a binarization threshold based on the grayscale histogram of the dirt detection image; and obtaining the binarized image based on the binarization threshold and the dirt detection image. The process of processing the binarized image using dilation and erosion algorithms to obtain the processed image includes: The dilation algorithm is used to fill in the white dots around multiple white dots in the binarized image, resulting in a dilated image. The dilated image is processed by an erosion algorithm, which reduces the white area obtained by connecting the white dots, so that the area of the reduced white area is the same as the area occupied by the multiple white dots before they were connected, thus obtaining the processed image.
7. A testing device, characterized in that, include: The focusing module is used to acquire multiple images of the lens to be tested at different focal lengths, determine the target focal length based on the multiple images to be tested, and adjust the focal length of the lens to the target focal length. A vignetting detection module is used to acquire a vignetting detection image captured by the lens at the target focal length, and perform vignetting detection based on the vignetting detection image. The vignetting detection based on the vignetting detection image includes: determining four vignetting detection sub-images and a light center detection image in the vignetting detection image; wherein the center of the light center detection image is the light center of the vignetting detection image, and the light center detection image is determined based on the light center and a preset side length; the vignetting detection sub-images are determined based on the pixels of the vignetting detection image and the preset side length; determining the average brightness value of the four vignetting detection sub-images and the light center brightness value of the light center detection image; if the difference between the average brightness value and the light center brightness value is less than a preset vignetting threshold, then the vignetting detection is passed. A dirt detection module is used to acquire a dirt detection image captured by the lens at the target focal length if the vignetting detection is passed, and perform dirt detection based on the dirt detection image; if the dirt detection is passed, then the detection result of the lens is determined to be qualified.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, The processor is used to execute the computer program to implement the steps of the detection method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the detection method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the detection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Focusing method and device
CN106412423A
Imaging difference detection method and apparatus
CN107465912A
Camera detection method and device and readable storage medium
CN111629202A
Dynamic detection method for smudginess of vehicle-mounted camera
CN113643313A
Camera focusing test instrument
CN203433264U