Automatic focusing method, system and device for double-line scanning camera

By using the defocus estimation curve and Tenengrad gradient function for automatic focus in a two-line scanning camera, the problems of low autofocus efficiency and poor accuracy in the prior art are solved, efficient and accurate image acquisition is achieved, and product quality and manufacturing efficiency are improved.

CN119603555AActive Publication Date: 2025-03-11SHANGOU TECH (HUZHOU) CO LTD +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510085247.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-03-11
Estimated Expiration
2045-01-20

AI Technical Summary

Technical Problem

The existing dual-line scanning camera autofocus system has low efficiency and poor accuracy, resulting in inaccurate image acquisition and affecting product quality and manufacturing efficiency.

Method used

The defocus estimation curve is used for autofocus, the image is collected through the line scanning camera module, the image quality is evaluated using Tenengrad gradient function and Gaussian nuclear convolution, the autofocus motion curve is fitted, the defocus distance is determined and the camera displacement is controlled to achieve autofocus.

Benefits of technology

Improves the efficiency and accuracy of autofocus, ensures the accuracy of image acquisition, and improves product quality and manufacturing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603555A_ABST
    Figure CN119603555A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic focusing method, system and device for a double-line scanning camera, and belongs to the technical field of camera control and adjustment. The objective of the invention is to solve the problems of low automatic focusing efficiency and poor precision of an existing double-line scanning camera. According to the method, firstly, a defocusing amount estimation curve is constructed, and in the construction process, a camera is controlled to ascend and move on the Z axis to collect N images; for each image, different Gaussian kernels are adopted for convolution to obtain a gradually fuzzy image, a Tenengrad gradient function is used for evaluating the quality, a Tenengrad-Gaussian kernel sigma curve is determined based on the images obtained by the different Gaussian kernels, and then a gradient value a is obtained; for a of the N images, fitting a curve of a gradient value a-position z by adopting a cubic function, namely a defocusing amount estimation curve; and then realizing automatic focusing of the double-line scanning camera by using the defocusing amount estimation curve.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of camera control and adjustment, and in particular relates to an automatic focusing system, system and device of a camera. Background Art

[0002] In modern industrial manufacturing, autofocus systems are essential to ensure high-quality products, especially in dual-line scan camera applications. Traditional autofocus systems often face problems such as unclear focus and troublesome focus debugging in dual-line scan camera applications. These problems may lead to inaccurate image acquisition, which in turn affects product quality and manufacturing efficiency. In order to overcome these challenges, Summary of the invention

[0003] The present invention aims to solve the problems of low automatic focusing efficiency and poor precision of the existing dual-line scanning camera.

[0004] An automatic focusing method for a dual-line scan camera, which realizes automatic focusing of the dual-line scan camera by using a defocus estimation curve;

[0005] The defocus estimation curve is pre-built. The process of building the defocus estimation curve includes:

[0006] S100, using the line scan camera module to acquire an image of the product. In this process, the Z axis is first adjusted to a certain set position, and then the Z axis is moved down by a distance of h0 to start acquiring images. After each image is acquired, the camera is controlled to acquire an image every time it moves up the Z axis by a distance of Δh. A total of N = 1 + h0 / Δh images are acquired, which are recorded as image M. o , o=0,1,2,…,N-1;

[0007] S200, fitting an auto-focus motion curve based on N pieces of image data, including:

[0008] S201, let o = 0, and transform the image M o Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o,σ ;

[0009] S202, use Tenengrad gradient function to M o,o The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function;

[0010] S203, for M o,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o,σThe corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve;

[0011] S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to one image by function fitting;

[0012] S205. For o=0, 1, 2, ..., N-1, the Tenengrad gradient function values ​​corresponding to the N images are calculated through steps S201 to S204 respectively, and then the "Tenengrad-Gaussian kernel σ" corresponding to the N images are obtained. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0013] The z-axis position of the image with the smallest curve gradient value a is set as the origin; a cubic function is used to fit the curve of gradient value a-position z, which is the defocus estimation curve;

