A focus adjustment method, system and related apparatus
By using a focus adjustment method, multiple sample screen images are captured by a camera to locate the real focus reference position and construct a relationship model. The camera object distance is dynamically adjusted, which solves the moiré interference problem and improves the accuracy of Demura correction and the quality of display products.
Patent Information
- Application Number
- CN202610733758.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-26
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2046-05-26
AI Technical Summary
In existing technologies, moiré interference generated when a camera captures images of a display screen leads to a decrease in the accuracy of Demura correction, affecting the accuracy of screen brightness and color information, and thus reducing the quality of display products.
By using a focus adjustment method, multiple sample images of the sample screen are acquired by the camera under different step sizes. The real focus reference position is located, a relationship model is constructed, the rate of change of focus value is analyzed, and the camera object distance is dynamically adjusted to avoid moiré interference and ensure the stability of image acquisition.
It improves the accuracy of Demura calibration, ensuring the quality of display products. Through sample calibration and defocus modeling, it achieves the accuracy and stability of focus adjustment and avoids the interference of moiré patterns.
Smart Images

Figure CN122293993B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of display technology, and in particular to a method, system and related apparatus for focusing adjustment. Background Technology
[0002] With the rapid iteration of display technology, OLED, MicroLED, and other display solutions have been widely applied to small display panels in various smart terminals such as smartphones, tablets, and high-end TVs, driving display products towards higher resolution, better color performance, and higher peak brightness. These high-end display products place stringent requirements on color accuracy, peak brightness, and image uniformity, and ideal display effects rely on the stable light emission performance of each pixel. Against this backdrop, Demura calibration (brightness and color uniformity calibration) has become a key technology in the manufacturing process of high-end display panels. It effectively corrects defects such as brightness and color uniformity through precise calibration of the screen's light emission characteristics, directly determining the quality of display products and the user's visual experience.
[0003] In existing technologies, Demura correction is typically achieved using a combination of camera acquisition and compensation algorithms. Specifically, a high-precision camera first acquires images of the display screen to obtain the original brightness and color information of each area. Then, based on the acquired image data, the differences in luminous characteristics of each area are quantified to construct a detailed brightness and color distribution map. Next, a compensation algorithm is used to specifically calibrate the luminous parameters of each pixel based on the differences in the distribution map, thereby optimizing the uniformity of brightness and color across the entire screen and completing the Demura correction process.
[0004] However, this method of directly capturing screen images with a camera is susceptible to moiré interference, severely impacting the accuracy of Demura correction. When a camera captures an image of a display screen, the pixel arrangement period of the camera's sensor and the pixel arrangement period of the screen create high-frequency interference, generating low-frequency interference fringes, i.e., moiré patterns. These moiré patterns significantly interfere with the extraction of the screen's true brightness and color information, leading to distortion of the raw data. This distorted data directly affects the accuracy of the brightness and color distribution maps, causing subsequent compensation algorithms to deviate from their calculations. Not only does this fail to achieve the desired correction effect, but it can even exacerbate screen display abnormalities and reduce product quality. Summary of the Invention
[0005] To address the aforementioned technical problems, this application provides a focus adjustment method, system, and related apparatus.
[0006] The technical solution provided in this application is described below:
[0007] A first aspect of this application provides a focus adjustment method, the method comprising: Multiple sample images of the sample screen are captured using a camera at different step sizes, and a preset focusing algorithm is used to locate the real focus reference position of the sample screen based on the sample images. Starting from the real focus reference position, the camera is used to acquire out-of-focus images of the sample screen at multiple out-of-focus object distances along the out-of-focus direction according to a preset step path, and the focus value of each out-of-focus image is calculated. A relationship model is constructed based on the focal value and the corresponding virtual focal distance; The rate of change of the focus value is analyzed using the relationship model, and the range of the target out-of-focus position on the sample screen is determined by combining the preset change threshold. The camera is used to acquire the current image of the screen under test within the range of the target out-of-focus position, and the current focus value is calculated; The current focus value is input into the relational model, and the theoretical object distance of the current focus value is calculated through the relational model; The actual object distance to the screen under test captured by the camera is obtained, and it is determined whether the difference between the theoretical object distance and the actual object distance exceeds a preset object distance change threshold. If so, the camera is dynamically moved to adjust the actual object distance until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold, thus completing the focus adjustment.
[0008] Optionally, the preset focusing algorithm includes a coarse positioning algorithm and a fine positioning algorithm; The step of acquiring multiple sample images of the sample screen at different step sizes using a camera, and locating the real focus reference position of the sample screen based on the sample images using a preset focusing algorithm, includes: The camera captures multiple sample images of the sample screen under a preset first step path, and the coarse positioning position is determined based on the sample images under the preset first step path using the coarse positioning algorithm. The fine positioning range is determined based on the coarse positioning position and the preset first step path; Within the precise positioning range, the camera is used to acquire multiple sample images of the sample screen under a preset second step path, and the precise positioning position is determined based on the sample images under the preset second step path using the precise positioning algorithm. The precise positioning position is the real focus reference position of the sample screen, wherein the preset second step path is smaller than the preset first step path.
[0009] Optionally, the step of using a camera to acquire multiple sample images of the sample screen under a preset first step path, and determining the coarse positioning position based on the sample images under the preset first step path using the coarse positioning algorithm, includes: The camera is moved along a preset first step path, and a first sample image of the sample screen is acquired for each preset first step path, and the focus value of the first sample image is calculated. The focus values of the first sample images are sorted from largest to smallest, and the coarse positioning position of the focus value of the first sorted first sample image is determined by the coarse positioning algorithm. Within the precise positioning range, the camera acquires multiple sample images of the sample screen under a preset second step path, and the precise positioning position is determined based on the sample images under the preset second step path using the precise positioning algorithm, including: Within the precise positioning range, the camera is moved along a preset second step path. For each preset second step path, a second sample image of the sample screen is acquired, and the focus value of the second sample image is calculated. The focus values of the second sample images are sorted from largest to smallest, and the fine positioning position of the focus value of the first second sample image after sorting is determined by the fine positioning algorithm.
[0010] Optionally, the focus value is calculated using the following formula: ; Among them, the The focus value, For brightness function, For contrast function, For structure functions; The brightness function is expressed by the following formula: ; The contrast function is expressed by the following formula: ; The structure function is defined by the following formula: ; in, Images captured using the camera, After mean filtering , for The mean, for The mean, for standard deviation for standard deviation , as well as It is a constant, and , , This is the depth parameter.
[0011] Optionally, the step of analyzing the rate of change of the focus value through the relationship model and determining the target out-of-focus position range of the sample screen in combination with a preset change threshold includes: The rate of change between the focus value at the real focus reference position and the focus value corresponding to each of the out-of-focus images is calculated using the relationship model. The absolute value of the difference between adjacent rates of change is determined sequentially to be less than a preset threshold. If not, then the out-of-focus position of the out-of-focus image corresponding to the previous change rate among the adjacent change rates is taken as the target out-of-focus position, and the interval from the real focus reference position to the target out-of-focus position is taken as the target out-of-focus position range.
[0012] Optionally, the relational model is expressed as follows: ; in, The focus value, For the preset step path, The real focal reference position is... This refers to the relationship between the focal value and the corresponding virtual focal distance. The order of the polynomial fit for constructing the relational model.
[0013] Optionally, before acquiring multiple sample images of the sample screen at different step sizes using the camera, the focus adjustment method further includes: Acquire flat-field images captured by the camera under a uniformly illuminated standard white board environment and dark-field images captured with the shutter closed; Flat field correction is performed on all images acquired using the camera based on the flat field image and the dark field image.
[0014] Optionally, the theoretical object distance is calculated using the following formula: ; in, The focus value, The theoretical object distance is... To construct the order of the polynomial fit for the relational model, These are the polynomial fitting coefficients used to construct the relational model.
[0015] A second aspect of this application provides a focus adjustment system, the system comprising: The positioning unit is used to acquire multiple sample images of the sample screen under different step sizes using a camera, and to locate the real focus reference position of the sample screen based on the sample images using a preset focusing algorithm. The first calculation unit is used to acquire, with the real focus reference position as the starting point, the camera along the defocus direction according to a preset step path to acquire defocus images of the sample screen at multiple defocus object distances, and calculate the focus value of each defocus image; The construction unit is used to construct a relationship model based on the focus value and the corresponding virtual focus distance; The determining unit is used to analyze the rate of change of the focus value through the relationship model and determine the range of the target defocus position of the sample screen in combination with a preset change threshold. The second calculation unit is used to acquire the current image of the screen under test using the camera within the target defocus position range, and to calculate the current focus value; The third calculation unit is used to input the current focus value into the relation model and calculate the theoretical object distance of the current focus value through the relation model; The judgment unit is used to obtain the actual object distance of the camera to the screen under test, and to determine whether the difference between the theoretical object distance and the actual object distance exceeds the preset object distance change threshold. The adjustment unit is used to dynamically move the camera to adjust the actual object distance if the actual object distance is adjusted until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold, thus completing the focus adjustment.
[0016] Optionally, the preset focusing algorithm includes a coarse positioning algorithm and a fine positioning algorithm; The step of acquiring multiple sample images of the sample screen at different step sizes using a camera, and locating the real focus reference position of the sample screen based on the sample images using a preset focusing algorithm, includes: The camera captures multiple sample images of the sample screen under a preset first step path, and the coarse positioning position is determined based on the sample images under the preset first step path using the coarse positioning algorithm. The fine positioning range is determined based on the coarse positioning position and the preset first step path; Within the precise positioning range, the camera is used to acquire multiple sample images of the sample screen under a preset second step path, and the precise positioning position is determined based on the sample images under the preset second step path using the precise positioning algorithm. The precise positioning position is the real focus reference position of the sample screen, wherein the preset second step path is smaller than the preset first step path.
[0017] Optionally, the positioning unit is specifically used for: The camera is moved along a preset first step path, and a first sample image of the sample screen is acquired for each preset first step path, and the focus value of the first sample image is calculated. The focus values of the first sample images are sorted from largest to smallest, and the coarse positioning position of the focus value of the first sorted first sample image is determined by the coarse positioning algorithm. Within the precise positioning range, the camera acquires multiple sample images of the sample screen under a preset second step path, and the precise positioning position is determined based on the sample images under the preset second step path using the precise positioning algorithm, including: Within the precise positioning range, the camera is moved along a preset second step path. For each preset second step path, a second sample image of the sample screen is acquired, and the focus value of the second sample image is calculated. The focus values of the second sample images are sorted from largest to smallest, and the fine positioning position of the focus value of the first second sample image after sorting is determined by the fine positioning algorithm.
[0018] Optionally, the focus value is calculated using the following formula: ; Among them, the The focus value, For brightness function, For contrast function, For structure functions; The brightness function is expressed by the following formula: ; The contrast function is expressed by the following formula: ; The structure function is defined by the following formula: ; in, Images captured using the camera, After mean filtering , for The mean, for The mean, for standard deviation for standard deviation , as well as It is a constant, and , , This is the depth parameter.
[0019] Optionally, the determining unit is specifically used for: The rate of change between the focus value at the real focus reference position and the focus value corresponding to each of the out-of-focus images is calculated using the relationship model. The absolute value of the difference between adjacent rates of change is determined sequentially to be less than a preset threshold. If not, then the out-of-focus position of the out-of-focus image corresponding to the previous change rate among the adjacent change rates is taken as the target out-of-focus position, and the interval from the real focus reference position to the target out-of-focus position is taken as the target out-of-focus position range.
[0020] Optionally, the relational model is expressed as follows: ; in, The focus value, For the preset step path, The real focal reference position is... This refers to the relationship between the focal value and the corresponding virtual focal distance. The order of the polynomial fit for constructing the relational model.
[0021] Optionally, it also includes a processing unit, specifically used for: Acquire flat-field images captured by the camera under a uniformly illuminated standard white board environment and dark-field images captured with the shutter closed; Flat field correction is performed on all images acquired using the camera based on the flat field image and the dark field image.
[0022] Optionally, the theoretical object distance is calculated using the following formula: ; in, The focus value, The theoretical object distance is... To construct the order of the polynomial fit for the relational model, These are the polynomial fitting coefficients used to construct the relational model.
[0023] A third aspect of this application provides a computer-readable storage medium storing a program that, when executed on a computer, performs the first aspect and any optional focus adjustment method of the first aspect.
[0024] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: This application solves the moiré pattern problem caused by camera-captured screens through sample calibration, defocus modeling, and dynamic calibration of focus adjustment, ensuring the authenticity of image data required for Demura correction and thus improving the accuracy of Demura correction and the quality of display products. In practical applications, multiple sample images of the sample screen are first acquired using a camera at different step distances. A preset focusing algorithm is used to locate the real focus reference position of the sample screen based on the sample images, providing a reference basis for subsequent defocus adjustment. Then, starting from the real focus reference position, defocus images of the sample screen are acquired along the defocus direction at multiple defocus object distances according to the preset step distance, and the focus value of each defocus image is calculated. After obtaining the focus value and the corresponding defocus object distance, a relationship model is constructed based on the two to achieve a precise correlation between the focus value and the object distance. Next, the rate of change of the focus value is analyzed through the relationship model, and the target defocus of the sample screen is determined by combining it with a preset change threshold. The system precisely avoids the focus range where camera and screen pixel periodic interference causes moiré patterns. Then, within the target out-of-focus area, the camera captures the current image of the screen under test, calculates the current focus value, and inputs it into a relational model to obtain the corresponding theoretical object distance. Next, the actual object distance captured by the camera is obtained, and it is determined whether the difference between the theoretical and actual object distances exceeds a preset object distance change threshold. When the difference exceeds the threshold, the camera is dynamically moved to adjust the actual object distance until the difference between the adjusted actual and theoretical object distances falls within the preset object distance change threshold, thus completing the focus adjustment and ensuring that the captured image is free of moiré interference, guaranteeing the stability of the acquisition. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A schematic flowchart of an embodiment of the focus adjustment method provided in this application; Figure 2 A schematic flowchart of another embodiment of the focus adjustment method provided in this application; Figure 3 This is a schematic diagram of an embodiment of the focus adjustment system provided in this application. Detailed Implementation
[0027] This application provides a focus adjustment method that can suppress moiré pattern interference. It should be noted that the focus adjustment method of this application is applied to a terminal device.
[0028] It should be noted that the focus adjustment method, apparatus, and related devices provided in this application can be applied to terminals, systems, and servers. For example, a terminal can be a smartphone, computer, tablet, smart TV, smartwatch, portable computer, or a desktop computer, etc. For ease of explanation, this application uses a terminal as the implementing entity for illustrative purposes.
[0029] Please see Figure 1 This application first provides an embodiment of a focus adjustment method, which includes: S101. Use a camera to acquire multiple sample images of the sample screen under different step sizes, and use a preset focusing algorithm to locate the real focus reference position of the sample screen based on the sample images. In this embodiment, the true focus reference position of the sample screen is located through multi-step sample acquisition and analysis using a preset focusing algorithm, establishing reference coordinates for subsequent focus adjustment. Locating the true focus reference position of the sample screen is crucial because image clarity is highest in true focus mode. By comparing multi-step sampling with algorithmic quantization, the true focus position can be accurately locked, avoiding reference deviations caused by sampling from a single location.
[0030] Specifically, first, a sample screen with specifications identical to the screen under test is selected. The camera is fixed on an adjustable z-axis motion mechanism, ensuring the camera lens is directly facing the center of the sample screen. Then, multiple different shooting steps are set, representing different object distances between the camera and the sample screen, for example, from 20cm to 50cm, with each step lasting 5cm. The camera is controlled to acquire at least one sample image at each step, ensuring the sample image covers the entire display area of the sample screen. After acquisition, a preset focusing algorithm is called to select the sample image, and the shooting position corresponding to the selected sample image is used as the focal length reference position.
[0031] S102. Starting from the real focus reference position, use the camera to collect the defocused images of the sample screen at multiple defocused object distances along the defocused direction according to the preset step path, and calculate the focus value of each defocused image. In this embodiment, the camera on the z-axis motion mechanism starts from the real-focus reference position and moves gradually along the defocus direction. It pauses and acquires a defocus image after each preset step, simultaneously recording the current defocus distance between the camera and the screen. The defocus direction is the direction away from the sample screen. In practical applications, the preset step size is relatively small, for example, 0.1 mm, to ensure data accuracy; the specific value is determined according to actual needs. As the image transitions from real focus to defocus, the image sharpness gradually decreases, and the focus value decreases accordingly. Sampling with small directional steps can capture this change. After acquisition, the focus value is calculated for each defocus image. The focus value quantifies image sharpness by statistically analyzing the degree of change in image pixel grayscale; the higher the value, the closer it is to real focus.
[0032] It should be noted that, in order to avoid the influence of individual differences on a single screen, it is necessary to collect out-of-focus images from at least 10 sample screens of the same model.
[0033] S103. Construct a relationship model based on the focus value and the corresponding virtual focus distance; In this embodiment, the relationship model is constructed by utilizing the strong fitting ability of the least squares method for nonlinear data, which transforms the stable change of the focus value and the virtual focus distance into a calculable mathematical relationship, thereby achieving a precise mapping between the two.
[0034] Specifically, the calculated focus values and their corresponding defocus distances are first preprocessed. This preprocessing includes removing aberrations such as sudden changes in focus values caused by camera shake. Then, the preprocessed defocus distances are used as independent variables and the focus values as dependent variables, resulting in a one-to-one dataset. Since the defocus distance and focus value have a non-linear relationship—the peak focus value at the point of focus gradually decreases towards the defocused area—a polynomial function is used to fit the dataset to a polynomial. The coefficients of this polynomial are then solved using the least squares method, and cross-validation is used to determine the optimal polynomial coefficients to construct the relationship model.
[0035] Furthermore, the choice of the order of the polynomial function needs to be considered in conjunction with the fitting accuracy and model stability. Too low an order will lead to excessive fitting deviation, while too high an order will result in overfitting. In this embodiment, a polynomial function of order 3-5 can be selected, depending on the actual needs.
[0036] S104. Analyze the rate of change of the focus value through a relational model, and determine the range of the target defocus position on the sample screen by combining the preset change threshold. Since the generation of moiré patterns is closely related to the relative position of the camera and screen pixel periods, and the rate of change of focus value can indirectly reflect this relative interference state, combining the rate of change with threshold screening can accurately isolate the interference range that is prone to generating moiré patterns.
[0037] Specifically, after constructing the relational model, the rate of change of the focus value with the object distance is calculated using the relational model. Then, all calculated rates of change are iterated through, and a preset change threshold is set to determine the range of the target out-of-focus position on the sample screen. This ensures that all images captured within this range corresponding to out-of-focus object distances are free of obvious moiré patterns.
[0038] Furthermore, the preset change threshold can be set to 400 in practical applications, depending on the severity of moiré patterns and the differences between different screens; no specific limit is set here.
[0039] S105. Use a camera to capture the current image of the screen under test within the target out-of-focus area and calculate the current focus value; Within the calibrated target defocus range, the camera on the z-axis motion mechanism is moved to the default initial position within the target defocus range. The same exposure time and screen brightness parameters as during sample image acquisition are fixed to control the camera to acquire the current image of the screen under test, ensuring that the current image covers the entire display area of the screen. Simultaneously, the current focus value of the current image is calculated.
[0040] This acquisition method is used because the target defocus position range has been verified to suppress moiré patterns. Acquiring the current image within this target defocus position range can ensure the quality of the current image. The unified acquisition parameters and focus value calculation standard avoid data distortion caused by changes in environmental and equipment parameters.
[0041] S106. Input the current focus value into the relational model, and calculate the theoretical object distance of the current focus value through the relational model; In this embodiment, the relational model has established a precise nonlinear mapping between the focus value and the object distance. Through this relational model, the current focus value can be reversed to derive the corresponding theoretical object distance.
[0042] Specifically, the current focus value is used as an input parameter and input into the relational model. Since the relational model is a high-order nonlinear equation, the Newton-Raphson iteration method can be used to solve the theoretical object distance in this embodiment. The optimal virtual focus position within the range of the target virtual focus position is used as the initial iteration value, and the calculation is performed iteratively step by step. During the iteration process, the difference between two iteration results is continuously calculated until the difference is less than the accuracy threshold. The iteration stops then, and the final result is determined as the theoretical object distance corresponding to the current focus value. This accuracy threshold can be 10^-3 mm. For example, with an accuracy threshold of 10^-3 mm and a current focus value of 82, 82 is input into the relational model. Using the midpoint of the target's defocused position range (26 mm) as the initial iteration value, the first iteration yields a theoretical object distance of 26.12 mm, and the second iteration yields 26.123 mm. The difference between the two iterations is 0.003 mm, which is greater than 10^-3 mm, so iteration continues. The third iteration yields 26.1235 mm, which is 0.0005 mm different from the second iteration result, which is less than 10^-3 mm, so iteration stops. Finally, 26.1235 mm is determined as the theoretical object distance corresponding to the current focus value.
[0043] S107. Obtain the actual object distance of the camera to the screen under test, and determine whether the difference between the theoretical object distance and the actual object distance exceeds the preset object distance change threshold. In this embodiment, the position feedback module of the z-axis motion mechanism obtains the actual object distance when the camera captures the screen under test, ensuring the real-time performance and accuracy of the actual object distance data. Subsequently, based on the calculated theoretical object distance, the absolute difference between the actual object distance and the theoretical object distance is calculated. The calculated absolute difference is compared with a preset object distance change threshold to determine whether the difference exceeds the preset object distance change threshold. In practical applications, the preset object distance change threshold is typically set to 0.5mm, but this can be adjusted based on screen precision requirements. This threshold is primarily to ensure the maximum allowable object distance deviation while maintaining moiré suppression and image quality. For example, when the preset object distance change threshold is 0.5mm, the theoretical object distance is 26.1235mm, and the actual object distance obtained through the position feedback module is 26.7mm, the calculated absolute difference between the theoretical and actual object distances is 0.577mm. Since 0.577mm is greater than the preset 0.5mm, the difference is determined to exceed the preset object distance change threshold. When the preset object distance change threshold and the theoretical object distance remain unchanged, and the actual object distance is 26.4mm, the absolute difference is 0.2765mm. Since 0.2765mm is less than the 0.5mm threshold, the difference is determined to not exceed the preset object distance change threshold.
[0044] If the difference between the theoretical object distance and the actual object distance exceeds the preset object distance change threshold, then step S108 is executed; if the difference between the theoretical object distance and the actual object distance does not exceed the preset object distance change threshold, then the current out-of-focus position is acceptable and no adjustment is required.
[0045] S108: Dynamically move the camera to adjust the actual object distance until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold, and then complete the focus adjustment.
[0046] When the difference between the theoretical and actual object distance exceeds a preset object distance change threshold, the camera's movement direction and initial adjustment step size are determined based on the magnitude and direction of the difference. The movement direction is determined by moving the camera away from the screen when the difference is positive and moving it closer when the difference is negative. The initial adjustment step size is set based on the magnitude of the difference; a larger difference results in a slightly larger step size to ensure adjustment efficiency. Subsequently, the z-axis motion mechanism is controlled to move the camera along the determined movement direction and initial adjustment step size. After movement, the image of the screen under test is acquired again, and the current focus value is calculated and input into the relational model to obtain a new theoretical object distance. Simultaneously, a new actual object distance is acquired.
[0047] Repeat steps S105 to S107 sequentially until the difference between the new theoretical object distance and the actual object distance is less than the preset object distance change threshold, then stop adjusting and complete focusing. This closed-loop adjustment mechanism continuously corrects the deviation between the actual and theoretical object distances, ensuring that the camera is ultimately at the optimal out-of-focus position and guaranteeing image quality.
[0048] This embodiment solves the moiré pattern problem caused by camera capturing the screen by adjusting focus through sample calibration, defocus modeling, and dynamic calibration, ensuring the authenticity of the image data required for Demura correction, thereby improving the accuracy of Demura correction and the quality of display products. In practical applications, multiple sample images of the sample screen are first acquired using a camera at different step distances. A preset focusing algorithm is used to locate the real focus reference position of the sample screen based on the sample images, providing a reference basis for subsequent defocus adjustment. Then, starting from the real focus reference position, defocus images of the sample screen are acquired along the defocus direction at multiple defocus object distances according to the preset step distance, and the focus value of each defocus image is calculated. After obtaining the focus value and the corresponding defocus object distance, a relationship model is constructed based on the two to achieve a precise correlation between the focus value and the object distance. Next, the rate of change of the focus value is analyzed through the relationship model, and the target defocus of the sample screen is determined by combining it with a preset change threshold. The system precisely avoids the focus range where camera and screen pixel periodic interference causes moiré patterns. Then, within the target out-of-focus area, the camera captures the current image of the screen under test, calculates the current focus value, and inputs it into a relational model to obtain the corresponding theoretical object distance. Next, the actual object distance captured by the camera is obtained, and it is determined whether the difference between the theoretical and actual object distances exceeds a preset object distance change threshold. When the difference exceeds the threshold, the camera is dynamically moved to adjust the actual object distance until the difference between the adjusted actual and theoretical object distances falls within the preset object distance change threshold, thus completing the focus adjustment and ensuring that the captured image is free of moiré interference, guaranteeing the stability of the acquisition.
[0049] Please see Figure 2 This application also provides another embodiment of a focus adjustment method, which includes: S201. Acquire a flat field image captured by the camera under a uniformly illuminated standard white board environment and a dark field image captured when the shutter is closed. To address inherent differences in camera optical systems, such as lens distortion and uneven response of photosensitive elements, the dark-field images acquired in this embodiment can reflect the inherent noise of the camera optical system, while the flat-field images can reflect the response of the camera optical system under uniform illumination. The combination of the two provides basic data for eliminating inherent system errors.
[0050] In practical applications, the camera is first fixed on the z-axis motion mechanism, ensuring that the camera lens is directly facing a uniformly illuminated standard white board, and that the white board completely covers the camera's field of view. Then, the camera is turned on and an image of the standard white board is captured; this image is the flat-field image. The flat-field image is primarily used to record the response characteristics of the camera's optical system under uniform illumination. Subsequently, the camera shutter is closed, and a dark-field image is captured in a state where no light enters the lens. The dark-field image is used to capture inherent noise signals such as dark current in the camera's image sensor.
[0051] It is important to note that during the acquisition process, the camera's exposure time, gain, and other parameters need to be kept constant to ensure that the acquisition conditions for the two images are consistent.
[0052] S202. Perform flat field correction processing on all images acquired using the camera based on flat field images and dark field images; In this embodiment, based on the acquired flat field image and dark field image, flat field correction is performed on all subsequently acquired images to eliminate the inherent error of the camera optical system. The inherent noise of the camera optical system is mainly canceled by the dark field image, and the illumination response of the camera optical system is normalized by the flat field image.
[0053] Specifically, the acquired flat-field and dark-field images are used to correct each image captured by the camera in subsequent steps. During correction, the pixel grayscale value of the image to be corrected is first subtracted from the corresponding pixel grayscale value of the dark-field image to remove noise interference such as dark current. Then, the difference is divided by the grayscale difference between the corresponding positions of the flat-field and dark-field images to eliminate the effects of lens distortion and uneven response of the image sensor. Finally, grayscale normalization is performed to map the grayscale values of the corrected image to a standard range.
[0054] Further, the leveling correction is performed using the following formula: ; in, This is the image after flat-field correction. Images captured by a camera. This is a dark field image. A flat-field image. This is the grayscale normalization coefficient, which can be 255 in practical applications.
[0055] After completing the flat-field correction, it is also necessary to perform consistency calibration on the basic imaging characteristics of multiple sample screens to eliminate the impact of individual differences between different sample screens of the same model on the accuracy of subsequent relational model construction. For at least 10 sample screens of the same model, standard white field images near the real-focus reference position are acquired under the same camera parameters, ambient lighting, and screen display parameters, and the average brightness value and pixel grayscale distribution standard deviation of each sample screen are calculated.
[0056] Using the average brightness of all sample screens as a benchmark, the grayscale values of each sample image are linearly normalized to control brightness deviation within ±2%. Simultaneously, outlier samples with a grayscale distribution standard deviation exceeding three times the overall average are removed to avoid focus value calculation errors caused by uneven screen brightness or pixel defects. This ensures that subsequently acquired out-of-focus image data has a unified benchmark, significantly improving the generalization ability of the relationship model and avoiding the poor model adaptability problem caused by modeling from a single sample.
[0057] S203. Move the camera along a preset first step path, and capture a first sample image of the sample screen for each preset first step path, and calculate the focus value of the first sample image. In this embodiment, the preset first step size can be set to 5cm in practical applications. This larger step size can improve efficiency, and it is necessary to ensure that the camera's movement range can cover the focal point of the sample screen. The focal point corresponds to the peak value of the focus. Only by sampling the entire area with a larger step size can the approximate area where the peak value of the focus is located be quickly locked.
[0058] Specifically, the z-axis motion mechanism is controlled to move the camera along the direction of approaching or moving away from the sample screen. After each preset step, the camera stops and captures a first sample image of the sample screen. After acquisition, the focus value of each first sample image is calculated. The focus value quantifies the sharpness by statistically analyzing the degree of change in the grayscale of the image pixels; the higher the value, the sharper the image.
[0059] Furthermore, the focus value is calculated using the following formula: ; in, For focus value, For brightness function, For contrast function, For structure functions; The brightness function is expressed by the following formula: ; The contrast function is expressed by the following formula: ; The structure function is defined by the following formula: ; in, For images captured using a camera, After mean filtering , for The mean, for The mean, for standard deviation for standard deviation , as well as It is a constant, and , , This is the depth parameter.
[0060] S204. Sort the focus values of the first sample images from largest to smallest, and determine the coarse positioning position of the focus value of the first first sample image after sorting by a coarse positioning algorithm. In this embodiment, the coarse positioning range of the real focus position is determined by sorting the focus value and using a coarse positioning algorithm. The focus value is positively correlated with the image sharpness, and the acquisition position corresponding to the maximum focus value is closest to the real focus state. By sorting, the coarse positioning position can be quickly filtered out, and the coarse positioning algorithm can ensure the accuracy of the coarse positioning position extraction.
[0061] Specifically, all focus values are sorted in descending order, from largest to smallest. Since the image sharpness is highest at the in-focus position, the corresponding focus value is the largest. The first focus value after sorting is the maximum focus value within the current sampling range. Subsequently, a coarse localization algorithm is called to extract the acquisition position of the first sample image corresponding to this maximum focus value, and this acquisition position is determined as the coarse localization position.
[0062] S205. Determine the fine positioning range based on the coarse positioning position and the preset first step path; In this embodiment, the fine positioning range is defined based on the coarse positioning position and the preset first step path. This is because the area where the maximum focus value is located corresponding to the coarse positioning position is located, and the actual focus position is located in a small range near the coarse positioning position. By defining the range with half of the preset first step path as the radius, the area where the actual focus position exists can be accurately covered, while controlling the size of the range to ensure the efficiency of fine positioning.
[0063] Specifically, using the coarse positioning position as the center, the fine positioning range is defined as the interval from the coarse positioning position minus half of the preset first step diameter to the coarse positioning position plus half of the preset first step diameter. For example, if the coarse positioning position is 28cm and the preset first step diameter is 5cm, then the fine positioning range is 25.5cm-30.5cm. During the definition process, it is necessary to ensure that this fine positioning range is within the camera's movable range. If it exceeds this range, the boundary should be adjusted appropriately to the camera's movement limit.
[0064] S206. Within the precise positioning range, move the camera with a preset second step path, and acquire a second sample image of the sample screen for each preset second step path, and calculate the focus value of the second sample image, wherein the preset second step path is smaller than the preset first step path. In the above steps, the precise positioning range has accurately locked the area where the focus point is located. Therefore, through dense sampling with a smaller preset second step diameter in this embodiment, the pattern of focus value changes with position can be meticulously captured, and the focus point corresponding to the peak focus value can be accurately located. For example, if 0.1cm is used as the preset second step diameter, and the precise positioning range is 25.5cm-30.5cm, then 51 images can be acquired within 25.5cm-30.5cm. In addition, the preset second step diameter is smaller than the preset first step diameter in practical applications to ensure sampling accuracy.
[0065] Specifically, the z-axis motion mechanism is controlled to move the camera within a defined precision positioning range. Each time the camera moves a preset second step, it pauses and acquires a second sample image of the sample screen, while simultaneously recording the coordinates of each acquisition position. After acquisition, the focus value of each second sample image is calculated.
[0066] S207. Sort the focus values of the second sample images from largest to smallest, and determine the fine positioning position of the focus value of the first second sample image after sorting by a fine positioning algorithm. The fine positioning position is the real focus reference position of the sample screen. During the sorting process, the focus values and corresponding acquisition position data of all second sample images are first processed, and abnormal data such as abrupt changes in focus values caused by shooting shake are removed. Then, the valid focus values are sorted in descending order. The first focus value after sorting is the maximum focus value within the fine positioning range, corresponding to the image with the highest clarity. Subsequently, the fine positioning algorithm is called to extract the acquisition position of the second sample image corresponding to the maximum focus value. This acquisition position is the real focus reference position of the sample screen.
[0067] S208. Starting from the real focus reference position, use the camera to collect the defocused images of the sample screen at multiple defocused object distances along the defocused direction according to the preset step path, and calculate the focus value of each defocused image. S209. Construct a relationship model based on the focus value and the corresponding virtual focus distance; In this embodiment, steps S208 to S209 are similar to steps S102 to S103 in the previous embodiment, and will not be described again here.
[0068] S210. Calculate the rate of change between the focus value at the real focus reference position and the focus value corresponding to each out-of-focus image using a relational model. In this embodiment, the difference between the focus value of each out-of-focus image and the focus value of the solid focus reference position, as well as the corresponding difference in object distance, are calculated using a relational model. Then, the focus value difference is divided by the corresponding difference in object distance to obtain the rate of change of focus value at each out-of-focus position, that is, the amount of change of focus value per unit out-of-focus distance. For example, if the focus value of the solid focus reference position extracted by the relational model is 95, and the focus value of a certain out-of-focus image is 90, the difference in object distance between the out-of-focus image and the solid focus reference position is 0.5mm. Then, the rate of change of focus value at this out-of-focus position is (95-90)÷0.5mm=10 / 0.5mm. Another out-of-focus image has a focus value of 82, and the corresponding difference in object distance is 1.3mm. Then, the rate of change of focus value at this out-of-focus position is (95-82)÷1.3mm=13 / 1.3mm. The rate of change of focus value can indirectly reflect the change in blur level of an image from in focus to out-of-focus. The rate of change is stable in the early stage of the transition from in focus to out-of-focus, but the rate of change will change abruptly when the image is too out of focus.
[0069] Furthermore, the relational model is expressed by the following formula: ; in, For focus value, For preset step path, The reference position for the actual focus. This relates the focus value to the corresponding virtual focus distance. The order of the polynomial fit for constructing the relational model.
[0070] Furthermore, the rate of change is expressed by the following formula: ; in, For the rate of change, For the first The focus value corresponding to a defocused image. This is the focus value at the reference position of the real focus. This is the preset step path.
[0071] S211. Sequentially determine whether the absolute value of the difference between adjacent rates of change is less than a preset change threshold. In this embodiment, since the image sharpness drops sharply when the focus is excessively out of focus, the rate of change of the focus value will change abruptly. Therefore, by comparing the absolute value of the difference between adjacent change rates with a preset change threshold, it can be determined whether the critical state of excessive out of focus has been reached. The preset change threshold is the critical standard for judging whether the rate of change of the focus value changes abruptly. In practical applications, it can be set to 400, which can be adjusted according to the screen type.
[0072] Specifically, two adjacent rates of change are selected sequentially, and the absolute value of their difference is calculated. Then, the absolute value of the difference between each adjacent rate of change is compared with a preset change threshold to determine whether it is less than the preset change threshold. For example, if the adjacent rates of change after being sorted by the virtual focus distance are 120, 150, 160, 200, and 650, and the preset change threshold is set to 400, the absolute values of the differences between adjacent rates of change are calculated to be 30, 10, 40, and 450, respectively. Among them, 30, 10, and 40 are all less than 400, and the absolute value of the last group of differences, 450, is greater than 400. Therefore, it is determined that the absolute value of the difference between the last group of adjacent rates of change, 200 and 650, is not less than the preset change threshold.
[0073] When the absolute value of the difference between adjacent rates of change is less than the preset change threshold, it indicates that the rate of change is stable, the moiré pattern continues to weaken and the image is not excessively blurred; when the absolute value of the difference between adjacent rates of change is not less than the preset change threshold, step S121 is executed.
[0074] Furthermore, it is determined whether the absolute value of the difference between adjacent rates of change is less than a preset threshold, as shown by the following formula: ; in, For the first rate of change, For the first rate of change, This is a preset threshold for change.
[0075] S212. Take the defocus position of the defocused image corresponding to the previous change rate among the adjacent change rates as the target defocus position, and take the interval from the real focus reference position to the target defocus position as the target defocus position range.
[0076] When the absolute value of the difference between adjacent rate of change is not less than a preset rate of change, it indicates that the out-of-focus position corresponding to the latter rate of change has entered an over-out-of-focus state. In this case, the out-of-focus position of the out-of-focus image corresponding to the former rate of change among these two adjacent rates of change needs to be determined as the target out-of-focus position. This position is the optimal position for moiré pattern elimination without over-out-of-focus. For example, if the preset rate of change is 400, and the difference between the last pair of adjacent rate of change 200 and 650 (450) is greater than 400, then the out-of-focus position corresponding to the former rate of change 200 is taken as the target out-of-focus position. Subsequently, the interval between the real focus reference position and this target out-of-focus position is defined as the target out-of-focus position range.
[0077] This method of determining the target defocus position range is based on the fact that the defocus position corresponding to the previous rate of change is still within the stable range of the rate of change, the image has no obvious moiré patterns and the brightness information is complete. Using this as the endpoint to define the target defocus position range can ensure that all positions within the target defocus position range meet the detection requirements.
[0078] S213. Use a camera to capture the current image of the screen under test within the target defocus position range, and calculate the current focus value; S214. Input the current focus value into the relational model, and calculate the theoretical object distance of the current focus value through the relational model; S215. Obtain the actual object distance of the camera to the screen under test, and determine whether the difference between the theoretical object distance and the actual object distance exceeds the preset object distance change threshold. S216. Dynamically move the camera to adjust the actual object distance until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold, and then complete the focus adjustment.
[0079] In this embodiment, steps S213 to S216 are similar to steps S105 to S108 in the previous embodiment, and will not be described again here.
[0080] Optionally, the theoretical object distance is calculated using the following formula: ; in, For focus value, For the theoretical object distance, To construct the order of the polynomial fit for the relational model, The polynomial fitting coefficients for constructing the relational model.
[0081] Furthermore, during the dynamic movement of the camera to adjust the actual object distance, an adaptive step size adjustment mechanism can be employed to balance the efficiency and accuracy of focus adjustment. This mechanism automatically switches between different adjustment step sizes based on the difference between the theoretical and actual object distance. For example, when the difference is greater than 2mm, a large step size of 1mm is used for rapid adjustment, allowing the camera to quickly approach the target's theoretical object distance area and significantly shortening the coarse adjustment time. When the difference narrows to between 0.5mm and 2mm, a medium step size of 0.1mm is used for fine adjustment, gradually reducing the object distance deviation. When the difference is less than 0.5mm, a micro step size of 0.01mm is used for calibration, ensuring that the final object distance deviation is controlled within a preset threshold.
[0082] At the same time, after each step change, an image acquisition and focus value calculation verification step is added to confirm that the adjustment direction under the current step is correct, and to avoid over-adjustment problems caused by excessive step size.
[0083] The focusing adjustment system provided in this application is described in detail below. Please refer to [link / reference]. Figure 3 , Figure 3 One embodiment of the focus adjustment system provided in this application includes: The positioning unit 301 is used to acquire multiple sample images of the sample screen under different step sizes using a camera, and to locate the real focus reference position of the sample screen based on the sample images using a preset focusing algorithm. The first calculation unit 302 is used to acquire images of the sample screen at multiple defocus distances along the defocus direction using a camera, starting from the real focus reference position, and to calculate the focus value of each defocus image. Construction unit 303 is used to construct a relationship model based on the focus value and the corresponding virtual focus distance; The determination unit 304 is used to analyze the rate of change of the focus value through a relational model and determine the range of the target defocus position on the sample screen in combination with a preset change threshold. The second calculation unit 305 is used to acquire the current image of the screen under test using a camera within the target defocus position range, and to calculate the current focus value; The third calculation unit 306 is used to input the current focus value into the relational model and calculate the theoretical object distance of the current focus value through the relational model; The judgment unit 307 is used to obtain the actual object distance of the camera to the screen under test, and to determine whether the difference between the theoretical object distance and the actual object distance exceeds the preset object distance change threshold. The adjustment unit 308 is used to dynamically move the camera to adjust the actual object distance if the actual object distance is adjusted until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold to complete the focus adjustment.
[0084] Optionally, the preset focus algorithm includes a coarse positioning algorithm and a fine positioning algorithm; Multiple sample images of the sample screen are acquired using a camera at different step sizes, and a preset focusing algorithm is used to locate the real focus reference position of the sample screen based on the sample images, including: The camera captures multiple sample images of the sample screen under a preset first step path, and the coarse positioning position is determined based on the sample images under the preset first step path using a coarse positioning algorithm. The fine positioning range is determined based on the coarse positioning position and the preset first step path; Within the fine positioning range, multiple sample images of the sample screen are acquired using a camera under a preset second step path, and the fine positioning position is determined based on the sample images under the preset second step path using a fine positioning algorithm. The fine positioning position is the real focal reference position of the sample screen, where the preset second step path is smaller than the preset first step path.
[0085] Optionally, the positioning unit 301 is specifically used for: The camera is moved along a preset first step path. Each time the camera moves along the preset first step path, a first sample image of the sample screen is captured, and the focus value of the first sample image is calculated. Sort the focus values of the first sample images from largest to smallest, and determine the coarse localization position of the focus value of the first sorted first sample image using a coarse localization algorithm. Within the precise localization range, multiple sample images of the sample screen are acquired using a camera under a preset second step path. The precise localization position is then determined based on these sample images using a precise localization algorithm, including: Within the precise positioning range, the camera is moved along a preset second step path. For each preset second step path, a second sample image of the sample screen is acquired, and the focus value of the second sample image is calculated. The focus values of the second sample images are sorted from largest to smallest, and the fine localization position of the focus value of the first second sample image after sorting is determined by a fine localization algorithm.
[0086] Optionally, the focus value is calculated using the following formula: ; in, For focus value, For brightness function, For contrast function, For structure functions; The brightness function is expressed by the following formula: ; The contrast function is expressed by the following formula: ; The structure function is defined by the following formula: ; in, For images captured using a camera, After mean filtering , for The mean, for The mean, for standard deviation for standard deviation , as well as It is a constant, and , , This is the depth parameter.
[0087] Optionally, the determining unit 304 is specifically used for: The rate of change between the focus value at the real focus reference position and the focus value corresponding to each out-of-focus image is calculated using a relational model. The absolute value of the difference between adjacent rates of change is determined sequentially to see if it is less than a preset change threshold. If not, the defocus position of the defocused image corresponding to the previous change rate among the adjacent change rates is taken as the target defocus position, and the interval from the real focus reference position to the target defocus position is taken as the target defocus position range.
[0088] Optionally, the relational model can be expressed as follows: ; in, For focus value, For preset step path, The reference position for the actual focus. This relates the focus value to the corresponding virtual focus distance. The order of the polynomial fit for constructing the relational model.
[0089] Optionally, it also includes a processing unit 309, specifically used for: Acquire flat-field images captured by the camera under a uniformly illuminated standard white board environment and dark-field images captured with the shutter closed; Flat field correction is performed on all images acquired using the camera, based on flat field and dark field images.
[0090] Optionally, the theoretical object distance is calculated using the following formula: ; in, For focus value, For the theoretical object distance, To construct the order of the polynomial fit for the relational model, The polynomial fitting coefficients for constructing the relational model.
[0091] For details on the implementation method, please refer to [link / reference]. Figures 1-2 Examples will not be described in detail here.
[0092] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform any of the above-described focus adjustment methods.
[0093] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0094] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0095] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0096] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0097] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A focus adjustment method, characterized in that, include: Multiple sample images of the sample screen are captured using a camera at different step sizes, and a preset focusing algorithm is used to locate the real focus reference position of the sample screen based on the sample images. Starting from the real focus reference position, the camera is used to acquire out-of-focus images of the sample screen at multiple out-of-focus object distances along the out-of-focus direction according to a preset step path, and the focus value of each out-of-focus image is calculated. A relationship model is constructed based on the focal value and the corresponding virtual focal distance; The rate of change of the focus value is analyzed using the relationship model, and the range of the target out-of-focus position on the sample screen is determined by combining the preset change threshold. The camera is used to acquire the current image of the screen under test within the range of the target out-of-focus position, and the current focus value is calculated; The current focus value is input into the relational model, and the theoretical object distance of the current focus value is calculated through the relational model; The actual object distance to the screen under test captured by the camera is obtained, and it is determined whether the difference between the theoretical object distance and the actual object distance exceeds a preset object distance change threshold. If so, the camera is dynamically moved to adjust the actual object distance until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold, thus completing the focus adjustment. The preset focusing algorithm includes a coarse positioning algorithm and a fine positioning algorithm; The step of acquiring multiple sample images of the sample screen at different step sizes using a camera, and locating the real focus reference position of the sample screen based on the sample images using a preset focusing algorithm, includes: The camera captures multiple sample images of the sample screen under a preset first step path, and the coarse positioning position is determined based on the sample images under the preset first step path using the coarse positioning algorithm. The fine positioning range is determined based on the coarse positioning position and the preset first step path; Within the fine positioning range, the camera is used to acquire multiple sample images of the sample screen under a preset second step path, and the fine positioning position is determined based on the sample images under the preset second step path by the fine positioning algorithm. The fine positioning position is the real focus reference position of the sample screen, wherein the preset second step path is smaller than the preset first step path. The step of using a camera to acquire multiple sample images of the sample screen under a preset first step path, and determining the coarse localization position based on the sample images under the preset first step path using the coarse localization algorithm, includes: The camera is moved along a preset first step path, and a first sample image of the sample screen is acquired for each preset first step path, and the focus value of the first sample image is calculated. The focus values of the first sample images are sorted from largest to smallest, and the coarse positioning position of the focus value of the first sorted first sample image is determined by the coarse positioning algorithm. Within the precise positioning range, the camera acquires multiple sample images of the sample screen under a preset second step path, and the precise positioning position is determined based on the sample images under the preset second step path using the precise positioning algorithm, including: Within the precise positioning range, the camera is moved along a preset second step path. For each preset second step path, a second sample image of the sample screen is acquired, and the focus value of the second sample image is calculated. The focus values of the second sample images are sorted from largest to smallest, and the fine positioning position of the focus value of the first second sample image after sorting is determined by the fine positioning algorithm.
2. The focus adjustment method according to claim 1, characterized in that, The focus value is calculated using the following formula: ; Among them, the The focus value, For brightness function, For contrast function, For structure functions; The brightness function is expressed by the following formula: ; The contrast function is expressed by the following formula: ; The structure function is defined by the following formula: ; in, Images captured using the camera, After mean filtering , for The mean, for The mean, for standard deviation for standard deviation , as well as It is a constant, and , , This is the depth parameter.
3. The focus adjustment method according to claim 1, characterized in that, The step of analyzing the rate of change of the focus value through the relationship model and determining the target out-of-focus position range of the sample screen in combination with a preset change threshold includes: The rate of change between the focus value at the real focus reference position and the focus value corresponding to each of the out-of-focus images is calculated using the relationship model. The absolute value of the difference between adjacent rates of change is determined sequentially to be less than a preset threshold. If not, then the out-of-focus position of the out-of-focus image corresponding to the previous change rate among the adjacent change rates is taken as the target out-of-focus position, and the interval from the real focus reference position to the target out-of-focus position is taken as the target out-of-focus position range.
4. The focus adjustment method according to claim 3, characterized in that, The relational model is expressed by the following formula: ; in, The focus value, For the preset step path, The real focal reference position is... This refers to the relationship between the focal value and the corresponding virtual focal distance. The order of the polynomial fit for constructing the relational model.
5. The focusing adjustment method according to any one of claims 1 to 4, characterized in that, Before acquiring multiple sample images of the sample screen at different step sizes using a camera, the focus adjustment method further includes: Acquire flat-field images captured by the camera under a uniformly illuminated standard white board environment and dark-field images captured with the shutter closed; Flat field correction is performed on all images acquired using the camera based on the flat field image and the dark field image.
6. The focusing adjustment method according to any one of claims 1 to 4, characterized in that, The theoretical object distance is calculated using the following formula: ; in, The focus value, The theoretical object distance is... To construct the order of the polynomial fit for the relational model, These are the polynomial fitting coefficients used to construct the relational model.
7. A focus adjustment system, characterized in that, For performing the focus adjustment method as described in any one of claims 1-6, comprising: The positioning unit is used to acquire multiple sample images of the sample screen under different step sizes using a camera, and to locate the real focus reference position of the sample screen based on the sample images using a preset focusing algorithm. The first calculation unit is used to acquire, with the real focus reference position as the starting point, the camera along the defocus direction according to a preset step path to acquire defocus images of the sample screen at multiple defocus object distances, and calculate the focus value of each defocus image; The construction unit is used to construct a relationship model based on the focus value and the corresponding virtual focus distance; The determining unit is used to analyze the rate of change of the focus value through the relationship model and determine the range of the target defocus position of the sample screen in combination with a preset change threshold. The second calculation unit is used to acquire the current image of the screen under test using the camera within the target defocus position range, and to calculate the current focus value; The third calculation unit is used to input the current focus value into the relation model and calculate the theoretical object distance of the current focus value through the relation model; The judgment unit is used to obtain the actual object distance of the camera to the screen under test, and to determine whether the difference between the theoretical object distance and the actual object distance exceeds the preset object distance change threshold. The adjustment unit is used to dynamically move the camera to adjust the actual object distance if the actual object distance is adjusted until the difference between the adjusted actual object distance and the theoretical object distance is within the preset object distance change threshold, thus completing the focus adjustment.
8. A computer-readable storage medium having a program stored thereon, the program performing the focus adjustment method as described in any one of claims 1 to 6 when executed on a computer.
Citation Information
Patent Citations
Four-dimensional polynomial model for depth estimation based on two-picture matching
CN102223477A
Split type long-focus visible light assembly fog penetration compensation method, system and equipment
CN120455841A