Automatic focusing method, system and device for dual line scan camera

By constructing the defocus estimation curve, using the image acquisition and gradient function evaluation of the two-line scanning camera, the problems of low autofocus efficiency and poor accuracy of the two-line scanning camera are solved, and efficient and accurate autofocus effect is achieved.

CN119603555BActive Publication Date: 2025-08-19SHANGOU TECH (HUZHOU) CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510085247.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-08-19
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

By constructing the defocus estimation curve, the image was collected using the line scan camera module and Gaussian nuclear convolution and Tenengrad gradient function evaluation, the Tenengrad-Gaussian nuclear σ curve was fitted, and the defocus amount was determined by combining the 3-time function fitting to achieve automatic focus.

Benefits of technology

It improves the efficiency and accuracy of autofocus, ensures the accuracy of image acquisition, and improves the accuracy and production efficiency of product inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603555B_ABST
    Figure CN119603555B_ABST
Patent Text Reader

Abstract

The invention relates to an autofocus method, system and device for a dual-line scan camera, which belongs to the field of camera control and adjustment technology. In order to solve the problems of low efficiency and poor accuracy of the autofocus of the existing dual-line scan camera, the present invention first constructs a defocus estimation curve. During the construction process, the camera is controlled to move upward on the Z axis to collect N images; for each image, different Gaussian kernels are used for convolution to obtain a gradually blurred image, and the quality is evaluated using the Tenengrad gradient function. Based on the images obtained with different Gaussian kernels, a "Tenengrad-Gaussian kernel σ" curve is determined, and then a gradient value a is obtained; for a of the N images, a cubic function is used to fit the gradient value a-position z curve, which is the defocus estimation curve; then the defocus estimation curve is used to realize the autofocus of the dual-line scan camera.
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 crucial for ensuring high-quality products, especially in dual-line scan camera applications. Traditional autofocus systems often suffer from issues like unclear focus and difficult focus adjustments in dual-line scan camera applications. These issues can lead to inaccurate image acquisition, which in turn impacts product quality and manufacturing efficiency. Summary of the Invention

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

[0004] An automatic focusing method for a dual-line scan camera, which uses a defocus estimation curve to achieve automatic focusing of the dual-line scan camera;

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

[0006] S100. Use the line scan camera module to acquire an image of the product. During this process, first adjust the Z axis to a set position, then move the Z axis down a distance of h0 to start acquiring images. After each image is acquired, control the camera to move up the Z axis by a distance of Δh to acquire an image. 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,σ The image quality is evaluated and the image gradient value returned by the Tenengrad gradient function is obtained;

[0010] S203, for M o,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o,σThe corresponding Tenengrad gradient function value is 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, calculate the Tenengrad gradient function value corresponding to each of the N images through steps S201 to S204, and then obtain the "Tenengrad-Gaussian kernel σ" corresponding to each of the N images. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0013] The z-axis position of the image with the minimum 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 using the defocus estimation curve to achieve autofocus of a dual-line scan camera includes:

[0015] Capturing an image using a dual line scan camera, and calculating a gradient value a of the captured image according to S201-S204; determining defocus distances according to a defocus estimation curve, corresponding to near-focus defocus distances and far-focus defocus distances respectively;

[0016] Then, according to the defocus distance, the camera is controlled to move up or down once and an image is captured. The image quality evaluation function Brenner function is used to evaluate which direction of movement, up or down, is the actual focused image. The corresponding position of the dual-line scan camera is the autofocus position.

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

[0018] Furthermore, S204 determines the gradient value a of the “Tenengrad-Gaussian kernel σ” curve corresponding to one image by function fitting. The function described in the function 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 autofocus 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-built, and the construction process includes:

[0027] S100. Use the line scan camera module to acquire an image of the product. During this process, first adjust the Z axis to a set position, then move the Z axis down a distance of h0 to start acquiring images. After each image is acquired, control the camera to move up the Z axis by a distance of Δh to acquire an image. 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, 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 and the image gradient value returned by the Tenengrad gradient function is obtained;

[0031] S203, for M o,σNormalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value is 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, calculate the Tenengrad gradient function value corresponding to each of the N images through steps S201 to S204, and then obtain the "Tenengrad-Gaussian kernel σ" corresponding to each of the N images. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0034] The z-axis position of the image with the minimum 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 M o′,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; o′,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o′,σ The corresponding Tenengrad gradient function value is used to obtain 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, corresponding 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 an image is collected; according to the image quality evaluation function Brenner function, it is evaluated which direction of movement is actually in focus, the upward or downward movement. The corresponding position of the dual-line scan camera is the autofocus position.

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