[0014] The process of realizing automatic focusing of a dual line scan camera using a defocus estimation curve includes:

[0015] Using a dual line scan camera to capture images, and calculating the value of a gradient value a of a captured image according to S201-S204; determining the defocus distance according to the defocus estimation curve, which corresponds to the near focus defocus distance and the far focus defocus distance respectively;

[0016] Then, according to the defocus distance, the camera is controlled to move up or down once and collect images; according to the image quality evaluation function Brenner function, it is evaluated which direction of moving up and moving down is the actual focused image, and the corresponding position of the dual-line scan camera is the autofocus position.

[0017] Further, the defocus estimation curve is used to realize the dual-line S203 for M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ Corresponding to the image gradient value obtained by the Tenengrad gradient function, using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

[0018] Further, S204 determines the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting. The function described in the figure is as follows:

[0019]

[0020] Among them, Tenengrad is the gradient function value; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

[0021] Furthermore, the curve of gradient value a-position z fitted by a cubic function is as follows:

[0022]

[0023] Among them, f(x) is the fitting function of the gradient value a, x is the z-axis position, and the equation coefficient a neg 、b neg 、c neg d neg 、a pos 、b pos 、c pos d pos are all fitting parameters.

[0024] Furthermore, h0 is 0.5 mm and Δh is 0.01 mm.

[0025] An automatic focusing system for a dual line scan camera, comprising:

[0026] A focus estimation curve acquisition module is used to acquire a defocus estimation curve; the defocus estimation curve is pre-constructed, and the construction process includes:

[0027] S100, using the line scan camera module to acquire an image of the product. In this process, the Z axis is first adjusted to a certain set position, and then the Z axis is moved down by a distance of h0 to start acquiring images. After each image is acquired, the camera is controlled to acquire an image every time it moves up the Z axis by a distance of Δh. A total of N = 1 + h0 / Δh images are acquired, which are recorded as image M. o , o=0,1,2,…,N-1;

[0028] S200, fitting an auto-focus motion curve based on N pieces of image data, including:

[0029] S201, let o = 0, and transform the image M o Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o,σ ;

[0030] S202, use Tenengrad gradient function to M o,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function;

[0031] S203, for M o,σThe image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve;

[0032] S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to one image by function fitting;

[0033] S205. For o=0, 1, 2, ..., N-1, the Tenengrad gradient function values ​​corresponding to the N images are calculated through steps S201 to S204 respectively, and then the "Tenengrad-Gaussian kernel σ" corresponding to the N images are obtained. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0034] The z-axis position of the image with the smallest curve gradient value a is set as the origin; a cubic function is used to fit the curve of gradient value a-position z, which is the defocus estimation curve;

[0035] Product image acquisition module: uses a dual-line scan camera to acquire images;

[0036] Gradient value a calculation module: First, the image M o′ Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o′,σ ; Use Tenengrad gradient function to adjust M o′,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; o′,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o′,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve; the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to the image is determined by function fitting;

[0037] Autofocus motion module: Based on the gradient value a calculated by the gradient value a calculation module, the defocus distance is determined according to the obtained defocus estimation curve, which corresponds to the near focus defocus distance and the far focus defocus distance respectively; then according to the defocus distance, the camera is controlled to move up or down once and collect images; according to the image quality evaluation function Brenner function, it is evaluated which direction of moving up and down is the actual focused image, and the corresponding position of the dual-line scan camera is the autofocus position.

[0038] Further, the defocus estimation curve is used to realize the dual-line S203 for M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ Corresponding to the image gradient value obtained by the Tenengrad gradient function, using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

[0039] Further, S204 determines the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting. The function described in the figure is as follows:

[0040]

[0041] Among them, Tenengrad is the gradient function value; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

[0042] Furthermore, the curve of gradient value a-position z fitted by a cubic function is as follows:

