A Dual Z-Axis Autofocus System and Method Based on Depth Vision
By using a dual Z-axis autofocus system, combined with depth vision and a graded adjustment strategy, the problems of slow cycle time and poor accuracy in thin glass inspection caused by single Z-axis are solved, achieving high-speed and high-precision autofocus to meet the inspection needs of complex surfaces.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WUHAN JINGCE ELECTRONICS GRP CO LTD
- Filing Date
- 2026-02-02
- Publication Date
- 2026-05-26
AI Technical Summary
Existing single Z-axis autofocus technology suffers from slow cycle time, poor accuracy, and insufficient stability in high-speed inspection scenarios involving large warps, thin glass, and complex surfaces, making it impossible to simultaneously meet the focusing requirements of large stroke, high speed, and micron-level accuracy.
A depth vision-based dual Z-axis autofocus system is adopted. Through the nested structure of the large and small Z-axis, combined with 3D vision detection components, it can achieve large-stroke coarse adjustment and high-precision fine adjustment. First, the surface depth map is obtained by 3D vision, and then the Z-axis adjustment strategy is allocated according to the region to perform automatic focusing.
It significantly shortens the single focusing time, improves repeatability accuracy, resists high reflection interference, meets the requirements of high-speed detection, and outputs focusing history files to achieve a fully digital closed loop.
Smart Images