[0039] Furthermore, S204 determines the gradient value a of the “Tenengrad-Gaussian kernel σ” curve corresponding to one image by function fitting. The function described in the function 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 autofocus device for a dual-line scan camera, comprising the aforementioned autofocus system for a dual-line scan camera and an image acquisition device, wherein the aforementioned autofocus system for a dual-line scan camera is used to perform autofocus 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 horizontally 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 vertically through the Z-axis translation stage; a line scan camera module and a light source are arranged on the fixed plate; the light source provides illumination for 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 autofocus efficiency and good focusing accuracy, and can ensure coverage of the entire target area and maximize detection sensitivity by precisely adjusting the positions of the camera and 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 autofocus effect.

[0050] The autofocus 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 can also 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 figure 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 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 the 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, and the product placement platform 108 is arranged on the X-axis translation stage. 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; a line scan camera module 105 and a light source 107 are arranged on the fixed plate 104; the light source 107 provides light 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 this invention, the fixed line scan camera modules (dual cameras) both have fixed focal lengths, and both cameras have their focal points aligned horizontally. An X-axis translation stage drives the product placement platform, allowing the line scan camera modules to capture and image the product. Algorithmic evaluation of the images is then performed, and the Z-axis translation stage is moved to focus the camera modules. This focusing process 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 control it.

[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 in which "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". Any platform or structure that can achieve planar movement can be used. At the same time, it is not limited to the structure in which "the support column 102 is vertically arranged on the optical platform 100, 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". 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-built, and the construction process includes:

[0063] S100. Use the line scan camera module to acquire an image of the product. During this process, first adjust the Z axis to a set position, then move the Z axis down a distance of h0 to start acquiring images. After each image is acquired, control the camera to move up the Z axis by a distance of Δh to acquire an image. 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 and the image gradient value returned by the Tenengrad gradient function is obtained;

[0067] S203, for M o,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value is 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,σ The image gradient value obtained by the Tenengrad gradient function is obtained by 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 one 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, calculate the Tenengrad gradient function value corresponding to each of the N images through steps S201 to S204, and then obtain the "Tenengrad-Gaussian kernel σ" corresponding to each of the N images. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a.

[0073] The z-axis position of the image with the minimum 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 M o′,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; o′,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o′,σ The corresponding Tenengrad gradient function value is used to obtain 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, corresponding 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 an image is collected; according to the image quality evaluation function Brenner function, it is evaluated which direction of movement is actually in focus, the upward or downward movement. 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 autofocus method for a dual-line scan camera, which uses the defocus estimation curve obtained in the previous modeling process to achieve autofocus of the dual-line scan camera;

[0082] The early modeling process includes:

[0083] S100: Use the line scan camera module to capture the 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 the position 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 down 0.5 mm;

[0086] S103, start collecting images, and after each image is collected, the Z axis rises 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: Analyze the 101 stored image data for fitting the auto-focus motion curve. 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 and the image gradient value returned by the Tenengrad gradient function is obtained;

[0091] S203, for the image gradient value obtained by the Tenengrad gradient function, using the original image M oThe Tenengrad gradient function value 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 is 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 performed, the normalization in step S203 is performed using the Tenengrad gradient function value corresponding to M1; 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 each of the 101 images are calculated using the above methods S201 to S204, and then the "Tenengrad-Gaussian kernel σ" corresponding to each of 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] 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 automatically focus 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 capture images;

[0108] ⑥ The image quality evaluation function Brenner function is used to evaluate which direction of the image is actually in focus, moving upward or downward. The larger the value of the Brenner function, the more ideal the image is, which corresponds to the direction of movement that needs to be focused.

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

[0110] This invention uses our independently developed dual-line scan camera's autofocus device to capture product images; the area to be focused is determined by framing the image; the autofocus motion curve is fitted by calculating the image's defocus amount; and the defocus distance of the product to be autofocused is determined based on the fitted curve. This controls the movement of the Z-axis translation stage to achieve autofocus.