[0043]

[0044] Among them, f(x) is the fitting function of the gradient value a, x is the z-axis position, and the equation coefficient a neg , b neg 、c neg d neg 、a pos , b pos 、c pos d pos are all fitting parameters.

[0045] An automatic focusing device for a dual-line scan camera, comprising the automatic focusing system for a dual-line scan camera and an image acquisition device, wherein the automatic focusing system for a dual-line scan camera is used to perform automatic focusing control on the image acquisition device, and the image acquisition device comprises an optical platform, an X-axis translation stage, a support column, a Z-axis translation stage, a fixing plate, a line scan camera module, a light source, and a product placement platform;

[0046] The X-axis translation stage is horizontally arranged on the optical platform, the product placement platform is arranged on the X-axis translation stage, and the product placement platform can move in the horizontal direction along the X-axis translation stage; the support column is vertically arranged on the optical platform, and the Z-axis translation stage is arranged on the support column; the fixed plate is arranged on the Z-axis translation stage, and the fixed plate can move in the vertical direction through the Z-axis translation stage; the fixed plate is arranged with a line scan camera module and a light source; the light source provides illumination for the objects on the product placement platform; the line scan camera module is used to capture images of the objects.

[0047] Beneficial effects:

[0048] The system of the present invention has the advantages of high automatic focusing efficiency and good focusing accuracy, and can ensure coverage of the entire target area and maximize detection sensitivity by accurately adjusting the positions of the camera and the light source unit.

[0049] In addition, the present invention is also adaptive and can be adjusted in real time according to the characteristics of different targets and environmental conditions to achieve the best auto-focusing effect.

[0050] The automatic focusing system of the present invention is not only suitable for the wide application of dual-line scanning cameras in the fields of industrial manufacturing and quality control, but also can significantly improve the accuracy and production efficiency of product inspection, bringing higher use value and economic benefits to users. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 The present invention is a schematic diagram of the structure of an autofocus system for a dual-line scan camera.

[0052] Figure 2 Flowchart of the autofocus process for a dual line scan camera.

[0053] Figure 3 This is the defocus estimation curve. DETAILED DESCRIPTION

[0054] Specific implementation method 1: Combination Figure 1 and Figure 2 To explain this embodiment,

[0055] This embodiment is an automatic focusing device for a dual-line scan camera, which includes an image acquisition device and an automatic focusing system for a dual-line scan camera; wherein,

[0056] The image acquisition device includes an optical platform 100, an X-axis translation stage 101, a support column 102, a Z-axis translation stage 103, a fixing plate 104, a line scan camera module 105, a light source 107, a product placement platform 108, etc. Figure 1 shown.

[0057] The X-axis translation stage 101 is horizontally arranged on the optical platform 100, the product placement platform 108 is arranged on the X-axis translation stage, and the product placement platform 108 can move in the horizontal direction along the X-axis translation stage; the support column 102 is vertically arranged on the optical platform 100, and the Z-axis translation stage 103 is arranged on the support column 102; the fixed plate 104 is arranged on the Z-axis translation stage 103, and the fixed plate 104 can move in the vertical direction through the Z-axis translation stage 103; the fixed plate 104 is provided with a line scan camera module 105 and a light source 107; the light source 107 provides illumination for the object 200 on the product placement platform 108; the line scan camera module 105 is used to capture images of the object 200.

[0058] In the present invention, the fixed line scan camera modules (dual cameras) are all fixed focal lengths and the focal points of the two cameras are on the same horizontal plane. The product placement platform is driven by the X-axis translation stage so that the product is captured and imaged by the line scan camera module. The image is evaluated by an algorithm, and the Z-axis translation stage is moved to drive the camera module to achieve focusing. The process of achieving focusing is based on the previous modeling process.