Figure CN122085477A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of 3D vision inspection technology, and more specifically, to a dual Z-axis autofocus system and method based on depth vision. Background Technology
[0002] With the rapid development of semiconductors, optical devices, and advanced glass packaging technologies, glass substrates are becoming increasingly thinner (thickness < 0.1 mm), and their surfaces often have microstructures, conductive coatings, or adhesive layers. In the optical inspection stages of wafer-level packaging, LCD panels, and precision machining, high-speed, high-precision focusing of the glass surface is essential to ensure the reliability of subsequent defect detection, laser processing, or material coating. Focusing failure will directly cause blurred images and missed defects, leading to failures such as bubbles, cracks, and uneven conductivity in the packaging layer, ultimately affecting the product's optical performance, electrical performance, and mechanical strength.
[0003] Currently, the "single Z-axis + laser focus sensor" autofocus solution is commonly used on production lines. Its working principle is as follows: the laser emitting unit projects light onto the workpiece surface through a tube lens and objective lens; the reflected light returns to the receiving unit along the original path. The object distance is calculated by detecting changes in the laser spot position, and the Z-axis motor drives the entire camera-objective assembly to rise and fall, achieving closed-loop focusing. This solution has a simple structure and low cost, and can meet basic requirements in applications with small warpage and flat surfaces.
[0004] However, with the evolution of technology, the above-mentioned single Z-axis solution has revealed the following shortcomings: 1. Conflict between travel distance and speed The single Z-axis needs to simultaneously perform both "large-stroke coarse adjustment" and "small-stroke fine adjustment". When the glass warpage is greater than ±2 mm, the Z-axis must travel at high speed throughout the entire process. The large inertia and limited acceleration result in a single focusing time of greater than 1 second, which cannot meet the production line cycle time of ≥10000 UPH.
[0005] 2. Limitations of single-point distance measurement Lasers only sample the height of a single point and cannot capture the entire surface. When encountering local steps, grooves, or sudden changes in coating reflectivity, the system has a high probability of misjudgment, requiring multiple refocusing attempts, which adds an average of 0.5–1 s to the time spent, and is prone to "hunting" oscillations.
[0006] 3. Conflict between accuracy and vibration The large mass single Z-axis generates mechanical vibration and hysteresis during high-speed start-up and shutdown, which degrades the repeatability accuracy from ±1 µm to more than ±5 µm. Meanwhile, the depth of field of high-magnification microscopic imaging is often <1 µm, resulting in the image clarity failing to meet the requirements for defect detection.
[0007] 4. Reflection interference The laser and imaging optical path are coaxial, which is easily interfered with by multiple reflection signals generated by highly reflective metal mesh or transparent adhesive layer, resulting in false peaks and focusing errors. This requires manual re-judgment and reduces equipment uptime.
[0008] 5. Unable to pre-scan and plan The single Z-axis system lacks a pre-scanning method for the overall surface shape, making it impossible to plan the optimal focus surface in advance. It can only "adjust as it goes," frequently adjusting in areas of drastic warping, further slowing down the pace.
[0009] In summary, existing single Z-axis autofocus technology has encountered prominent problems such as slow cycle time, poor accuracy, and insufficient stability in high-speed inspection scenarios involving large warps, thin glass, and complex surfaces. There is an urgent need for a new focusing solution that can simultaneously achieve large stroke, high speed, and micron-level accuracy. Summary of the Invention
[0010] This invention addresses the technical problems existing in the prior art by providing a dual Z-axis autofocus system and method based on depth vision. By using dual Z-axis, it achieves large-stroke coarse adjustment and high-precision fine adjustment in the autofocus process, taking into account the advantages of focusing efficiency and focusing accuracy, and is suitable for various high-speed detection scenarios.
[0011] According to a first aspect of the present invention, a dual Z-axis autofocus system based on depth vision is provided, comprising a large Z-axis, a small Z-axis, and a vision detection component, wherein the vision detection component is vertically and vertically mounted on the small Z-axis, and the small Z-axis is vertically and vertically mounted on the large Z-axis, wherein: The visual inspection component is used to pre-scan a three-dimensional image of the surface of the target being tested, and based on the depth analysis results of the three-dimensional image, to assign a coarse adjustment strategy in the Z-axis to the large Z-axis and a fine adjustment strategy in the Z-axis to the small Z-axis. The large Z-axis is used to adjust the small Z-axis and the Z-axis position of the visual detection component according to the Z-axis coarse adjustment strategy. The small Z-axis is used to adjust the Z-axis position of the visual detection component according to the Z-axis fine-tuning strategy.
[0012] According to a second aspect of the present invention, a depth vision-based dual Z-axis autofocus method is provided, applied to the above-described system, the method comprising: A three-dimensional image of the surface of the target under test is pre-scanned, and the height change of the three-dimensional image and the optimal focus position are analyzed based on the image processing algorithm; Based on the image analysis results, a coarse adjustment strategy in the Z-axis is assigned to the large Z-axis and a fine adjustment strategy in the Z-axis is assigned to the small Z-axis. Automatic focusing is performed based on Z-axis coarse adjustment and Z-axis fine adjustment strategies.
[0013] Based on the above technical solution, the present invention can also be improved as follows.
[0014] Optionally, the pre-scanned three-dimensional image of the target surface includes: A detection light with a depth detection pattern is projected onto the surface of the target being tested, and a three-dimensional image of the target being tested with the depth detection pattern is acquired simultaneously, wherein the depth detection pattern is stripes, grids, or dot matrix.
[0015] Optionally, the step of analyzing the height change and optimal focus position of the 3D image based on the image processing algorithm includes: The 3D image is converted into a depth map based on an image processing algorithm; The depth map is divided into m×n regions, and the average height of each region is calculated to generate a height matrix H; The optimal focusing surface Zbest(i,j) for each region is calculated based on the height matrix H. Traverse the height matrix H in a preset order and calculate the height difference between adjacent regions in the height matrix H.
[0016] Optionally, the image processing algorithm is a phase unwrapping algorithm or a triangulation algorithm.
[0017] Optionally, the step of converting the 3D image into a depth map based on the image processing algorithm includes: Phase unwrapping calculation is performed on each pixel of the three-dimensional image to obtain the absolute phase map Φ(x,y); The absolute phase map Φ(x,y) is converted into a depth map D(x,y) based on the system calibration coefficients, and the depth map D(x,y) is then subjected to median filtering to remove isolated noise points.
[0018] Optionally, the step of assigning a coarse Z-axis adjustment strategy to the large Z-axis and a fine Z-axis adjustment strategy to the small Z-axis based on image analysis results includes: Compare the height difference Δh between adjacent regions in the height matrix H with the coarse adjustment threshold Tc: When Δh > Tc, insert a coarse adjustment command for the large Z-axis. When Δh≤Tc, keep the large Z-axis position unchanged and insert the small Z-axis fine-tuning command.
[0019] Optionally, autofocus is performed based on a Z-axis coarse adjustment strategy, including: Obtain the optimal focus plane Zbest(i,j) corresponding to the current region (i,j), and calculate the difference between the current large Z-axis position Zbig and the optimal focus plane Zbest(i,j): ΔZ = Zbest(i,j) Zbig; If |ΔZ| ≤ Tc, then skip the coarse adjustment step of the large Z-axis and proceed to the fine adjustment step of the small Z-axis; If |ΔZ|>Tc, then the large Z-axis moves a closed loop distance ΔZ at a preset speed.
[0020] Optionally, autofocus is performed based on a Z-axis fine-tuning strategy, including: The small Z-axis carries the camera-objective assembly in the fine-tuning window. Within Tf, +Tf], move with the initial step size, synchronously acquire images of the surface of the target under test and calculate the sharpness evaluation value Q; The movement step size and direction of the small Z-axis are adaptively adjusted according to the changing trend of the sharpness evaluation value Q until it is determined that the sharpness evaluation value Q has entered the peak region. Sharpness evaluation values Q are collected from multiple points in the peak region, and a quadratic polynomial fitting is performed to obtain the theoretical maximum value position z*. The small Z-axis is then moved to the theoretical maximum value position z* to complete fine focusing.
[0021] Optionally, the method also includes: after completing the global focus of the pre-scanned image, re-acquiring a full-frame image and traversing each region in the full-frame image to verify whether the sharpness of each region reaches the preset value.
[0022] According to a third aspect of the present invention, an electronic device is provided, including a memory and a processor, wherein the processor is configured to implement the steps of the aforementioned depth vision-based dual Z-axis autofocus method when executing a computer management program stored in the memory.
[0023] According to a fourth aspect of the present invention, a computer-readable storage medium is provided having a computer management program stored thereon, which, when executed by a processor, implements the steps of the aforementioned depth vision-based dual Z-axis autofocus method.
[0024] This invention provides a dual Z-axis autofocus method, system, electronic device, and storage medium based on depth vision. Through a nested structure of "large Z-axis - small Z-axis - vision inspection component," it balances long-stroke coarse adjustment and micro-stroke fine adjustment. First, a surface depth map is acquired in one go by 3D vision. Then, the remaining error is distributed to the two Z-axis by region, achieving rapid macroscopic focusing and high-speed microscopic compensation. This significantly shortens the single focusing time and effectively improves repeatability accuracy. Based on this, a "global-to-local" control strategy is adopted: pre-scanning generates a depth map → calculates the optimal focus surface for each region → compares the adjacent height difference with a threshold, automatically inserting large Z-axis coarse adjustment or small Z-axis fine adjustment commands. Finally, adaptive hill climbing and quadratic curve fitting lock the peak sharpness. This invention's solution can compensate for overall warpage and local steps in one go, resists high-reflection interference, and has a very low single-point defocus rate, meeting the needs of high-speed inspection production lines. It can also output a focusing history file, achieving a fully digital closed loop. Attached Figure Description
[0025] Figure 1 A schematic diagram of the composition structure of a dual Z-axis autofocus system based on depth vision provided in an embodiment of the present invention; Figure 2 A block diagram of the control architecture of a depth vision-based dual Z-axis autofocus system provided in an embodiment of the present invention; Figure 3 A flowchart of a dual Z-axis autofocus method based on depth vision provided in an embodiment of the present invention; Figure 4 A schematic diagram of the hardware structure of a possible electronic device provided by the present invention; Figure 5 This is a schematic diagram of the hardware structure of a possible computer-readable storage medium provided by the present invention.
[0026] The attached diagram lists the components represented by each number as follows: 1. Large Z-axis, 2. Small Z-axis, 3. 3D vision inspection instrument, 4. First focusing drive mechanism, 5. Second focusing drive mechanism, 6. Target under test, 7. Camera, 8. Objective lens, 9. Laser focusing sensor, 10. Mounting base. Detailed Implementation
[0027] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0028] Please see Figure 1 and Figure 2 , Figure 1 This is a schematic diagram of the composition structure of a depth vision-based dual Z-axis autofocus system provided in this embodiment. Figure 2 This embodiment provides a block diagram of the control architecture of a depth vision-based dual Z-axis autofocus system.
[0029] Combination Figure 1 and Figure 2 As shown, the dual Z-axis autofocus system based on depth vision provided in this embodiment mainly includes a large Z-axis 1, a small Z-axis 2, and a vision detection component. The vision detection component mainly includes... Figure 1 The diagram shows a 3D vision inspection instrument 3, a laser focusing sensor 9, and a camera 7 with a lens assembly. The 3D vision inspection instrument 3 includes an image processing module that communicates with the system controller; the laser focusing sensor 9 communicates with the focusing controller, and the focusing controller communicates with the system controller.
[0030] like Figure 1As shown, the X, Y, and Z directions are mutually perpendicular, with the Z-axis parallel to the optical axis of the objective lens 8 of the camera's 7-tube lens assembly. Based on a dual Z-axis autofocus system, it is adjustable. Figure 1 The distance in the Z direction between the objective lens 8 and the target 6 is shown.
[0031] Specifically, the fixed part of the large Z-axis 1 is mounted on the equipment mounting base 10 via the first focusing drive mechanism 4. Under the control of the system controller, the first focusing drive mechanism 4 can drive the movable part of the large Z-axis 1 to move up and down along the Z direction. The camera 7 lens assembly (including the objective lens 8), the small Z-axis 2, and the laser focusing sensor 9 are mounted on the movable part of the large Z-axis 1 to follow the movable part of the large Z-axis 1 to move up and down rapidly and significantly, achieving wide-range high-speed focusing.
[0032] The camera 7 and objective lens 8 are coaxially positioned to acquire surface images of the target 6. The objective lens 8 is mounted on the small Z-axis 2 via the second focusing drive mechanism 5, and can move slightly up and down in the Z-axis under the control of the focusing controller and the drive of the second focusing drive mechanism 5 to achieve precise focusing within a small range.
[0033] Preferably, the first focusing drive mechanism 4 can be implemented using a linear motor with strong load-bearing capacity, and the second focusing drive mechanism 5 can be implemented using a stepper motor + lead screw drive structure with higher control precision.
[0034] The 3D vision inspection instrument 3 is connected to the objective lens 8 via an optical path. It projects detection light with a depth detection pattern onto the surface of the target 6 and calculates the depth information of the surface image (i.e., surface depth map) of the target 6 based on the applied depth calculation algorithm. The laser focusing sensor 9, based on the spot position detection / confocal principle, can provide real-time feedback on the defocus amount between the objective lens 8 and the surface of the target 6, providing a basis for local focusing accuracy calibration.
[0035] This embodiment performs depth analysis based on the detection results of the 3D vision inspection instrument 3 and the laser focusing sensor 9, and assigns a coarse Z-axis adjustment strategy to the large Z-axis 1 and a fine Z-axis adjustment strategy to the small Z-axis 2 according to the depth analysis results. Under the drive of the first focusing drive mechanism 4, the large Z-axis 1 adjusts the Z-axis position of the small Z-axis 2 and the vision inspection component according to the coarse Z-axis adjustment strategy to achieve high-speed focusing over a wide range; under the drive of the second focusing drive mechanism 5, the small Z-axis 2 adjusts the Z-axis position of the vision inspection component according to the fine Z-axis adjustment strategy to achieve precise focusing over a small range.
[0036] This embodiment utilizes a nested structure of "large Z-axis - small Z-axis - vision inspection component" to balance long-stroke coarse adjustment and micro-stroke fine adjustment. During operation, 3D vision inspection first acquires the surface depth map in one go, then distributes the remaining error to the two Z-axises by region, achieving rapid macroscopic positioning and high-speed microscopic compensation. This significantly shortens the single-focusing time and effectively improves repeatability accuracy. Figure 1 as well as Figure 2 The system shown can compensate for overall warping and local steps in one go, resist high reflection interference, and has a very low single-point defocusing rate, meeting the needs of high-speed inspection production lines. It can also output focusing history files, realizing a digital closed loop throughout the entire process.
[0037] like Figure 3 The following is based on Figure 1 The system demonstrates a depth vision-based dual Z-axis autofocus method, which is applied to the system proposed in the aforementioned embodiments. The method includes: S1, pre-scan the three-dimensional image of the surface of the target to be tested, and analyze the height change of the three-dimensional image and the optimal focus position based on the image processing algorithm; S2, based on the image analysis results, assign a coarse adjustment strategy in the Z-axis to the large Z-axis and a fine adjustment strategy in the Z-axis to the small Z-axis; S3 uses a Z-axis coarse adjustment strategy and a Z-axis fine adjustment strategy for autofocus.
[0038] It is understood that in this embodiment... Figure 1 as well as Figure 2 The system shown employs a global-to-local control strategy: pre-scanning generates a surface depth map → calculates the optimal focus surface for each region → compares the adjacent height difference with a threshold, and automatically inserts coarse adjustment commands on the large Z-axis or fine adjustment commands on the small Z-axis. This method can compensate for overall warping and local steps in one step, resists high-reflection interference, and has a very low single-point defocusing rate, meeting the requirements of high-speed inspection production lines.
[0039] In one possible implementation, step S1, the pre-scanning of the three-dimensional image of the target surface includes: A detection light with a depth detection pattern is projected onto the surface of the target being tested, and a three-dimensional image of the target being tested with the depth detection pattern is acquired simultaneously, wherein the depth detection pattern is stripes, grids, or dot matrix.
[0040] Understandably, by projecting depth detection patterns such as stripes, grids, or dot matrices onto the surface being measured in one go and simultaneously acquiring the corresponding three-dimensional images, high-contrast surface shape data can be obtained completely using 3D vision, replacing traditional single-point laser sampling. This allows for the formation of the entire surface shape information in one go, effectively improving the signal-to-noise ratio and providing a complete and highly reliable foundation of depth data for subsequent phase unwrapping and dual Z-axis coarse-fine adjustment strategies.
[0041] In one possible implementation, step S1, which involves analyzing the height variation and optimal focus position of the 3D image based on an image processing algorithm, includes: The three-dimensional image is converted into a depth map based on an image processing algorithm, which employs either a phase unwrapping algorithm or a triangulation algorithm. The depth map is divided into m×n regions, and the average height of each region is calculated to generate a height matrix H; The optimal focusing surface Zbest(i,j) for each region is calculated based on the height matrix H. Traverse the height matrix H in a preset order and calculate the height difference between adjacent regions in the height matrix H.
[0042] Understandably, this embodiment first uses phase unwrapping or triangulation algorithms to convert the 3D image into a pixel-level depth map, then divides it into m×n regions to generate a height matrix H, calculates the optimal focus surface Zbest(i,j) for each region, and statistically analyzes the height difference between adjacent regions. It then outputs the surface elevation difference and focus target using two-level data: "region-neighborhood". Through these operations, the overall warping and local steps are quantified into an executable position sequence, providing a clear threshold basis for subsequent dual Z-axis coarse-fine command allocation. This avoids blind adjustment and repeated hunting of single-point lasers, effectively reducing pre-analysis time and surface misjudgment rate.
[0043] In one possible implementation, a phase unwrapping algorithm is used to convert a 3D image into a depth map, including the following steps: Perform phase unwrapping calculation on each pixel of the three-dimensional image, for example, recover the 0-2π wrapped phase into a continuous absolute phase map Φ(x,y); The absolute phase map Φ(x,y) is converted into a depth map D(x,y) based on the system calibration coefficients, and the depth map D(x,y) is then subjected to median filtering to remove isolated noise points.
[0044] For example, Φ(x,y) is linearly converted into the true depth map D(x,y) using the pre-calibrated system coefficients K(μm / rad), and finally, 3×3 median filtering is performed on the depth map D(x,y) to remove isolated noise points.
[0045] It is understood that this embodiment specifically defines the complete link for converting a 3D image into a depth map. This process replaces traditional laser single-point ranging with pure phase calculation, and can obtain the entire field shape in a short time (e.g., 30 ms) without additional hardware. The depth resolution can be as low as 0.5 μm, and the signal-to-noise ratio is effectively improved. This provides a highly reliable data foundation without jumps or outliers for subsequent m×n region division, optimal focus plane Zbest calculation, and dual Z-axis coarse-fine strategy, significantly reducing focusing errors caused by reflection interference or phase jumps.
[0046] In one possible implementation, calculating the optimal focus surface Zbest(i,j) required for each region based on the height matrix H includes: Obtain the optical depth of field ΔDOF based on the objective lens parameters; Centered on a region (i,j) within the height matrix H, a local statistical window W(i,j) of a preset size (e.g., 5×5) is generated, and the heights of all sub-pixels within the local statistical window W(i,j) are read as {Dsub(x,y) | (x,y)∈W}. Create a histogram of the sub-pixel heights {Dsub} within the same window, and truncate the histogram by a preset ratio (e.g., 5% / 95%) to remove outlier high / low points, resulting in a set {D′}. Calculate the maximum height difference ΔZmax(W) within the set {D′}, and based on the relationship between the maximum height difference ΔZmax(W) and the optical depth of field ΔDOF, calculate the height Hrep(i,j) within the window and the initial optimal focus plane Z0(i,j): If ΔZmax(W) ≤ ΔDOF, then the height Hrep(i,j) within the window takes the mean of the set {D′}: Hrep = mean(D′), Furthermore, the slope flag (i,j) is recorded as 0, indicating that the current window is basically flat; for flat areas, the initial optimal focus plane Z0(i,j) is output as follows: Z0(i,j) = Hrep(i,j); If ΔZmax(W) > ΔDOF, then the height Hrep(i,j) within the window takes the median value of the set {D′}. Hrep = median(D′), Furthermore, the slope flag (flag(i,j)) is recorded as 1, indicating the presence of a significant slope or step within the current window; for sloped areas, a depth-of-field offset is introduced to ensure that both the high and low ends fall within the depth of field; the initial optimal focus plane Z0(i,j) is calculated using the following formula: Z0(i,j) = Hrep(i,j) + (ΔZmax(W) ΔDOF) / 2; The initial optimal focusing surface Z0(i,j) is subjected to a second smoothing process (e.g., 3×3 Gaussian smoothing) and a boundary compatibility check to obtain the final optimal focusing surface Zbest(i,j).
[0047] Understandably, this embodiment provides a complete algorithm for calculating the optimal focus surface Zbest(i,j) using the height matrix H. This embodiment uses a four-level processing approach—"statistics-truncation-offset-smoothing"—to quantify local warping, steps, or coating thickness differences into a micrometer-level focus surface in one step. Different statistical measures are automatically used for sloped and flat areas to avoid bias from single-point extreme values. The height error representing the surface shape and the height jump between adjacent macropixels are effectively reduced, decreasing the number of large Z-axis reversals and shortening the small Z-axis fine-tuning travel. While ensuring full-area sharpness within high-magnification microscopic depth of field, the overall focusing time is significantly reduced.
[0048] In one possible implementation, step S2 includes: A preset coarse adjustment threshold Tc is set, for example, Tc ≈ 0.5·ΔDOF. The height difference Δh between adjacent regions in the height matrix H is compared with the coarse adjustment threshold Tc: When Δh > Tc, it is determined that the two regions are in different depth ranges, and a large Z-axis coarse adjustment command is inserted to complete the long-stroke transition. When Δh≤Tc, the drop is considered to be within the fine-tuning tolerance range. The position of the large Z-axis remains unchanged, and a small Z-axis fine-tuning command is inserted. Micrometer-level compensation is performed by issuing the small Z-axis fine-tuning command.
[0049] Understandably, this embodiment sets up a clear threshold decision mechanism in the process of converting the height matrix H into dual Z-axis commands. In this embodiment, the surface data is directly converted into executable motion code through the "difference-threshold-command" mapping, eliminating the need for secondary sampling or iterative focus testing, completely eliminating the "hunting" oscillation of the single Z-axis, increasing the first-time coarse adjustment success rate to 99%, shortening the average travel of the small Z-axis by 60%, and significantly improving the overall cycle time. At the same time, it reduces the mechanical wear and vibration caused by frequent starts and stops of the large mass axis (large Z-axis), achieving high-speed, high-precision, and low-wear autofocus.
[0050] In one possible implementation, step S3, which involves autofocusing based on a Z-axis coarse adjustment strategy, includes: Obtain the optimal focus plane Zbest(i,j) corresponding to the current region (i,j), and calculate the difference between the current large Z-axis position Zbig and the optimal focus plane Zbest(i,j): ΔZ = Zbest(i,j) Zbig; If |ΔZ| ≤ Tc, it is considered to be in place, so skip the coarse adjustment step of the large Z-axis and proceed to the fine adjustment step of the small Z-axis; If |ΔZ|>Tc, the large Z-axis moves a distance ΔZ in a closed loop at a preset speed. After reaching the target position, the laser focusing sensor performs a secondary verification to ensure that the actual distance matches the target.
[0051] This embodiment provides a closed-loop control chain in the coarse adjustment execution stage, limiting long-stroke motion to triggering only when truly needed, avoiding unnecessary back-and-forth movements. At the same time, closed-loop feedback eliminates the endpoint error caused by lead screw backlash and load deformation, ensuring that the coarse adjustment stage is completed in one go. The fine adjustment window is always kept within the range of micro-stroke deviation, providing a stable starting point for subsequent high-speed peak finding of the small Z-axis, and significantly reducing the overall focusing cycle time and mechanical impact.
[0052] In one possible implementation, step S3, which involves autofocusing based on a Z-axis fine-tuning strategy, includes: The small Z-axis carries the camera-objective assembly in the fine-tuning window. Within the range, the system moves back and forth to sample using an initial step distance, simultaneously acquiring images of the surface of the target object and calculating the sharpness evaluation value Q; The movement step size and direction of the small Z-axis are adaptively adjusted according to the changing trend of the sharpness evaluation value Q until it is determined that the sharpness evaluation value Q has entered the peak region. For example, if Q increases monotonically, the movement is accelerated in the same direction. If it decreases, the movement is reversed immediately and the step size is halved until the step size is reduced to below the threshold and the change of Q tends to zero, at which point it is determined that the value has entered the peak region. Sharpness evaluation values Q are collected from multiple points in the peak region, and a quadratic polynomial fitting is performed to obtain the theoretical maximum value position z*. The small Z-axis is then moved to the theoretical maximum value position z* to complete fine focusing.
[0053] In this embodiment, an adaptive hill-climbing combined with a quadratic fitting dual-mode optimization strategy is constructed during the small Z-axis fine-tuning execution stage. This strategy first uses a coarse step size to quickly approximate the peak region, and then uses an analytical curve to accurately locate it, avoiding the oscillation overshoot near the peak in traditional hill-climbing. At the same time, it uses the fitted extreme value to replace the single-point maximum, effectively suppressing misjudgments caused by image noise, so that the fine-tuning stage maintains both high speed and sub-micron level repeatability positioning accuracy, ensuring that the image clarity within the high-magnification microscopic depth of field is always at the optimal peak.
[0054] In one possible implementation, after step S3, the method further includes: after completing the global focus of the pre-scanned image, re-acquiring a full-frame image and traversing each region in the full-frame image to verify whether the sharpness of each region reaches the preset value.
[0055] For example, for a newly acquired full-frame image, the sharpness is calculated area by area using the same m×n grid and compared with a preset threshold. If an area is found to be below the threshold, the small Z-axis fine-tuning is immediately performed in that area until the full-frame image meets the standard.
[0056] Understandably, this embodiment adds a closed-loop verification step after full-field focusing is completed. By combining a single-image re-inspection with local readjustment, the single-focusing result is reviewed under a unified evaluation standard. This can compensate for focus shifts caused by temperature drift, vibration, or workpiece micro-deformation, eliminate local missed adjustments or illusory peaks, and achieve true full-field consistent clarity. This provides a traceable and reliable image basis for subsequent defect detection, measurement, or laser processing, while avoiding cycle time loss and missed detection risks caused by manual sampling.
[0057] In one possible implementation, after step S3, the method further includes: after completing global focusing of the pre-scanned image, the large Z-axis returns to a preset safe position, and the focusing history file of the measured target surface is uploaded. The focusing history file includes at least the focusing position and image data of each region in the full-frame image.
[0058] Understandably, this embodiment performs a safety zeroing and history upload action after all areas have passed verification. For example, the large Z-axis automatically returns to the preset safety position to avoid collisions between the lens and other equipment or workpieces. At the same time, the system controller or focus controller packages data such as the optimal focus surface, final focus height, peak sharpness evaluation value, and corresponding image index for each area into a focus history file, which is then uploaded to the factory database via the MES interface. This embodiment binds the "position-image-quality" three-dimensional data chain to the product ID to achieve full-process digital traceability. Subsequent defect detection, laser processing, or rework can directly call the focus coordinates at that time without refocusing, saving refocusing time and providing a complete chain of evidence for process anomaly analysis, equipment maintenance, and quality auditing, significantly improving the intelligence level of the production line and production management efficiency.
[0059] Please see Figure 4 , Figure 4 This is a schematic diagram illustrating an embodiment of the electronic device provided in this invention. For example... Figure 4 As shown, this embodiment of the invention provides an electronic device 400, including a memory 410, a processor 420, and a computer program 411 stored in the memory 410 and executable on the processor 420. When the processor 420 executes the computer program 411, it performs the following steps: S1, pre-scan the three-dimensional image of the surface of the target to be tested, and analyze the height change of the three-dimensional image and the optimal focus position based on the image processing algorithm; S2, based on the image analysis results, assign a coarse adjustment strategy in the Z-axis to the large Z-axis and a fine adjustment strategy in the Z-axis to the small Z-axis; S3 uses a Z-axis coarse adjustment strategy and a Z-axis fine adjustment strategy for autofocus.
[0060] Please see Figure 5 , Figure 5This is a schematic diagram illustrating an embodiment of a computer-readable storage medium provided by the present invention. (See diagram below.) Figure 5 As shown, this embodiment provides a computer-readable storage medium 500 on which a computer program 411 is stored. When the computer program 411 is executed by a processor, it performs the following steps: S1, pre-scan the three-dimensional image of the surface of the target to be tested, and analyze the height change of the three-dimensional image and the optimal focus position based on the image processing algorithm; S2, based on the image analysis results, assign a coarse adjustment strategy in the Z-axis to the large Z-axis and a fine adjustment strategy in the Z-axis to the small Z-axis; S3 uses a Z-axis coarse adjustment strategy and a Z-axis fine adjustment strategy for autofocus.
[0061] This invention provides a depth vision-based dual Z-axis autofocus system, method, electronic device, and storage medium. Combining depth vision pre-scanning and a hierarchical closed-loop control scheme for the large and small Z axes, the system first projects a coded pattern onto the surface under test using a 3D vision inspection instrument and performs phase unwrapping to obtain a full-scale surface shape depth map in one operation. Then, after region division, histogram truncation, depth-of-field offset, and smoothing compatibility calculations, the theoretical optimal focus surface Zbest for each region is generated and compared with adjacent height differences, automatically assigning coarse adjustment commands for the large Z-axis or fine adjustment commands for the small Z-axis. After the large Z-axis reaches its target position with a long-stroke closed loop, the small Z-axis adaptively climbs and searches for peaks within a micro-window and uses quadratic curve fitting to lock the true peak position zfocus, simultaneously recording the peak sharpness Qpeak. After full-field verification is successful, the large Z-axis returns to a safe position, and a focus history file containing Zbest, zfocus, and Qpeak is uploaded, achieving full digital traceability.
[0062] This invention combines surface shape measurement and focusing into one process. The coarse and fine axes respectively handle long strokes and micro-displacements, avoiding single Z-axis inertial vibration and repeated hunting, significantly shortening cycle time, improving repeatability accuracy, and eliminating misjudgments caused by high reflection or steps. This allows warped, thin, and microstructured complex surfaces to obtain consistent and clear imaging results on high-speed production lines. At the same time, it provides a reusable focus data chain for subsequent defect detection, laser processing, and quality auditing.
[0063] It should be noted that the descriptions of each embodiment in the above embodiments have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0064] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0065] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0066] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0067] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0068] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0069] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A dual Z-axis autofocus system based on depth vision, characterized in that, It includes a large Z-axis, a small Z-axis, and a vision inspection component. The vision inspection component is vertically and flexibly mounted on the small Z-axis, and the small Z-axis is vertically and flexibly mounted on the large Z-axis, wherein: The visual inspection component is used to pre-scan a three-dimensional image of the surface of the target being tested, and based on the depth analysis results of the three-dimensional image, to assign a coarse adjustment strategy in the Z-axis to the large Z-axis and a fine adjustment strategy in the Z-axis to the small Z-axis. The large Z-axis is used to adjust the small Z-axis and the Z-axis position of the visual detection component according to the Z-axis coarse adjustment strategy. The small Z-axis is used to adjust the Z-axis position of the visual detection component according to the Z-axis fine-tuning strategy.
2. A dual Z-axis autofocus method based on depth vision, characterized in that, Applied to the system as described in claim 1, the method includes: A three-dimensional image of the surface of the target under test is pre-scanned, and the height change of the three-dimensional image and the optimal focus position are analyzed based on the image processing algorithm; Based on the image analysis results, a coarse adjustment strategy in the Z-axis is assigned to the large Z-axis and a fine adjustment strategy in the Z-axis is assigned to the small Z-axis. Automatic focusing is performed based on Z-axis coarse adjustment and Z-axis fine adjustment strategies.
3. The dual Z-axis autofocus method based on depth vision according to claim 2, characterized in that, The pre-scanned three-dimensional image of the target surface includes: A detection light with a depth detection pattern is projected onto the surface of the target being tested, and a three-dimensional image of the target being tested with the depth detection pattern is acquired simultaneously, wherein the depth detection pattern is stripes, grids, or dot matrix.
4. The dual Z-axis autofocus method based on depth vision according to claim 2, characterized in that, The analysis of the height changes and optimal focus position of the 3D image based on the image processing algorithm includes: The 3D image is converted into a depth map based on an image processing algorithm; The depth map is divided into m×n regions, and the average height of each region is calculated to generate a height matrix H; The optimal focusing surface Zbest(i,j) for each region is calculated based on the height matrix H. Traverse the height matrix H in a preset order and calculate the height difference between adjacent regions in the height matrix H.
5. A dual Z-axis autofocus method based on depth vision according to claim 2 or 4, characterized in that, The image processing algorithm is either a phase unwrapping algorithm or a triangulation algorithm.
6. The dual Z-axis autofocus method based on depth vision according to claim 4, characterized in that, The process of converting the 3D image into a depth map based on the image processing algorithm includes: Phase unwrapping calculation is performed on each pixel of the three-dimensional image to obtain the absolute phase map Φ(x,y); The absolute phase map Φ(x,y) is converted into a depth map D(x,y) based on the system calibration coefficients, and the depth map D(x,y) is then subjected to median filtering to remove isolated noise points.
7. The dual Z-axis autofocus method based on depth vision according to claim 4, characterized in that, The method of assigning a coarse Z-axis adjustment strategy to the large Z-axis and a fine Z-axis adjustment strategy to the small Z-axis based on image analysis results includes: Compare the height difference Δh between adjacent regions in the height matrix H with the coarse adjustment threshold Tc: When Δh > Tc, insert a coarse adjustment command for the large Z-axis. When Δh≤Tc, keep the large Z-axis position unchanged and insert the small Z-axis fine-tuning command.
8. The dual Z-axis autofocus method based on depth vision according to claim 7, characterized in that, Autofocus based on Z-axis coarse adjustment strategy includes: Obtain the optimal focus plane Zbest(i,j) corresponding to the current region (i,j), and calculate the difference between the current large Z-axis position Zbig and the optimal focus plane Zbest(i,j): ΔZ = Zbest(i,j) Zbig; If |ΔZ| ≤ Tc, then skip the coarse adjustment step of the large Z-axis and proceed to the fine adjustment step of the small Z-axis; If |ΔZ| > Tc, then the large Z-axis moves a closed loop distance ΔZ at a preset speed.
9. A dual Z-axis autofocus method based on depth vision according to claim 7 or 8, characterized in that, Autofocus based on Z-axis fine-tuning strategy includes: The small Z-axis carries the camera-objective assembly in the fine-tuning window. Within the range, the target surface is moved at an initial step distance, and images are simultaneously acquired and the sharpness evaluation value Q is calculated. The movement step size and direction of the small Z-axis are adaptively adjusted according to the changing trend of the sharpness evaluation value Q until it is determined that the sharpness evaluation value Q has entered the peak region. Sharpness evaluation values Q are collected from multiple points in the peak region, and a quadratic polynomial fitting is performed to obtain the theoretical maximum value position z*. The small Z-axis is then moved to the theoretical maximum value position z* to complete fine focusing.
10. A dual Z-axis autofocus method based on depth vision according to claim 2, characterized in that, Also includes: After completing global focusing on the pre-scanned image, a new full-frame image is acquired, and each region in the full-frame image is traversed to verify whether the sharpness of each region meets the preset value.