Focusing detection method, system and device and medium
By constructing a mapping model between the real-time focal length of the zoom lens and the temperature and control voltage, as well as a mapping model between the center of mass offset of the light spot and the current focal length, the problems of poor autofocus accuracy and imaging detection effect of laser ranging at close distances are solved, and high-precision close-range imaging detection is achieved.
Patent Information
- Application Number
- CN202510615536.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-09-12
AI Technical Summary
In the prior art, active focus systems based on laser ranging suffer from poor autofocus accuracy and imaging detection effects at close distances due to clock jitter and quantization errors.
By constructing a first mapping model of the real-time focal length of the zoom lens with temperature and control voltage, and a second mapping model of the target focal length of the zoom lens with the center of mass offset of the light spot and the current focal length, the target voltage of the zoom lens is directly calculated in combination with the center of mass offset of the light spot to improve the accuracy of close-range imaging detection.
It effectively solves the problem of insufficient autofocus accuracy during close-range detection, improves imaging detection effects, avoids laser ranging errors, shortens data acquisition time, reduces the risk of overfitting during model fitting, and improves the model's generalization ability and detection efficiency.
Smart Images

Figure CN120628547A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of machine vision, and in particular relates to a focus detection method, system, device and medium. Background Art
[0002] In the field of optical imaging and autofocus, active focus systems based on laser ranging are widely used in cameras, smartphones, industrial inspection equipment, and other scenarios due to their fast response. Their core principle is to transmit a modulated laser beam from a laser transmitter to a target. After receiving the reflected signal, the time difference or phase difference is used to calculate the target distance, which in turn drives the zoom lens to adjust the focal length, achieving rapid focus.
[0003] However, laser ranging relies on a high-precision clock to measure the laser's round-trip time (Time-of-Flight (ToF)). Limited by hardware cost and power consumption, clock frequencies typically cannot exceed 100 MHz. As the demand for near-field imaging accuracy increases, when the target is at close range (e.g., within 10 cm), the actual close-range error is further amplified by clock jitter and quantization error accumulation, seriously affecting autofocus accuracy and subsequent imaging detection results.
[0004] Therefore, in order to improve the autofocus accuracy during close-range detection and ensure the subsequent imaging detection effect, the present invention provides a focus detection method, system, device and medium. Summary of the Invention
[0005] The purpose of the present invention is to overcome the above problems existing in the prior art and provide a focus detection method, system, device and medium. For the technical problem of large laser ranging error during close-range automatic focusing, the first mapping model between the real-time focal length of the zoom lens and the zoom lens temperature and control voltage is fitted, and a second mapping model between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens is fitted, and the target voltage of the zoom lens is directly calculated based on the light spot centroid offset of the object to be measured, so as to improve the accuracy of close-range imaging detection.
[0006] In order to achieve the above technical objectives and the above technical effects, the present invention is implemented through the following technical solutions: A focus detection method adjusts the focal length of a zoom lens so that the image information of the object to be measured meets the clarity requirement. The detection method includes: Constructing a first mapping model between the real-time focal length of the zoom lens and the temperature and control voltage of the zoom lens, collecting the real-time focal length of the zoom lens at different temperatures and control voltages, and fitting to obtain model parameters in the first mapping model; The semi-blocked laser beam is emitted through the zoom lens to the surface of the calibration object to obtain a spot image formed on the surface of the calibration object; Constructing a second mapping model between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens, changing the current focal length of the zoom lens, and collecting the target focal lengths corresponding to the zoom lens at different current focal lengths and light spot centroid offsets to obtain the model parameters in the second mapping model through fitting; A semi-blocked laser beam is emitted through a zoom lens to the surface of the object to be measured, and a light spot image fed back from the surface of the object to be measured is obtained to calculate the corresponding light spot centroid offset; Collect the centroid offset of the light spot corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model to calculate the target focal length of the zoom lens; The target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model are obtained to calculate a target voltage.
[0007] Furthermore, collecting the real-time focal length of the zoom lens at different temperatures and control voltages includes: Adjust the zoom lens temperature and move the calibration object several times at each temperature so that each movement of the calibration object corresponds to a different object distance and the corresponding image distance is known; Change the control voltage of the focus lens at different object distances so that the image information of the calibration object meets the clarity requirements; The real-time focal length of the focus lens at different object distances is calculated to obtain the zoom lens temperature and control voltage corresponding to the real-time focal length.
[0008] Furthermore, the target focal length corresponding to the zoom lens at different current focal lengths and spot centroid offsets is collected, including: Adjust the zoom lens control voltage to make the current focal length of the zoom lens different; Move the calibration object and collect the spot images fed back by the calibration object at different positions to calculate the corresponding spot centroid offset; The focal length of the zoom lens is changed so that the image information of the calibration object at the current position meets the clarity requirement, and the focal length of the zoom lens at this time is used as the target focal length.
[0009] Furthermore, the calculation method of the spot centroid offset includes: Collect the spot image fed back by the calibration object or the object to be measured to calculate the average value of each row of data in the spot image, where each row of data is distributed along the long axis of the spot image; Obtain the average value of each row of data in the spot image, and perform weighted averaging based on the position of the corresponding row of data to obtain the centroid position of the spot; The spot centroid position and the reference centroid position are collected, and the difference is calculated to obtain the spot centroid offset.
[0010] Furthermore, it also includes: Collect the spot image fed back by the calibration object or the object to be measured, and perform median filtering and Gaussian filtering in succession to complete the spot image preprocessing; Calculate the gradient size and direction of each pixel position in the spot image, and use the gradient method to calculate the edge coordinates of the spot image; Extract the edge coordinates of the spot image to calculate the geometric centroid position of the spot image, and then calculate the geometric offset of the spot centroid according to the reference centroid position; It is determined whether the difference between the spot centroid geometric offset and the spot centroid offset is less than a preset threshold. If so, the corresponding spot centroid offset is retained; if not, the corresponding spot centroid offset is discarded.
[0011] Furthermore, before extracting the edge coordinates of the spot image, the following steps are also included: Collect any edge coordinates, and extract pixel coordinates and grayscale values within a preset range with the edge coordinates as the center; The grayscale centroid within the range is calculated to obtain the corrected edge coordinates.
[0012] Furthermore, before extracting the edge coordinates of the spot image, the method further includes: constructing a semi-ellipse equation, and completing the fitting of the semi-ellipse equation using the edge coordinates, so as to fill in the missing edge points through linear interpolation.
[0013] The present invention also provides a focus detection system, comprising: A first fitting module is used to construct a first mapping model between the real-time focal length of the zoom lens and the temperature and control voltage of the zoom lens, collect the real-time focal length of the zoom lens under different temperatures and control voltages, and fit the model parameters in the first mapping model; A first laser control module is used to emit a semi-blocked laser beam through a zoom lens to the surface of the calibration object to obtain a spot image formed on the surface of the calibration object; A second fitting module is used to construct a second mapping model between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens, change the current focal length of the zoom lens, and collect the target focal lengths corresponding to the zoom lens under different current focal lengths and light spot centroid offsets to fit the model parameters in the second mapping model; The second laser control module is used to emit a semi-blocked laser beam through the zoom lens to the surface of the object to be measured, and obtain the light spot image fed back from the surface of the object to be measured to calculate the corresponding light spot centroid offset; The target focal length analysis module is used to collect the centroid offset of the light spot corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model to calculate the target focal length of the zoom lens; The target voltage analysis module is used to obtain the target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model to calculate the target voltage.
[0014] The present invention also provides a focus detection device, comprising: A laser light source is used to emit a laser beam, which passes through a collimating lens and an aperture in sequence to form a semi-blocked collimated beam; The zoom lens is used to project a semi-blocked collimated light beam onto the surface of the object to be measured to form a light spot and receive image information fed back by the object to be measured; The first image sensor is used to collect the light spot image fed back by the object to be measured; The second image sensor is used to collect image information of the surface of the object to be measured; a dichroic prism, configured to transmit the collimated light beam from the laser light source to the zoom lens, and transmit the light spot image and the surface image information of the object to be measured to the first image sensor and the second image sensor respectively; The detection module is connected to the first image sensor and is used to execute the above detection method.
[0015] The present invention also provides a computer-readable storage medium, comprising a computer program, wherein the computer program implements the above detection method when executed by a processor.
[0016] The beneficial effects of the present invention are: (1) The various steps in the detection method of the present invention are closely integrated, which solves the problem of insufficient autofocus accuracy during close-range detection as a whole. The specific effects of combining the various steps are as follows: By pre-building a first mapping model between the real-time focal length of the zoom lens and its temperature and control voltage, the parameters of the first mapping model are calibrated in advance. The impact of the zoom lens temperature on the lens material is fully considered, allowing the zoom lens's focal length control to achieve the desired focal length effect through voltage adjustment at any temperature, providing an accurate and reliable data foundation for subsequent processes. By emitting a semi-blocked laser beam through the zoom lens to the surface of the calibration object, the focus state of the calibration object can be intuitively fed back through the spot image formed on the calibration object surface. The ideal focal length state can be achieved by adjusting the zoom lens voltage. Not only can it adapt to the calibration objects of different object distances to achieve clear imaging, but compared with existing object distance adjustment solutions, it is not affected by the hysteresis of the objective lens movement, its focusing speed is faster, and the generated image clarity is better; By constructing a second mapping model between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens, the advance calibration of each model parameter in the second mapping model is achieved. Not only is the fitting relationship between the change of the light spot centroid offset and the target focal length of the zoom lens considered, but also the influence of the current focal length of the zoom lens on the target focal length of the zoom lens is considered, so that the output result of the second mapping model is more accurate. During actual detection, no matter what focal length state the zoom lens is currently in, the light spot centroid offset and the second mapping model can be combined to directly give the target focal length required for clear imaging. In addition, the present application provides a dual-model combination method using the first mapping model and the second mapping model. Compared with a single model fitting, the number of model parameters to be solved in a single fitting process is smaller, which not only effectively reduces the risk of overfitting in the model fitting process and improves the generalization ability of the fitted model, but also reduces the demand for data collection in a single fitting process, which can shorten the data collection time to a certain extent and improve the efficiency of model fitting. By emitting a semi-blocked laser beam through a zoom lens to the surface of the object to be measured and obtaining a light spot image fed back from the surface, the error caused by close-range laser ranging is effectively avoided. Since the light spot image can be accurately captured by the image sensor with high resolution, it not only utilizes the image capture characteristics of the image sensor, but also achieves better results the closer the object to be measured, fully solving the detection accuracy problem of traditional laser ranging in close-range imaging. By collecting the light spot centroid offset corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model, the pre-calibrated second mapping model can be fully utilized. According to the light spot centroid offset corresponding to the zoom lens at the current focal length, the tedious steps of object distance measurement and corresponding focal length conversion are skipped, and the ideal target focal length is directly given. The influence of the light spot centroid offset on the target focal length is fully utilized, making the final result accurate and reliable. By obtaining the target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model, the first mapping model calibrated in advance in the first step is once again utilized. By simply controlling the zoom lens to reach the target voltage, clear surface information of the object to be measured can be collected.
[0017] (2) The present invention combines spot image detection and precise voltage control of the zoom lens at a macro level. Spot image detection effectively avoids the actual error problem caused by laser ranging during close-range imaging, and fully utilizes the graphic detection advantage of the image sensor, especially in close-range detection. The precise voltage control of the zoom lens eliminates the need to move the lens for focusing, and the shooting position is relatively fixed, which can better adapt to the limited detection area. At the same time, compared with the mechanical structure moving lens, voltage-controlled zoom is not only more efficient in focusing, but also avoids the accuracy impact caused by long-term mechanical control wear. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 It is a flow chart of the detection method of the present invention; Figure 2 It is a structural block diagram of the detection system in the present invention; Figure 3 It is a schematic structural diagram of the detection device in the present invention.
[0019] In the figure: 1- color separation prism; 2- laser light source; 3- first image sensor; 4- second image sensor; 5- zoom lens; 6- collimating lens; 7- imaging lens; 8- focusing lens; 9- aperture; 10- stage; 11- detection module. DETAILED DESCRIPTION
[0020] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.
[0021] like Figure 1 As shown, this embodiment first provides a focus detection method, which adjusts the focal length of the zoom lens so that the image information of the object to be measured meets the clarity requirement. Meeting the clarity requirement means that the optimal focal length state is selected at the current object distance, so that the collected image information of the object to be measured has the highest clarity and meets the Gaussian imaging formula.
[0022] In the traditional autofocus field, active focus systems based on laser ranging are limited by clock frequency when focusing at close distances, which seriously affects the autofocus accuracy and subsequent imaging detection effects during close-range detection. To solve this problem, the focus detection method provided in this application includes: A first mapping model between the real-time focal length of the zoom lens and the temperature and control voltage of the zoom lens is constructed, and the real-time focal lengths of the zoom lens at different temperatures and control voltages are collected to fit the model parameters in the first mapping model.
[0023] Zoom lenses usually use liquid lenses, which are a zoom technology based on the dynamic adjustment of optical properties of liquid materials. Its core principle is to adjust the focal length by changing the shape or refractive index of the liquid. Generally, voltage is applied between the liquid and the electrode to change the contact angle (wettability) between the liquid and the solid surface, thereby adjusting the curvature radius of the droplet to achieve focal length changes. Unlike traditional mechanical zoom lenses (which rely on physical movement of the lens), liquid lenses do not require complex mechanical structures and have the advantages of fast response, small size, and low power consumption. In addition to voltage, the temperature of the zoom lens will also cause the material to expand and contract, change the refractive index of the lens, and indirectly affect the focal length. Therefore, in order to fully consider the impact of the zoom lens temperature on the lens material, so that the focal length control of the zoom lens can achieve the ideal focal length effect through voltage adjustment at any temperature, a first mapping model between the three can be constructed in advance. The first mapping model is specifically:
[0024] Where T is the zoom lens temperature, V is the control voltage, f is the real-time focal length of the zoom lens, and α1, α2, α3, α4, α5, and α6 are fitting coefficients. By collecting several sets of statistical data on the real-time focal length f of the zoom lens at different temperatures T and control voltages V, these data are substituted into the first mapping model to analyze and derive all fitting coefficients. To ensure the reliability of the fitting coefficients, the temperature T range is chosen to cover the temperature fluctuations that the zoom lens may encounter during actual operation, and the real-time focal length f range is also chosen to cover the focal length fluctuations required during actual operation.
[0025] A semi-blocked laser beam is emitted through the zoom lens to the surface of the calibration object to obtain a spot image formed on the surface of the calibration object.
[0026] In order to avoid the influence of the laser beam on the imaging of the object to be measured during subsequent detection and reduce the interference of ambient light, the laser beam is an infrared beam. In order to characterize the near-focus or far-focus state of the object to be measured through the spot image, half of the laser beam is blocked, so that the half-blocked laser beam forms a spot image similar to a semi-ellipse after reaching the calibration object, thereby providing positive and negative values of the data, increasing the number of samples, and avoiding the same spot image corresponding to different object distances.
[0027] A second mapping model is constructed between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens. The current focal length of the zoom lens is changed, and the target focal lengths corresponding to the zoom lens under different current focal lengths and light spot centroid offsets are collected to fit the model parameters in the second mapping model.
[0028] The light spot centroid offset is the offset of the centroid position of the light spot image relative to the reference centroid position preset in advance, and the current focal length of the zoom lens is the real-time focal length. The real-time focal length can be calculated based on the first mapping model obtained by pre-fitting, the current control voltage V and the zoom lens temperature T. The target focal length is the focal length corresponding to the zoom lens when the clarity requirement is met. In order to fully consider the influence of the current focal length of the zoom lens on the target focal length, the focal length control of the zoom lens can achieve the ideal focal length effect through voltage adjustment at any current focal length, and combine the light spot centroid offset for data statistics, a second mapping model can be constructed between the light spot centroid offset, the current focal length of the zoom lens and the target focal length of the zoom lens. The second mapping model is specifically:
[0029] Among them, f0 is the current focal length of the zoom lens, ΔY is the light spot center offset, f1 is the target focal length of the zoom lens, and β1, β2, β3, β4, β5, and β6 are all fitting coefficients. By collecting the target focal length f1 corresponding to the zoom lens at different current focal lengths f0 and light spot center offsets ΔY, several sets of statistical data are obtained. Substituting them into the second mapping model, all fitting coefficients can be analyzed and obtained. To ensure the reliability of the fitting coefficients, the value range of the light spot center offset ΔY is selected to cover the light spot center offset fluctuation range that the zoom lens may face in actual operation as much as possible. The value range of the current focal length f0 also covers the focal length fluctuation range required in actual operation as much as possible.
[0030] A semi-blocked laser beam is emitted through a zoom lens to the surface of the object to be measured, and a light spot image fed back from the surface of the object to be measured is obtained to calculate the corresponding light spot centroid offset.
[0031] This is similar to the operation of transmitting a partially obstructed laser beam through the zoom lens to the surface of the calibration object. The difference is that the calibration object becomes the actual object to be measured. Based on the calculation of the center of mass offset of the light spot, combined with the first and second mapping models calibrated previously, the target voltage for controlling the zoom lens can be finally obtained, as follows: The centroid offset of the light spot corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model are collected to calculate the target focal length of the zoom lens.
[0032] The second mapping model represents the changing relationship between the target focal length f1 of the zoom lens based on the current focal length f0 of the zoom lens and the center of mass offset ΔY of the light spot. Therefore, after the second mapping model is calibrated in advance, the dependent variable f1 can be directly obtained based on the two independent variables f0 and ΔY.
[0033] The target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model are obtained to calculate a target voltage.
[0034] The second mapping model represents the changing relationship between the real-time focal length f of the zoom lens and the zoom lens temperature T and the control voltage V. Therefore, after the first mapping model is calibrated in advance, the target focal length f1 of the zoom lens and the currently measured zoom lens temperature T are substituted into the first mapping model to obtain the target voltage.
[0035] Since the real-time focal length of a zoom lens is difficult to measure directly, according to the Gaussian imaging formula 1 / f=1 / u+1 / v, where f is the real-time focal length, u is the object distance, and v is the image distance, the image is clearest when the Gaussian imaging formula is satisfied. When the image meets the clarity requirement, the real-time focal length f at this time can be obtained based on the known image distance v and the measured object distance u. Therefore, collecting the real-time focal length of a zoom lens at different temperatures and control voltages specifically includes the following steps: Adjust the zoom lens temperature and move the calibration object several times at each temperature, so that each movement corresponds to a different object distance and a known image distance. Determine the zoom lens temperature range based on the actual usage environment and sample evenly within that range. Each temperature adjustment will correspond to a different object distance, which can be converted into a different focal length using the Gaussian imaging formula.
[0036] The focus lens's control voltage is varied at different object distances to ensure the calibration object's image meets the required clarity. Once the zoom lens's temperature and current object distance are determined, the control voltage is varied to obtain the image information corresponding to the calibration object at different control voltages. The control voltage corresponding to the highest-resolution image is then calculated using the clarity calculation formula, which serves as the control voltage sampling data.
[0037] The calculation formula of clarity E is as follows:
[0038] Where I(x,y) represents the grayscale value of the pixel in the xth row and yth column, x represents the row number, and y represents the column number. is the gradient in the X direction, is the gradient in the Y direction.
[0039] Calculate the real-time focal length of the focus lens at different object distances to statistically determine the zoom lens temperature and control voltage corresponding to that real-time focal length. Since the image distance is known, once the image information of the calibration object at the current object distance meets the clarity requirements, the corresponding real-time focal length can be calculated using the Gaussian imaging formula. This allows for the generation of several sets of statistical data on the zoom lens temperature, control voltage, and real-time focal length.
[0040] The data set consisting of the zoom lens temperature T, the control voltage V, and the real-time focal length f of the zoom lens in the above-mentioned first mapping model should evenly cover the value range of the zoom lens temperature T and the control voltage V in the actual environment. In order to verify the data set, the statistical work of the above-mentioned first mapping model can be performed on the first calibration object and the second calibration object respectively. The number of data sets corresponding to the first calibration object and the second calibration object is 8:2, and they are respectively used as the training set and the test set. The mean square error of the training set and the test set is calculated respectively, and the judgment is as follows: If the mean square error of the training set is much smaller than the mean square error of the test set, that is, the difference is less than the first preset threshold, it means that the model is overfitting and the model can be simplified, for example, by reducing the polynomial order; If the mean square errors of the training set and the test set are both high, that is, both are greater than the second preset threshold, it means that the model complexity is insufficient and the polynomial order can be increased.
[0041] Because different target focal lengths are obtained when the zoom lens is at different current focal lengths even if the light spot centroid offset is the same, it is necessary to comprehensively consider the impact of the current focal length of the zoom lens. As a specific embodiment of the present invention, collecting the target focal lengths corresponding to the zoom lens at different current focal lengths and light spot centroid offsets specifically includes the following steps: Adjust the zoom lens control voltage to change the current focal length of the zoom lens. At this point, the first mapping model has been calibrated. By adjusting the control voltage within the specified voltage control range, the current zoom lens can be adjusted to different focal length states, thereby obtaining different current focal lengths f0 of the zoom lens.
[0042] The calibration object is moved and the spot images fed back from different locations are collected to calculate the corresponding spot centroid offset. After adjusting and confirming the current focal length f0 of the zoom lens, moving the calibration object causes the spot image to appear in different states, such as near focus, in focus, and far focus. After collecting the spot images in all states, the difference between the spot centroid position and the reference centroid position is calculated to obtain different spot centroid offsets ΔY.
[0043] Change the zoom lens focal length so that the calibration object image information at the current position meets the clarity requirement, and use the zoom lens focal length at this time as the target focal length. By changing the zoom lens focal length, you can obtain calibration object image information of different clarity. Select the zoom lens focal length corresponding to the calibration object image information with the highest clarity as the target focal length f1.
[0044] In traditional laser ranging combined with zoom lens control technology, the basic principle is to first measure the object distance, then convert it into the corresponding focal length, and finally adjust it according to the relationship between focal length and voltage. In contrast, the analysis process of the target focal length f1 directly skips the tedious steps of object distance measurement and corresponding focal length conversion. The final target focal length can be obtained directly through the fitting relationship between the light spot centroid offset and the corresponding second mapping model, avoiding the error defects caused by the principle of laser ranging and effectively improving the focusing accuracy.
[0045] The calculation process of the spot centroid offset requires analysis of the grayscale values of different pixel positions in the spot image. In order to further improve the analysis efficiency, synchronous calculation is performed while the image data is cached and read line by line, which can effectively save analysis time. The calculation method of the spot centroid offset specifically includes the following steps: The spot image feedback from the calibration object or the object to be tested is collected to calculate the average value of each row of the spot image data, where each row of data is distributed along the long axis of the spot image. The spot image is usually presented in a horizontally distributed semi-elliptical state. If a semi-ellipse is formed upward, it can indicate close focus, that is, the object is closer to the lens than the focus position. If a semi-ellipse is formed upward, it can indicate far focus, that is, the object is farther from the lens than the focus position. If it is close to a straight line, it indicates a focused state. Since data storage and reading are usually performed in row order, by calculating the average value of each row of the spot image data, data cache reading and calculation analysis can be performed simultaneously, effectively shortening the data analysis time of the spot image.
[0046] The calculation formula for the average value of each row of data in the spot image is as follows:
[0047] Among them, I(x,y) represents the grayscale value of the pixel in the xth row and yth column, N represents the number of columns, μ x Represents the average value of the xth row of data in the spot image.
[0048] The average value of each row of data in the spot image is obtained, and weighted average is performed based on the position of the corresponding row of data to obtain the centroid position of the spot.
[0049] The specific calculation formula for the weighted average of the spot centroid position is as follows:
[0050] Among them, C y Indicates the centroid position of the light spot, and M indicates the number of rows.
[0051] The center of mass of the light spot and the reference center of mass are collected, and the difference is calculated to obtain the center of mass offset of the light spot. The reference center of mass position can be set in advance. Usually, the intersection of the long axis and the short axis of the light spot can be used as the reference center of mass position. It can also be fine-tuned according to actual conditions. The specific calculation method is as follows:
[0052] Among them, C0 is the reference center of mass position.
[0053] According to the principle, the first mapping model and the second mapping model are calibrated in advance. During the actual detection, the only thing measured is the center of mass offset of the light spot. Therefore, to ensure the focusing accuracy, it is necessary to ensure the reliability of the center of mass offset of the light spot. To ensure the reliability, the following steps can be used: The image of the spot is collected from the calibration object or the object under test and then subjected to median filtering and Gaussian filtering to complete the spot image preprocessing. The median filter first removes salt and pepper noise to prevent the weighted averaging process of the Gaussian filter from spreading salt and pepper noise to surrounding pixels. The Gaussian filter then smooths the remaining Gaussian noise to further optimize image quality.
[0054] Calculate the gradient size and direction of each pixel position in the spot image, and use the gradient method to calculate the edge coordinates of the spot image. The edge is the area where the gray value changes suddenly, and the edge position is where the gradient amplitude is the largest. The gradient method can be specifically calculated by convolution using the Sobel operator: For example, the convolution kernel in the X direction is , the convolution kernel in the Y direction is ; The image data are respectively x and G y Convolution, get the horizontal gradient G x (x,y) and vertical gradient G y (x,y); Gradient amplitude ; Gradient direction .
[0055] The edge coordinates of the spot image are extracted to calculate the geometric centroid position of the spot image, and then the geometric offset of the spot centroid is calculated according to the reference centroid position.
[0056] First, the edge coordinate set P is obtained by extracting the edge coordinates of the spot image as follows:
[0057] Among them, n is the number of coordinates in the edge coordinate set P, and then the geometric center position (x c ,y c ), x c and y c The calculation formula is as follows:
[0058] Among them, x k is the kth horizontal coordinate in the edge coordinate set P, y kis the kth ordinate in the edge coordinate set P.
[0059] The geometric offset of the spot centroid is recorded as ΔY', and the calculation formula is as follows:
[0060] Determine whether the difference between the spot centroid geometric offset and the spot centroid offset is less than a preset threshold. If so, retain the corresponding spot centroid offset; otherwise, discard the corresponding spot centroid offset. By determining whether the difference between the spot centroid geometric offset and the spot centroid offset is less than a preset threshold, the impact of error data on the focusing result can be effectively reduced, significantly improving the reliability of the spot centroid offset.
[0061] Since the calculation result of the spot centroid geometric offset will affect the selection of the spot centroid offset, in order to further improve the accuracy of the spot centroid geometric offset, the following steps are also included before extracting the edge coordinates of the spot image: Collect any edge coordinates and extract pixel coordinates and grayscale values within a preset range centered on that edge coordinate. For each edge coordinate point, you can take its neighborhood, such as a 3×3 window, to perform sub-pixel refinement on the edge coordinates.
[0062] The grayscale centroid within the range is calculated to obtain the corrected edge coordinates. The corrected edge coordinates can be obtained based on the calculation method of the grayscale centroid.
[0063] In the actual measurement process, due to the surface texture of the object to be measured, some morphology of the spot image will be missing. Therefore, in order to ensure the reliability of the spot centroid offset, before extracting the edge coordinates of the spot image, it also includes: constructing a semi-ellipse equation and using the edge coordinates to complete the fitting of the semi-ellipse equation to fill the missing edge points through linear interpolation.
[0064] By fitting the semi-ellipse equation, the influence of the surface texture of the object to be measured on the spot image can be avoided, the problem of missing spot image can be improved to a certain extent, and the measurement accuracy and reliability of the spot centroid offset can be significantly improved.
[0065] like Figure 2 As shown, the second aspect of the present invention further provides a focus detection system, comprising: The first fitting module is used to construct a first mapping model between the real-time focal length of the zoom lens and the temperature and control voltage of the zoom lens, collect the real-time focal length of the zoom lens under different temperatures and control voltages, and fit the model parameters in the first mapping model.
[0066] The first laser control module is used to emit a semi-blocked laser beam through the zoom lens to the surface of the calibration object to obtain a light spot image formed on the surface of the calibration object.
[0067] The second fitting module is used to construct a second mapping model between the target focal length of the zoom lens and the light spot center offset and the current focal length of the zoom lens, change the current focal length of the zoom lens, and collect the target focal lengths corresponding to the zoom lens under different current focal lengths and light spot center offsets to fit the model parameters in the second mapping model.
[0068] The second laser control module is used to emit a semi-blocked laser beam through the zoom lens to the surface of the object to be measured, and obtain the light spot image fed back from the surface of the object to be measured to calculate the corresponding light spot centroid offset.
[0069] The target focal length analysis module is used to collect the light spot centroid offset corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model to calculate the target focal length of the zoom lens.
[0070] The target voltage analysis module is used to obtain the target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model to calculate the target voltage.
[0071] In order to implement the above detection method, according to the principle, it is necessary to have a laser emission optical path, a spot image collection optical path, and a surface collection optical path for the object to be detected. In order to further simplify the structure and improve its integration effect, so as to adapt to the limited detection area and reduce the manufacturing cost, the specific Figure 3 As shown, the third aspect of the present invention further provides a focus detection device, comprising: The laser light source 2 is used to emit a laser beam, which passes through the collimating lens 6 and the aperture 9 in sequence to form a semi-blocked collimated beam. At this time, the laser light source 2 can select an infrared light source to reduce environmental interference. The light beam emitted by the laser light source 2 usually has a divergence angle, and the collimating lens 6 converts it into a parallel beam. The function of the aperture 9 is to limit half of the light beam from passing through.
[0072] The zoom lens 5 is used to project the semi-blocked collimated light beam onto the surface of the object to be measured to form a light spot, and receive image information fed back by the object to be measured; the zoom lens 5 is usually a liquid lens, so that it can be precisely controlled by voltage.
[0073] The first image sensor 3 is used to collect the light spot image fed back by the object to be measured; a focus lens 8 may be further provided in front of the photosensitive surface of the first image sensor 3 to achieve clear collection of the light spot image.
[0074] The second image sensor 4 is used to collect image information of the surface of the object to be measured. An imaging lens 7 may be provided before the photosensitive surface of the second image sensor 4 to achieve clear collection of the image of the surface of the object to be measured.
[0075] The dichroic prism 1 is used to transmit the collimated light beam from the laser light source 2 to the zoom lens 5, and transmit the light spot image and surface image information fed back by the object to be measured to the first image sensor 3 and the second image sensor 4 respectively; the dichroic prism 1 can be used to limit the light beam from the laser light source 2 from being directly projected onto the first image sensor 3, and can also be reflected to the zoom lens 5, thereby reducing interference.
[0076] The detection module 11 is connected to the first image sensor 3 and is used to execute the above detection method.
[0077] In actual use, the laser beam emitted by the laser light source 2 is converted by the collimating lens 6 and limited by the aperture 9 to form a semi-blocked collimated beam, which is reflected by the dichroic prism 1 and passes through the zoom lens 5 to reach the surface of the calibration object or the object to be measured on the stage 10. The formed spot image is reflected by the dichroic prism 1 and passes through the focusing lens 8 to reach the first image sensor 3, so as to detect the centroid offset of the spot. After the focusing of the zoom lens is completed, the diffusely reflected light of the image information on the surface of the object to be measured passes through the dichroic prism 1 and the imaging lens 7 to reach the second image sensor 4, completing the clear image acquisition.
[0078] A fourth aspect of the present invention further provides a computer-readable storage medium comprising a computer program, which implements the above-mentioned detection method when executed by a processor.
[0079] In practical applications, computer-readable storage media may take the form of any combination of one or more computer-readable media. Computer-readable media may be computer-readable signal media or computer-readable storage media. Computer-readable storage media may be, but are not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination thereof. More specific examples of computer-readable storage media may include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component.
[0080] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0081] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0082] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0083] Throughout this specification, references to terms such as "one embodiment," "example," and "specific example" indicate that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of the present invention. In this specification, schematic representations of these terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0084] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention, and such changes and modifications fall within the scope of the invention as claimed.
Claims
1. A focus detection method, which adjusts the focal length of a zoom lens so that the image information of the object to be measured meets the clarity requirement, characterized in that: Detection methods include: Constructing a first mapping model between the real-time focal length of the zoom lens and the temperature and control voltage of the zoom lens, collecting the real-time focal length of the zoom lens at different temperatures and control voltages, and fitting to obtain model parameters in the first mapping model; The semi-blocked laser beam is emitted through the zoom lens to the surface of the calibration object to obtain a spot image formed on the surface of the calibration object; Constructing a second mapping model between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens, changing the current focal length of the zoom lens, and collecting the target focal lengths corresponding to the zoom lens at different current focal lengths and light spot centroid offsets to obtain the model parameters in the second mapping model through fitting; A semi-blocked laser beam is emitted through a zoom lens to the surface of the object to be measured, and a light spot image fed back from the surface of the object to be measured is obtained to calculate the corresponding light spot centroid offset; Collect the center of mass offset of the light spot corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model to calculate the target focal length of the zoom lens; The target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model are obtained to calculate a target voltage.
2. A focus detection method according to claim 1, characterized in that: The real-time focal length of the zoom lens at different temperatures and control voltages includes: Adjust the zoom lens temperature and move the calibration object several times at each temperature so that each movement of the calibration object corresponds to a different object distance and the corresponding image distance is known; Change the control voltage of the focus lens at different object distances so that the image information of the calibration object meets the clarity requirements; The real-time focal length of the focus lens at different object distances is calculated to obtain the zoom lens temperature and control voltage corresponding to the real-time focal length.
3. A focus detection method according to claim 1, characterized in that: The target focal lengths corresponding to different current focal lengths and spot centroid offsets of the acquisition zoom lens include: Adjust the zoom lens control voltage to make the current focal length of the zoom lens different; Move the calibration object and collect the spot images fed back by the calibration object at different positions to calculate the corresponding spot centroid offset; The focal length of the zoom lens is changed so that the image information of the calibration object at the current position meets the clarity requirement, and the focal length of the zoom lens at this time is used as the target focal length.
4. A focus detection method according to claim 3, characterized in that: The calculation methods of the spot centroid offset include: Collect the spot image fed back by the calibration object or the object to be measured to calculate the average value of each row of data in the spot image, where each row of data is distributed along the long axis of the spot image; Obtain the average value of each row of data in the spot image, and perform weighted averaging based on the position of the corresponding row of data to obtain the centroid position of the spot; The spot centroid position and the reference centroid position are collected, and the difference is calculated to obtain the spot centroid offset.
5. A focus detection method according to claim 4, characterized in that: Also includes: Collect the spot image fed back by the calibration object or the object to be measured, and perform median filtering and Gaussian filtering in succession to complete the spot image preprocessing; Calculate the gradient size and direction of each pixel position in the spot image, and use the gradient method to calculate the edge coordinates of the spot image; Extract the edge coordinates of the spot image to calculate the geometric centroid position of the spot image, and then calculate the geometric offset of the spot centroid according to the reference centroid position; It is determined whether the difference between the spot centroid geometric offset and the spot centroid offset is less than a preset threshold. If so, the corresponding spot centroid offset is retained; if not, the corresponding spot centroid offset is discarded.
6. A focus detection method according to claim 5, characterized in that: Before extracting the edge coordinates of the spot image, it also includes: Collect any edge coordinates, and extract pixel coordinates and grayscale values within a preset range with the edge coordinates as the center; The grayscale centroid within the range is calculated to obtain the corrected edge coordinates.
7. A focus detection method according to claim 5, characterized in that: Before extracting the edge coordinates of the spot image, the method also includes: constructing a semi-ellipse equation, and using the edge coordinates to complete the fitting of the semi-ellipse equation to fill in the missing edge points through linear interpolation.
8. A focus detection system, characterized in that: include: A first fitting module is used to construct a first mapping model between the real-time focal length of the zoom lens and the temperature and control voltage of the zoom lens, collect the real-time focal length of the zoom lens under different temperatures and control voltages, and fit the model parameters in the first mapping model; A first laser control module is used to emit a semi-blocked laser beam through a zoom lens to the surface of the calibration object to obtain a spot image formed on the surface of the calibration object; A second fitting module is used to construct a second mapping model between the target focal length of the zoom lens and the light spot centroid offset and the current focal length of the zoom lens, change the current focal length of the zoom lens, and collect the target focal lengths corresponding to the zoom lens under different current focal lengths and light spot centroid offsets to fit the model parameters in the second mapping model; The second laser control module is used to emit a semi-blocked laser beam through the zoom lens to the surface of the object to be measured, and obtain the light spot image fed back from the surface of the object to be measured to calculate the corresponding light spot centroid offset; The target focal length analysis module is used to collect the centroid offset of the light spot corresponding to the object to be measured, the current focal length of the zoom lens, and the second mapping model to calculate the target focal length of the zoom lens; The target voltage analysis module is used to obtain the target focal length of the zoom lens, the current temperature of the zoom lens, and the first mapping model to calculate the target voltage.
9. A focus detection device, characterized in that: include: A laser light source is used to emit a laser beam, which passes through a collimating lens and an aperture in sequence to form a semi-blocked collimated beam; The zoom lens is used to project a semi-blocked collimated light beam onto the surface of the object to be measured to form a light spot and receive image information fed back by the object to be measured; The first image sensor is used to collect the light spot image fed back by the object to be measured; The second image sensor is used to collect image information of the surface of the object to be measured; a dichroic prism, configured to transmit the collimated light beam from the laser light source to the zoom lens, and transmit the light spot image and the surface image information of the object to be measured to the first image sensor and the second image sensor respectively; A detection module is connected to the first image sensor and is used to execute the detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium comprising a computer program, characterized in that When the computer program is executed by a processor, the detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
High-precision image processing device, method and system
CN121013010A
Lens astigmatism measuring method and device based on liquid lens and umbrella-shaped target
CN121577296A