[0059] The autofocus system for a dual-line scan camera is used to perform autofocus control on an image acquisition device. It should be noted that in this embodiment, autofocus control is performed on the above-mentioned image acquisition device. In fact, the autofocus system for a dual-line scan camera is not limited to controlling the above-mentioned image acquisition device. As long as the image acquisition device has a similar working principle or structure to the above-mentioned image acquisition device, the autofocus system for a dual-line scan camera described in this embodiment can achieve control.

[0060] An image acquisition device with a similar working principle or structure to the above-mentioned image acquisition device is not limited to the structure of "the X-axis translation table 101 is horizontally arranged on the optical platform 100, the product placement platform 108 is arranged on the X-axis translation table, and the product placement platform 108 can move in the horizontal direction along the X-axis translation table", and any platform or structure that can achieve planar movement can be used; at the same time, it is not limited to the structure of "the support column 102 is vertically arranged on the optical platform 100, the Z-axis translation table 103 is arranged on the support column 102; the fixed plate 104 is arranged on the Z-axis translation table 103, and the fixed plate 104 can move in the vertical direction through the Z-axis translation table 103", and any structure that can achieve vertical movement can be used.

[0061] The automatic focusing system for a dual line scan camera comprises:

[0062] A focus estimation curve acquisition module is used to acquire a defocus estimation curve; the defocus estimation curve is pre-constructed, and the construction process includes:

[0063] S100, using the line scan camera module to acquire an image of the product. In this process, the Z axis is first adjusted to a certain set position, and then the Z axis is moved down by a distance of h0 to start acquiring images. After each image is acquired, the camera is controlled to acquire an image every time it moves up the Z axis by a distance of Δh. A total of N = 1 + h0 / Δh images are acquired, which are recorded as image M. o , o=0,1,2,…,N-1;

[0064] S200, fitting an auto-focus motion curve based on N pieces of image data, including:

[0065] S201, let o = 0, and transform the image M o Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o,σ ;

[0066] S202, use Tenengrad gradient function to M o,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function;

[0067] S203, for M o,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve;

[0068] The M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ Corresponding to the image gradient value obtained by the Tenengrad gradient function, using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

[0069] S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting; the function by function fitting is as follows:

[0070]

[0071] Among them, Tenengrad is the gradient function value; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

[0072] S205. For o=0, 1, 2, ..., N-1, the Tenengrad gradient function values ​​corresponding to the N images are calculated through steps S201 to S204 respectively, and then the "Tenengrad-Gaussian kernel σ" corresponding to the N images are obtained. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0073] The z-axis position of the image with the smallest curve gradient value a is set as the origin; a cubic function is used to fit the curve of gradient value a-position z, which is the defocus estimation curve;

[0074] The curve of the gradient value a-position z fitted by the cubic function is as follows:

[0075]

[0076] Among them, f(x) is the fitting function of the gradient value a, x is the z-axis position, and the equation coefficient a neg 、b neg 、c neg d neg 、a pos 、b pos 、c pos d pos are all fitting parameters.

[0077] Product image acquisition module: uses a dual-line scan camera to acquire images;

[0078] Gradient value a calculation module: First, the image M o′ Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o′,σ ; Use Tenengrad gradient function to adjust M o′,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; o′,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o′,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve; the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to the image is determined by function fitting;

[0079] Autofocus motion module: Based on the gradient value a calculated by the gradient value a calculation module, the defocus distance is determined according to the obtained defocus estimation curve, which corresponds to the near focus defocus distance and the far focus defocus distance respectively; then according to the defocus distance, the camera is controlled to move up or down once and collect images; according to the image quality evaluation function Brenner function, it is evaluated which direction of moving up and down is the actual focused image, and the corresponding position of the dual-line scan camera is the autofocus position.

[0080] Specific implementation method 2: Combination Figure 2 To explain this embodiment,

[0081] This embodiment is an auto-focus method for a dual-line scan camera, which uses the defocus estimation curve obtained in the previous modeling process to achieve auto-focus of the dual-line scan camera;