[0111] The above examples are merely illustrative of the calculation model and process of the present invention and are not intended to limit the embodiments of the present invention. Persons skilled in the art will readily appreciate that other variations or modifications based on the above description are possible. This list of embodiments is not exhaustive; however, any obvious variations or modifications derived from the technical solution of the present invention remain 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 defocus estimation curve to realize autofocus of dual line scan camera; The defocus estimation curve is pre-built. The process of building the defocus estimation curve includes: S100. Use the line scan camera module to acquire an image of the product. During this process, first adjust the Z axis to a set position, then move the Z axis down a distance of h0 to start acquiring images. After each image is acquired, control the camera to rise on the Z axis, and acquire an image every time it moves a distance Δ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 σ yields a gradually blurred image M o,σ ; S202, use Tenengrad gradient function to M o,σ The image quality is evaluated and the image gradient value returned by the Tenengrad gradient function is obtained; S203, for M o,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value is a curve, namely the "Tenengrad-Gaussian kernel σ" curve; S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to one image by function fitting; S205. For o=0, 1, 2, ..., N-1, calculate the Tenengrad gradient function value corresponding to each of the N images through steps S201 to S204, and then obtain the "Tenengrad-Gaussian kernel σ" curve corresponding to each of the N images. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a. The Z-axis position of the image with the minimum 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 using the defocus estimation curve to achieve autofocus of a dual-line scan camera includes: Capturing an image using a dual line scan camera, and calculating a gradient value a of the captured image according to S201-S204; determining defocus distances according to a defocus estimation curve, corresponding to near-focus defocus distances and far-focus defocus distances respectively; Then, based on the defocus distance, the camera is controlled to move up and down once each, and images are captured. The Brenner function, an image quality evaluation function, is used to evaluate which direction of movement, up or down, is the actual focused image. The corresponding position of the dual-line scan camera is the autofocus position.

2. The automatic focusing method for a dual line scan camera according to claim 1, wherein: S203 for M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ The image gradient value obtained by the Tenengrad gradient function is obtained by using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

3. The 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. The function described is as follows: Among them, Tenengrad is the gradient function; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

4. The automatic focusing method for a dual line scan camera according to claim 3, wherein: 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, wherein: h0 is 0.5mm and Δh is 0.01mm.

6. An autofocus system for a dual line scan camera, characterized in that: include: Defocus estimation curve acquisition module: used to obtain the defocus estimation curve; The defocus estimation curve is pre-constructed, and the construction process includes: S100. Use the line scan camera module to acquire an image of the product. During this process, first adjust the Z axis to a set position, then move the Z axis down a distance of h0 to start acquiring images. After each image is acquired, control the camera to rise on the Z axis, and acquire an image every time it moves a distance Δ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 σ yields a gradually blurred image M o,σ ; S202, use Tenengrad gradient function to M o,σ The image quality is evaluated and the image gradient value returned by the Tenengrad gradient function is obtained; S203, for M o,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o,σ The corresponding Tenengrad gradient function value is a curve, namely the "Tenengrad-Gaussian kernel σ" curve; S204, determining the gradient value a of the "Tenengrad-Gaussian kernel σ" curve corresponding to one image by function fitting; S205. For o=0, 1, 2, ..., N-1, calculate the Tenengrad gradient function value corresponding to each of the N images through steps S201 to S204, and then obtain the "Tenengrad-Gaussian kernel σ" curve corresponding to each of the N images. Each "Tenengrad-Gaussian kernel σ" curve corresponds to a gradient value a. The Z-axis position of the image with the minimum 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 σ yields a gradually blurred image M o′,σ ; Use Tenengrad gradient function to M o′,σ The image quality is evaluated to obtain the image gradient value returned by the Tenengrad gradient function; o′,σ Normalize the image gradient value obtained by the Tenengrad gradient function to obtain the normalized Tenengrad gradient function value, and obtain M based on different Gaussian kernels σ o′,σ The corresponding Tenengrad gradient function value is used to obtain 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, corresponding 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 and down once and capture images. The image quality evaluation function Brenner function is used to evaluate which direction of movement is actually in focus. The corresponding position of the dual-line scan camera is the autofocus position.

7. The automatic focusing system for a dual line scan camera according to claim 6, wherein: S203 for M o,σ In the process of normalizing the image gradient value obtained by the Tenengrad gradient function, for M o,σ The image gradient value obtained by the Tenengrad gradient function is obtained by using the original image M o The Tenengrad gradient function value is normalized to obtain the normalized Tenengrad gradient function value.

8. The 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. The function described is as follows: Among them, Tenengrad is the gradient function; σ is the half-width of the Gaussian kernel; a represents the gradient value, which is a fitting parameter; b is the fitting parameter.

9. The automatic focusing system for a dual line scan camera according to claim 8, wherein: 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 according to 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 displacement stage (101) is horizontally arranged on the optical platform (100), the product placement platform (108) is arranged on the X-axis displacement stage, and the product placement platform (108) can move in the horizontal direction along the X-axis displacement stage; the support column (102) is vertically arranged on the optical platform (100), and the Z-axis displacement stage (103) is arranged on the support column (102); the fixed plate (104) is arranged on the Z-axis displacement stage (103), and the fixed plate (104) can move in the vertical direction through the Z-axis displacement stage (103); a line scan camera module (105) and a light source (107) are arranged on the fixed plate (104); the light source (107) provides light for items on the product placement platform (108); and the line scan camera module (105) is used to capture images of the items.

Citation Information

Patent Citations

  • Rapid high-precision camera focusing method

    CN117201937A

  • Automatic focusing method and device for electron microscope

    CN117555123A