[0082] The early modeling process includes:

[0083] S100: Use the line scan camera module to acquire an image of the product. The specific process is as follows:

[0084] S101. Since the product may be uneven or the product plane height may vary greatly, it is necessary to select a position that needs to be focused in the image.

[0085] S102, first manually adjust the Z axis to a position where the image is roughly clear, and then move the Z axis downward by 0.5 mm;

[0086] S103, start collecting images, and after each image is collected, the Z axis rises by 0.01 mm, and repeats 101 times.

[0087] It should be noted that the moving distance of 0.5 mm and the step length of the upward movement can be adjusted according to the accuracy of the translation stage and the depth of field of the camera.

[0088] S200, analyzing the 101 saved image data for fitting the motion curve of the auto-focus motion, the specific process includes:

[0089] S201, for o=0, image M o Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o,σ ;

[0090] S202, use Tenengrad gradient function to M o,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function;

[0091] S203, for the image gradient value obtained by the Tenengrad gradient function, using the original image M oThe Tenengrad gradient function value of is normalized and the normalized Tenengrad gradient function value is obtained. The M obtained based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve;

[0092] In fact, M o There are 101, namely o=0,1,2…100. For the image gradient value of the blurred image corresponding to image M0, the normalization in step S203 is performed using the Tenengrad gradient function value corresponding to M0; when the image gradient value of the blurred image corresponding to image M1 is normalized in step S203, the Tenengrad gradient function value corresponding to M1 is used; the image gradient values ​​of the blurred images corresponding to o=0,1,2…100 are all normalized with the values ​​of their original images.

[0093] S204, using the following function to perform fitting to determine the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to one image;

[0094]

[0095] Among them, Tenengrad is the gradient function value; σ is the half width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is a fitting parameter (without physical meaning);

[0096] S205. For o=0, 1, 2…100, the Tenengrad gradient function values ​​corresponding to the 101 images are calculated respectively by the above-mentioned methods S201 to S204, and then the "Tenengrad-Gaussian kernel σ" corresponding to the 101 images are obtained. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0097] Set the z-axis position of the image with the smallest gradient value a (the clearest image) as the origin (optimal focus distance); use the following function to fit the curve of gradient value a-position z;

[0098]

[0099] Among them, f(x) is the fitting function of the gradient value a, x is the z-axis position (Defocus), and the equation coefficient a neg , b neg 、c neg d neg 、a pos , b pos 、c pos d posare all fitting parameters.

[0100] The position z is actually determined by fitting the image corresponding to the gradient value a, that is, the position of the camera on the z axis when the image was taken. The obtained gradient value a-position z curve is the defocus estimation curve, such as Figure 3 shown.

[0101] To autofocus on a product:

[0102] S300, the process of automatically focusing the product using the defocus estimation curve includes:

[0103] ① The product placement platform is driven by the X-axis translation stage so that the product is imaged by the line scan camera module;

[0104] ②Determine the image of the area to be focused based on the product;

[0105] ③ Calculate the a value of the captured image according to S201-S204 in S200;

[0106] ④ Determine the defocus distance according to the defocus estimation curve, which corresponds to the near focus defocus distance and the far focus defocus distance (i.e., two different horizontal coordinates under the same vertical coordinate);

[0107] ⑤ According to the defocus distance, control the camera to move up or down once and collect images;

[0108] ⑥ According to the image quality evaluation function Brenner function, evaluate which direction of upward and downward movement is the actual focused image; the larger the value of the Brenner function, the more ideal the image is, which corresponds to the moving direction that needs to be focused.

[0109] ⑦ Move the Z axis to the position of the clear image in ⑥ to achieve autofocus.

[0110] The present invention adopts the autofocus device of the dual-line scan camera independently developed by us to collect product images; determine the area to be focused by framing the image; fit the autofocus motion curve by calculating the defocus amount of the image; for the product to be automatically focused, determine the defocus distance according to the fitting curve; thereby control the movement of the Z-axis translation stage to achieve autofocus.

[0111] The above calculation examples of the present invention are only used to explain the calculation model and calculation process of the present invention in detail, and are not intended to limit the implementation methods of the present invention. For ordinary technicians in the relevant field, other different forms of changes or modifications can be made based on the above description. It is impossible to list all the implementation methods here. All obvious changes or modifications derived from the technical solution of the present invention are still within the scope of protection of the present invention.

Claims

1. An automatic focusing method for a dual line scan camera, characterized in that: Using the defocus estimation curve to realize the automatic focusing of the dual line scan camera; The defocus estimation curve is pre-built. The process of building the defocus estimation curve includes: S100, using the line scan camera module to acquire an image of the product. In this process, the Z axis is first adjusted to a certain set position, and then the Z axis is moved down by a distance of h0 to start acquiring images. After each image is acquired, the camera is controlled to acquire an image every time it moves up the Z axis by a distance of Δh. A total of N = 1 + h0 / Δh images are acquired, which are recorded as image M. o , o=0,1,2,…,N-1; S200, fitting an auto-focus motion curve based on N pieces of image data, including: S201, let o = 0, and transform the image M o Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o,σ ; S202, use Tenengrad gradient function to M o,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; S203, for M o,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve; S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting; S205. For o=0, 1, 2, ..., N-1, the Tenengrad gradient function values ​​corresponding to the N images are calculated through steps S201 to S204 respectively, and then the "Tenengrad-Gaussian kernel σ" corresponding to the N images are obtained. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a. The z-axis position of the image with the smallest curve gradient value a is set as the origin; a cubic function is used to fit the curve of gradient value a-position z, which is the defocus estimation curve; The process of realizing automatic focusing of a dual line scan camera using a defocus estimation curve includes: Using a dual line scan camera to capture images, and calculating the value of a gradient value a of a captured image according to S201-S204; determining the defocus distance according to the defocus estimation curve, which corresponds to the near focus defocus distance and the far focus defocus distance respectively; Then, according to the defocus distance, the camera is controlled to move up or down once and collect images; according to the image quality evaluation function Brenner function, it is evaluated which direction of moving up and moving down is the actual focused image, and the corresponding position of the dual-line scan camera is the autofocus position.

2. An automatic focusing method for a dual line scan camera according to claim 1, characterized in that: The defocus estimation curve is used to realize the dual-line S203 for M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ Corresponding to the image gradient value obtained by the Tenengrad gradient function, using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

3. An automatic focusing method for a dual line scan camera according to claim 1 or 2, characterized in that: S204 determines the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting, wherein the function described is as follows: Among them, Tenengrad is the gradient function value; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

4. An automatic focusing method for a dual line scan camera according to claim 3, characterized in that: The curve of the gradient value a-position z fitted by the cubic function is as follows: Among them, f(x) is the fitting function of the gradient value a, x is the z-axis position, and the equation coefficient a neg 、b neg 、c neg d neg 、a pos 、b pos 、c pos d pos are all fitting parameters.

5. The automatic focusing method for a dual line scan camera according to claim 4, characterized in that: h0 is 0.5mm and Δh is 0.01mm.

6. An automatic focusing system for a dual line scan camera, characterized in that: include: Focus estimation curve acquisition module: used to obtain the defocus estimation curve; The defocus estimation curve is pre-constructed, and the construction process includes: S100, using the line scan camera module to acquire an image of the product. In this process, the Z axis is first adjusted to a certain set position, and then the Z axis is moved down by a distance of h0 to start acquiring images. After each image is acquired, the camera is controlled to acquire an image every time it moves up the Z axis by a distance of Δh. A total of N = 1 + h0 / Δh images are acquired, which are recorded as image M. o , o=0,1,2,…,N-1; S200, fitting an auto-focus motion curve based on N pieces of image data, including: S201, let o = 0, and transform the image M o Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o,σ ; S202, use Tenengrad gradient function to M o,o The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; S203, for M o,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve; S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting; S205. For o=0, 1, 2, ..., N-1, the Tenengrad gradient function values ​​corresponding to the N images are calculated through steps S201 to S204 respectively, and then the "Tenengrad-Gaussian kernel σ" corresponding to the N images are obtained. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a. The z-axis position of the image with the smallest curve gradient value a is set as the origin; a cubic function is used to fit the curve of gradient value a-position z, which is the defocus estimation curve; Product image acquisition module: uses a dual-line scan camera to acquire images; Gradient value a calculation module: First, the image M o′ Convolution with different Gaussian kernels σ to obtain a gradually blurred image M o′,σ ; Use Tenengrad gradient function to adjust M o′,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; o′,σ The image gradient value obtained by the Tenengrad gradient function is normalized to obtain the normalized Tenengrad gradient function value. The M obtained based on different Gaussian kernels σ o′,σ The corresponding Tenengrad gradient function value obtains a curve, namely the "Tenengrad-Gaussian kernel σ" curve; the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to the image is determined by function fitting; Autofocus motion module: Based on the gradient value a calculated by the gradient value a calculation module, the defocus distance is determined according to the obtained defocus estimation curve, which corresponds to the near focus defocus distance and the far focus defocus distance respectively; then according to the defocus distance, the camera is controlled to move up or down once and collect images; according to the image quality evaluation function Brenner function, it is evaluated which direction of moving up and down is the actual focused image, and the corresponding position of the dual-line scan camera is the autofocus position.

7. An automatic focusing system for a dual line scan camera according to claim 6, characterized in that: The defocus estimation curve is used to realize the dual-line S203 for M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ Corresponding to the image gradient value obtained by the Tenengrad gradient function, using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

8. An automatic focusing system for a dual line scan camera according to claim 6 or 7, characterized in that: S204 determines the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to an image by function fitting, wherein the function described is as follows: Among them, Tenengrad is the gradient function value; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

9. An automatic focusing system for a dual line scan camera according to claim 8, characterized in that: The curve of the gradient value a-position z fitted by the cubic function is as follows: Among them, f(x) is the fitting function of the gradient value a, x is the z-axis position, and the equation coefficient a neg 、b neg 、c neg ,d neg 、a pos 、b pos 、c pos ,d pos are all fitting parameters.

10. An automatic focusing device for a dual line scan camera, characterized in that: It comprises an autofocus system and an image acquisition device for a dual line scan camera as claimed in any one of claims 6 to 9, wherein the autofocus system is used to perform autofocus control on the image acquisition device, and the image acquisition device comprises an optical platform (100), an X-axis translation stage (101), a support column (102), a Z-axis translation stage (103), a fixing plate (104), a line scan camera module (105), a light source (107), and a product placement platform (108); The X-axis translation table (101) is horizontally arranged on the optical platform (100), the product placement platform (108) is arranged on the X-axis translation table, and the product placement platform (108) can move in the horizontal direction along the X-axis translation table; the support column (102) is vertically arranged on the optical platform (100), and the Z-axis translation table (103) is arranged on the support column (102); the fixed plate (104) is arranged on the Z-axis translation table (103), and the fixed plate (104) can move in the vertical direction through the Z-axis translation table (103); the fixed plate (104) is provided with a line scan camera module (105) and a light source (107); the light source (107) provides illumination for an object on the product placement platform (108); and the line scan camera module (105) is used to capture images of the object.

Citation Information

Patent Citations

  • Automatic focusing method and system for handheld fundus camera

    CN116803336A

  • Rapid high-precision camera focusing method

    CN117201937A

  • Automatic focusing method and device for electron microscope

    CN117555123A

  • Double-line scanning high-resolution confocal imaging light path and imaging method

    CN118276291A

  • Interface wave three-dimensional shape and parameter measuring method and measuring system

    CN118392982A