An automatic focusing positioning system of an optical detector based on machine vision

By combining multimodal image acquisition and composite fitness calculation with focus weight iterative optimization, the failure of traditional autofocus methods on subwavelength structural samples is solved, achieving efficient and accurate autofocus positioning, which is suitable for industrial online inspection.

CN123145482APending Publication Date: 2026-11-20SHANDONG LEICAI ECONOMIC & TRADING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610426699.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-02
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Traditional autofocus methods suffer from low imaging contrast and complex image grayscale distribution when dealing with subwavelength structural samples. This results in multi-peak, flat, or non-monotonic evaluation functions that cannot reliably indicate the optimal focal plane, leading to focusing failure and severely impacting high-precision and high-efficiency online detection.

Method used

A multimodal image acquisition module is used to acquire images under different imaging conditions to construct a multimodal image set. A composite fitness calculation module integrates multiple sharpness evaluation indicators, and a focus weight iterative optimization module dynamically adjusts the weights to determine the optimal focus position. The sample is then located through a positioning execution module.

Benefits of technology

It achieves high-speed, high-precision, and high-robust autofocus and positioning on subwavelength structural samples, solving the failure problem of traditional methods under low contrast and complex interference, and improving detection efficiency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123145482A_ABST
    Figure CN123145482A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of industrial vision, and particularly relates to an automatic focusing positioning system of an optical detector based on machine vision, comprising a multi-modal image acquisition module, a composite fitness calculation module, a focal point weight iterative optimization module, an optimal focal point determination module and a positioning execution module, the multi-modal image acquisition module is used for selecting multiple discrete acquisition positions on the Z-axis of the optical detector; multi-dimensional information is acquired through the multi-modal image acquisition to cope with low contrast and complex interference, a robust composite fitness evaluation is constructed by using multi-source definition index fusion to overcome the problem of traditional single index failure, and the optimal focal point is stably locked in the multi-peak or flat response through dynamic iterative optimization, so that the problems of misalignment, failure and low speed in the automatic focusing of sub-wavelength structure samples are systematically solved without expensive hardware upgrade, and automatic focusing positioning with high precision, high robustness and millisecond speed is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of industrial vision, and more particularly to an automatic focusing and positioning system for an optical inspection instrument based on machine vision. Background Technology

[0002] Industrial online optical inspection is a key technology for achieving quality control in precision manufacturing. Autofocus is the primary step in ensuring clear imaging and accurate measurement. Currently, mainstream autofocus methods rely on single-channel sharpness evaluation functions such as "maximum image contrast" or "maximum image gradient." These methods are based on a core assumption: the feature size of the sample structure is greater than or close to the diffraction limit of the optical imaging system. Under this condition, the sample's geometric contours can effectively modulate light intensity, resulting in a significant and easily optimized single-peak curve in the image sharpness evaluation function during the defocus-focus-defocus process. The system can then quickly search for the peak position to determine the optimal focal plane.

[0003] However, with the rapid development of semiconductors, nanomaterials, and biosensing, the samples to be tested often contain subwavelength structures with feature sizes much smaller than the detection wavelength, such as quantum dots, nanopores, and metasurface structures. In this technological context, traditional focusing methods face fundamental failure. First, due to the diffraction limit, the imaging contrast of these nanostructures is extremely low, resulting in a poor image signal-to-noise ratio. Second, in the near-field region, complex interference and diffraction effects cause the image grayscale distribution to no longer simply correspond to the sample morphology. This makes the traditional sharpness evaluation functions (such as gradient and variance) based on grayscale statistics exhibit multi-peak, flat, or non-monotonic characteristics, failing to reliably indicate a unique optimal focal plane. This blindness directly leads to focusing failure, severely restricting high-precision, high-efficiency online detection in related fields. Summary of the Invention

[0004] To address the technical problems existing in the background art, this invention proposes an automatic focusing and positioning system for optical inspection instruments based on machine vision, the specific solution of which is as follows: An automatic focusing and positioning system for an optical inspection instrument based on machine vision, comprising: Multimodal image acquisition module: used to select multiple discrete acquisition positions on the Z-axis of the optical detector; based on each acquisition position, acquire images obtained under at least two imaging conditions, and construct a multimodal image set for each acquisition position; Composite fitness calculation module: For each acquisition location, a composite fitness value is calculated based on the multimodal image set corresponding to the acquisition location; the composite fitness value is obtained by weighted fusion of at least two different types of sharpness evaluation indicators; Focus weight iterative optimization module: used to set multiple candidate focus positions and their initial weights; based on the composite fitness value of each collection position calculated by the composite fitness calculation module, the weights of the multiple candidate focus positions are iteratively calculated in multiple rounds until the preset convergence condition is met, and the weight distribution of the multiple candidate focus positions is obtained. Optimal focus determination module: Based on the weight distribution, obtain the candidate focus position corresponding to the maximum weight and set it as the final focus position; Positioning execution module: used to control the optical detector to move to the final focusing position, perform image acquisition, and complete the positioning of the sample in the X-axis and Y-axis planes.

[0005] Furthermore, in the multimodal image acquisition module, the at least two imaging conditions are as follows: the imaging conditions include: different optical bands, different polarization states, different illumination modes, and different defocus amounts.

[0006] Furthermore, the multimodal image acquisition module specifically includes: In the Z-axis range Within, N discrete acquisition locations are selected based on preset intervals. , where i = 1…N, and N is an integer greater than 1; At each collection location At this location, images are acquired synchronously based on imaging conditions; The acquisition location is constructed based on the synchronously acquired images. The corresponding multimodal image set; The preset interval ranges from 2µm to 10µm.

[0007] Furthermore, images are acquired synchronously based on imaging conditions, as follows: The following images are acquired: a) One image in the visible light band and one image in the near-infrared band; b, Two linearly polarized images with mutually orthogonal illumination polarization directions; c, A random speckle illumination image formed by a digital micromirror device or a transmission mask; d, by position Based on the baseline, two images are acquired after being offset by a preset distance Δz in the positive and negative directions, respectively, where the value of Δz ranges from 0.5µm to 2µm.

[0008] Furthermore, in the composite fitness calculation module, the at least two different types of sharpness evaluation metrics are as follows: sharpness evaluation metrics include: metrics based on image physical characteristics, metrics based on image statistical features, and metrics based on information theory methods.

[0009] Furthermore, in the composite fitness calculation module, the composite fitness value is obtained by weighted fusion of at least two different types of sharpness evaluation metrics, as follows: Based on the sharpness evaluation index, the index based on image physical characteristics, the index based on image statistical features, and the index based on information theory methods are normalized to the same numerical range through a normalization algorithm, and corresponding three index values ​​are generated. Based on the above three index values, a weighted summation algorithm is used to obtain the composite fitness value according to the preset weight coefficients α, β, and γ. , where α+β+γ=1; The initial values ​​of α, β, and γ are 0.4, 0.4, and 0.2, respectively.

[0010] Furthermore, the focus weight iterative optimization module specifically includes the following: The Z-axis range M positions are selected at equal intervals as candidate focal positions, and each candidate focal position is assigned the same initial weight, wherein the value of M is greater than 1 and less than or equal to 15, and M is an integer; Perform weight iteration update: obtain the composite fitness value of each acquisition position, and perform multiple rounds of iterative calculation on the weights of the M candidate focal positions through the replicating sub-equation; After each round of weight iteration and update, calculate the Shannon entropy of all current weights.

[0011] Compared with the prior art, the present invention can achieve at least the following beneficial effects: 1. This invention constructs a multimodal image set by acquiring images under different imaging conditions. Using at least two different types of sharpness evaluation metrics, a composite fitness value is built, enabling more reliable identification of signals truly corresponding to the optimal focal plane in complex responses. Multiple candidate focal positions are weighted according to their composite fitness values. This effectively suppresses spurious peaks generated by random noise or fixed interference patterns, causing weight resources to concentrate on truly high-quality imaging regions. Thus, in complex response curves with multiple interference extrema, it stably and accurately converges to the optimal focal region. This systematically solves a series of technical problems in subwavelength sample autofocus, such as low contrast, strong noise interference, evaluation function failure, and slow search speed. It achieves high-speed, high-precision, and highly robust autofocus and positioning, significantly improving the efficiency and reliability of online optical inspection in related fields.

[0012] 2. This invention acquires multi-dimensional information through multimodal image acquisition to address low contrast and complex interference. It utilizes multi-source sharpness index fusion to construct a robust composite fitness evaluation to overcome the failure problem of traditional single index. Through dynamic iterative optimization, it stably locks the optimal focus in multi-peak or flat responses. Thus, without the need for expensive hardware upgrades, it systematically solves the problems of inaccuracy, failure, and low speed in autofocusing of subwavelength structural samples, achieving autofocus positioning that balances high precision, high robustness, and millisecond-level speed. Attached Figure Description

[0013] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein: Figure 1 This is a system principle block diagram of the present invention. Detailed Implementation

[0014] Embodiments of the present invention are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar symbols denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0015] Please refer to Figure 1 As shown, the present invention provides an automatic focusing and positioning system for an optical inspection instrument based on machine vision, including a multimodal image acquisition module, a composite fitness calculation module, a focus weight iterative optimization module, an optimal focus determination module, and a positioning execution module; A multimodal image acquisition module is used to select multiple discrete acquisition positions on the Z-axis of an optical detector; based on each acquisition position, images are acquired under at least two imaging conditions to construct a multimodal image set for each acquisition position; It should be noted that the multimodal image acquisition module is the foundation for achieving high-speed, high-precision autofocus. At the same Z-axis position ( At a location, multiple images reflecting different physical properties of the sample are acquired simultaneously or sequentially within a very short time, forming a "multimodal image set" for that location. This approach aims to overcome the inherent shortcomings of traditional single-frame images, such as insufficient information, low contrast, and susceptibility to noise interference when dealing with subwavelength samples like quantum dots and nanostructures.

[0016] In the multimodal image acquisition module, the at least two imaging conditions are as follows: the imaging conditions include: different optical bands, different polarization states, different illumination modes, and different defocus amounts.

[0017] It should be noted that the different optical bands are specifically: This condition refers to acquiring images in the visible light band (typically 400-700 nm) and the near-infrared band (typically 700-1100 nm) at the same location. The interaction between light of different wavelengths and nanostructures varies: shorter wavelengths of visible light are more sensitive to surface morphology and smaller size features, while longer wavelengths of near-infrared light have stronger penetrating power and a more pronounced response to subsurface or deep structures. For samples such as quantum dots and certain nanomaterials, their scattering or absorption characteristics may be wavelength-dependent. By simultaneously acquiring dual-band images and calculating the multispectral scattering index, response information from different scales can be effectively integrated, avoiding evaluation inaccuracies caused by weak signals in a single band or interference from specific noise, and enhancing the robustness of the fitness function.

[0018] The different polarization states are as follows: This condition refers to acquiring two linearly polarized images (e.g., 0° and 90° linear polarization) with mutually orthogonal polarization directions in the illumination or imaging light path. Many nanostructures (such as anisotropic nanowires and semiconductor structures with specific crystal orientations) are polarization sensitive, meaning they exhibit different scattering and diffraction efficiencies for incident light with different polarization directions. Acquiring orthogonal polarization images and calculating their polarization contrast allows for the extraction of polarization-related anisotropic information about the sample. This information is independent of traditional intensity images, providing a novel and independent physical observation dimension for sharpness evaluation, and is particularly helpful in enhancing the focusing response of nanostructures with regular orientations or anisotropic characteristics.

[0019] The different lighting modes are as follows: This condition specifically refers to acquiring images using a random speckle illumination mode, typically achieved by rapidly generating random patterns to provide structured illumination of the sample using a digital micromirror device (DMD) or a transmission mask. Compared to uniform illumination, random speckle illumination offers two key advantages: first, its high-frequency spatial components can more effectively excite the sample's weak scattering signals, especially for objects with weak phase or amplitude; second, the randomly varying illumination pattern can modulate and break the fixed fringe pattern generated by near-field interference, helping to suppress coherent noise. By analyzing image sequences acquired under different random illumination modes (calculating mutual information approximations), information related to the sample's structure but unrelated to fixed interference noise can be extracted, thereby improving focusing accuracy in environments with strong interference.

[0020] The different defocus amounts are as follows: This condition refers to the nominal focus position. Two images are acquired by offsetting by a small distance Δz (typically 0.5-2µm) in both positive and negative directions, along with... An image at a given location, together forming a sequence of images with known differences in defocus, forms the basis for non-interferometric phase retrieval. According to the Transmission Intensity Equation (TIE), this image sequence contains phase information about the light wave after passing through the sample. By solving the TIE, the phase distribution caused by the sample can be calculated, and thus the phase curvature can be obtained. Phase information is highly sensitive to the sample's refractive index distribution and ultrathin structure, and is unaffected by uniform absorption. Therefore, phase curvature, as a physical indicator, provides an extremely effective basis for focusing evaluation of transparent, weakly absorbing, or purely phase-dependent nanomaterials (such as microlens arrays and certain biological samples), compensating for the shortcomings of traditional intensity-contrast methods.

[0021] By synchronously or rapidly switching between acquiring at least two types of images, this method constructs a multimodal image set that comprehensively "perceives" the sample from multiple physical dimensions such as spectrum, polarization, illumination, and phase. This lays a solid data foundation for the subsequent generation of a composite fitness function with strong anti-interference and high discriminative power, thereby fundamentally solving the technical problem of the failure of traditional single-channel evaluation functions when facing nanoscale samples.

[0022] The multimodal image acquisition module specifically includes: In the Z-axis range Within, N discrete acquisition locations are selected based on preset intervals. , where i = 1…N, and N is an integer greater than 1; At each collection location At this location, images are acquired synchronously based on imaging conditions; The acquisition location is constructed based on the synchronously acquired images. The corresponding multimodal image set; The preset interval ranges from 2µm to 10µm.

[0023] It should be noted that the phrase "for selecting multiple discrete acquisition positions on the Z-axis of the optical detector" refers to a search range along the Z-axis that is expected to contain the optimal focus. This invention employs sparse sampling within a certain range. Unlike traditional dense "full-stack scanning," this invention uses a sparse sampling strategy, where N is typically small, for example, 5-20, and the preset interval between adjacent sampling positions is 2µm to 10µm. This interval range is chosen based on empirical values ​​set according to the approximate depth of field and positioning accuracy requirements of common samples in industrial inspection. Too small an interval leads to redundant sampling points, increasing unnecessary acquisition time; too large an interval may miss the optimal focal region. For example, for a microscope objective with a numerical aperture (NA) of 0.8, its depth of field is typically in the submicron range. Setting a sampling interval of 2-10µm ensures a sufficient number of sampling points within the search range to capture focal information while maintaining high speed.

[0024] Images were acquired synchronously based on imaging conditions, as follows: The following images were acquired: a) One image in the visible light band and one image in the near-infrared band; b, Two linearly polarized images with mutually orthogonal illumination polarization directions; c, A random speckle illumination image formed by a digital micromirror device or a transmission mask; d, by position Based on the baseline, two images are acquired after being offset by a preset distance Δz in the positive and negative directions, respectively, where the value of Δz ranges from 0.5µm to 2µm.

[0025] It should be noted that the "at least two imaging conditions" and the four types of images (a, b, c, and d) acquired each provide complementary information dimensions to address specific challenges in imaging nanoscale samples: a. Images in different optical bands (visible and near-infrared): Due to the different scattering and absorption characteristics of nanostructures to different wavelengths of light, dual-band imaging can acquire richer information about materials and morphology. Near-infrared light is more sensitive to certain semiconductor materials or deep structures, and its images can serve as an effective supplement to visible light images.

[0026] b. Orthogonal linearly polarized images: Many nanostructures exhibit optical anisotropy. Acquiring two images with orthogonal polarization directions allows the intensity difference (polarization contrast) to reflect the anisotropy of the sample's orientation or shape. This information is independent of the overall brightness or texture of the image, providing an independent physical criterion for focusing.

[0027] c. Random speckle illumination image: The sample is illuminated by rapid projection of random patterns using a digital micromirror device (DMD). This non-uniform, high-frequency illumination effectively modulates the weak signal of the sample and breaks up the fixed-pattern near-field interference fringes (a major source of noise) caused by a coherent light source. Therefore, this image helps to extract the true sample signal against a noisy background.

[0028] d, Slightly out-of-focus image pairs ( ±Δz: This is crucial for achieving non-interfering phase retrieval. Two images are acquired by symmetrically offsetting the focal position by a small distance Δz (0.5-2µm). Combining these two images at the focal position provides the data needed to solve the Intensity Transmission Equation (TIE). Solving the TIE yields the phase distribution of the sample, and phase information is extremely sensitive to transparent, weakly absorbing nanostructures (such as microlenses and certain biological samples). The selection of the Δz value requires a trade-off between the sensitivity and linearity of phase retrieval; it is typically set slightly less than the system depth of focus to ensure a measurable intensity change between the defocused and focused images, while simultaneously satisfying the linear approximation condition of the TIE.

[0029] It should be noted that the "synchronous acquisition" of the images mentioned above refers to acquiring them as close as possible in time to ignore possible drift from the sample or environment. In actual hardware implementation, a set of multimodal images can be acquired within milliseconds through techniques such as beam splitting, filter wheels, polarizer wheels, and rapid switching of DMD. The "multimodal image set" constructed in this way is no longer a single data point, but a comprehensive dataset containing multi-dimensional information such as spectrum, polarization, illumination structure, and three-dimensional intensity gradient (for phase retrieval), laying a solid foundation for subsequent robust sharpness evaluation.

[0030] Composite fitness calculation module: For each acquisition location, a composite fitness value is calculated based on the multimodal image set corresponding to the acquisition location; the composite fitness value is obtained by weighted fusion of at least two different types of sharpness evaluation indicators; It should be noted that the composite fitness calculation module is the core of the decision-making process. Its purpose is to provide a composite fitness calculation module for each data acquisition location. A single, comprehensive score—the composite fitness value—is calculated and serves as the sole criterion for determining the "survival of the fittest" among candidate focal positions in subsequent competitive iterations. Traditional methods rely on a single sharpness evaluation function (such as gradient or variance), which is highly susceptible to failure due to noise or spurious signals when dealing with nanoscale samples. This invention constructs a highly robust composite evaluation standard by integrating multiple independent sharpness evaluation metrics from different principles.

[0031] It should be noted that weighted fusion is the specific mathematical method for achieving indicator fusion. Because the calculation methods, dimensions, and numerical ranges of different indicators vary greatly (for example, phase curvature might be on the order of 0.01, while neural network scores are between 0 and 1), direct addition is meaningless. Therefore, it is necessary to first map each indicator value to the same numerical range (e.g., 0-1 or 0-100) using a normalization algorithm. A commonly used normalization method is min-max normalization. The normalized indicator values... , , In a comparable state, they represent the relative scores of physical sharpness, statistical sharpness, and information content at the current location, respectively.

[0032] In the composite fitness calculation module, the composite fitness value is obtained by weighted fusion of at least two different types of sharpness evaluation metrics, as follows: Based on the sharpness evaluation index, the index based on image physical characteristics, the index based on image statistical features, and the index based on information theory methods are normalized to the same numerical range through a normalization algorithm, and corresponding three index values ​​are generated. Based on the above three index values, a weighted summation algorithm is used to obtain the composite fitness value according to the preset weight coefficients α, β, and γ. , where α+β+γ=1; The initial values ​​of α, β, and γ are 0.4, 0.4, and 0.2, respectively.

[0033] It should be noted that the weighting coefficients α, β, and γ reflect the relative importance of the three types of indicators in the final decision. Their initial values ​​are set to α=0.4, β=0.4, and γ=0.2, which are empirical equilibrium points obtained from numerous experiments, assigning higher weights to physical and statistical indicators while retaining the moderating role of information theory indicators. This setting reflects the design philosophy of this invention, which emphasizes both prior physical knowledge and data-driven methods. More importantly, these weights are not fixed. Through methods such as Bayesian optimization, the system can dynamically adjust the weights online according to the specific sample type being detected (e.g., strong scattering or weak phase) and the level of environmental noise, achieving adaptive fusion and thus maintaining optimal performance in diverse real-world industrial scenarios.

[0034] It should be noted that the "at least two different types of sharpness evaluation indicators" are preferably the following three categories, which evaluate the "sharpness" or "information richness" of the image from different perspectives: Image-based physical properties indexes: These directly utilize the physical principles of optical imaging to extract quantitative features from multimodal images that are directly related to the physical properties of the sample.

[0035] Image statistical feature-based metrics: These metrics use data-driven methods to determine the sharpness of an image from its pixel statistical distribution or learned features.

[0036] Information theory-based metrics: From the perspective of information transmission, assess the amount of information (rather than noise) carried by an image about the sample itself.

[0037] These three types of metrics are complementary. Physical metrics are robust but may be insensitive in certain scenarios; statistical metrics are flexible but rely on training data; information-theoretic metrics are robust to noise but may be computationally complex. Combining them ensures that even if one metric temporarily fails, the system can still make reliable judgments based on the other metrics.

[0038] It should be noted that the weighted summation algorithm is as follows: ; : Indicates the position The values ​​of indices calculated based on the physical properties of the image (such as multispectral scattering index, polarization contrast, and phase curvature) are normalized.

[0039] : Indicates the position The value of the index (sharpness score output by a self-supervised neural network) calculated based on image statistical features is normalized.

[0040] : Indicates the position The value is the normalized value of the index (the approximate value of mutual information under random illumination) calculated based on information theory methods.

[0041] It should be noted that the weighted summation algorithm described above is the final formula for calculating the composite fitness value. The significance of this formula lies in the fact that it produces a single-valued summary of multi-dimensional information. For example, for an image containing sharp edges (high physical metrics) but affected by fixed stripe noise (information-theoretical metrics may be reduced due to noise correlation), its composite fitness value will weight-balance these two contradictory signals, thus obtaining a more impartial and stable evaluation than any single metric. The values ​​will be directly input into the subsequent ecological competition model, driving the entire focusing and optimization process. Through this fusion strategy, the present invention fundamentally avoids the risk of traditional methods falling into local extrema or completely failing due to reliance on a single evaluation function.

[0042] Focus weight iterative optimization module: used to set multiple candidate focus positions and their initial weights; based on the composite fitness value of each collection position calculated by the composite fitness calculation module, the weights of the multiple candidate focus positions are iteratively calculated in multiple rounds until the preset convergence condition is met, and the weight distribution of the multiple candidate focus positions is obtained. It should be noted that the "Focus Weight Iterative Optimization Module" receives multi-dimensional evaluations (composite fitness values) from various positions from the composite fitness calculation module and outputs a probability distribution (weight distribution) that clearly points to the optimal focus.

[0043] The focus weight iterative optimization module specifically includes the following: The Z-axis range M positions are selected at equal intervals as candidate focal positions, and each candidate focal position is assigned the same initial weight, wherein the value of M is greater than 1 and less than or equal to 15, and M is an integer; Perform weight iteration update: obtain the composite fitness value of each acquisition position, and perform multiple rounds of iterative calculation on the weights of the M candidate focal positions through the replicating sub-equation; It should be noted that when initializing candidate focal points, M positions are selected at equal intervals within the Z-axis search range as the "candidate population," for example, 5 to 15. The number M is less than the number of acquisition positions N in the multimodal image acquisition module. This reflects the idea of ​​secondary optimization: first, the entire range is quickly scanned through sparse sampling (multimodal image acquisition module) and composite evaluation (composite fitness calculation module); then, based on this information, a few promising candidate points are focused on for refined competitive evolution. The initial weights are all set to 1 / M, meaning that all candidate points are considered equally important at the beginning, laying the foundation for subsequent "fair competition."

[0044] It should be noted that the replicon equation is: , in, This represents the weight of the i-th candidate focus position in the t-th iteration; Δt is the iteration step size, with a value of 0.5; , where represents the competition coefficient between the i-th and j-th candidate focal positions; This is the attenuation constant, with a value ranging from 5µm to 15µm; This represents summing over all j candidate focus positions except for i; It should be noted that, This indicates that the weight increase of candidate point i is related to its current weight. and its fitness Proportional. The higher the value (indicating better image quality at that location), the faster it "reproduces" or "expands".

[0045] Distance between two candidate points on the Z-axis The closer, The larger the value, the more intense the competition for the same "niche" (optimal focus). Decay constant (Typically set to 5-15µm, matching the system's depth of field and sampling interval) controls the rate at which the competitive effect decays with distance. This ensures that a clear "dominance region" forms around the ultimately winning focal position, while the weight of positions far from it is quickly suppressed.

[0046] Iteration step size Δt: Set to 0.5, it is an empirical parameter that ensures stable numerical calculations and a reasonable convergence speed.

[0047] Through iterative replication of the sub-equations (e.g., up to 20 rounds, with each round having extremely short simulation time), the system achieves a dynamic process of survival of the fittest, where the strong become stronger: candidate points with good imaging quality (high fitness) and few surrounding competitors will have their weights rapidly increased; while points with poor quality or surrounded by strong competition will have their weights decayed. This process can effectively suppress spurious focal points (isolated "strong" points) caused by noise, because although spurious focal points may score high on a certain metric, their fitness is the result of fusing multiple metrics, usually lacking a comprehensive advantage, and lacking real spatial continuity support, making it difficult to maintain in continuous competitive iterations.

[0048] After each round of weight iteration update, the Shannon entropy of all current weights is calculated; wherein, until the preset convergence condition is met, as follows: the Shannon entropy H is less than the preset entropy threshold of 0.25, or the number of iteration rounds reaches the preset maximum number of iterations of 20.

[0049] It should be noted that the formula for calculating Shannon entropy is: Convergence is determined using Shannon entropy. Shannon entropy is a metric in information theory for measuring uncertainty. During the weight iteration process: initially, all weights are equal, uncertainty is greatest, and the entropy value is highest (approximately lnM).

[0050] As the iteration progresses, the weight of the advantageous candidate points increases continuously, while the weight of other points decreases. The weight distribution changes from "uniform" to "concentrated," reducing uncertainty and decreasing entropy.

[0051] When the entropy H drops below the preset threshold of 0.25, it indicates that the system has reached a high degree of "consensus" on the optimal focal position, and iteration can stop. Simultaneously, a maximum number of iterations (20 times) is set as a safety limit to prevent the algorithm from getting stuck in a loop or converging too slowly in extreme cases. This dual convergence condition ensures that the algorithm is both efficient and robust.

[0052] Ultimately, the weight distribution output by the system is a highly concentrated probability distribution, where the candidate point corresponding to the maximum weight is the optimal focus "evolved" by the algorithm. This fundamentally changes the traditional focusing algorithm's passive "search" mode for peaks, transforming it into an active, dynamic, and collectively intelligent "competitive optimization" mode, which is particularly suitable for complex scenarios with multiple interfering peaks.

[0053] Optimal focus determination module: Based on the weight distribution, obtain the candidate focus position corresponding to the maximum weight and set it as the final focus position; It should be noted that the "optimal focus determination module" is the step that extracts deterministic results from the dynamic competition process. Through the ecological competition iteration of the focus weight optimization module, the system has obtained a stable and concentrated weight distribution. The purpose here is to transform this probability distribution, which represents "group consensus," into a clear and executable mechanical instruction—the final focus position.

[0054] It's important to note that the method for determining the optimal focus directly selects the candidate focus position corresponding to the maximum value in the weight distribution. This seemingly simple operation relies entirely on the robustness of the focus weight iterative optimization module. Because the competition mechanism in the replicon equation effectively suppresses spurious peaks caused by noise and concentrates resources on the region with the highest fitness, the maximum weight value typically has a significant lead advantage after convergence (e.g., much higher than the second-highest weight). This ensures that the final selected focus position is not a random extreme value, but rather the "optimal" one verified through multiple rounds of competition. Directly reading this position eliminates the need for complex curve fitting or secondary judgments, aligning with the system's pursuit of "millisecond-level" speed.

[0055] Positioning execution module: used to control the optical detector to move to the final focusing position, perform image acquisition, and complete the positioning of the sample in the X-axis and Y-axis planes.

[0056] It should be noted that the "positioning execution module" is the final output and closed-loop component of the automatic focusing and positioning process. Its purpose is to accurately position the sample in the two-dimensional plane (XY plane) after obtaining the precise Z-axis focus position, thereby providing an accurate coordinate reference for subsequent detection, measurement, or operation.

[0057] It should be noted that, firstly, the Z-axis drive device of the optical inspection instrument (such as an electric stage) is moved to the final focus position determined by the optimal focus determination module. At this optimal focal plane, the system acquires a final high-quality image. Because this image is at the optimal focal plane, its contrast and detail information are the richest, providing the ideal data source for subsequent planar positioning.

[0058] It should be noted that XY plane localization based on this final image can be achieved using mature machine vision algorithms. For example: Standard template matching: If a sample has a known, unique feature pattern (such as alignment marks or specific repeating structures), its location can be determined by searching for the region in the image that is most similar to the template.

[0059] Subpixel corner or feature point detection algorithm: If the sample has clear corners or feature points, the algorithm can detect their positions and calculate their centroids with an accuracy of subpixel level.

[0060] The X and Y coordinates output by these positioning algorithms, combined with the known final focus position, together constitute the complete three-dimensional pose information of the sample in the current field of view.

[0061] The automatic focusing and positioning system described in this invention forms a complete logical closed loop: starting with multimodal sparse acquisition, followed by multi-source information fusion and evaluation, and then dynamic optimization through ecological competition, it ultimately determines and reaches the optimal focal plane, achieving precise two-dimensional positioning. The entire process, while ensuring high precision and robustness for nanoscale samples, achieves millisecond-level high-speed completion through algorithmic innovation rather than hardware stacking, fully meeting the stringent requirements of modern industrial online inspection.

[0062] In summary, multi-modal image acquisition acquires multi-dimensional information to address low contrast and complex interference. Multi-source sharpness index fusion is used to construct a robust composite fitness evaluation to overcome the failure problem of traditional single index. Dynamic iterative optimization is used to stably lock the optimal focus in multi-peak or flat responses. Thus, without the need for expensive hardware upgrades, the problems of inaccuracy, failure and low speed in autofocusing of subwavelength structural samples are systematically solved, achieving autofocus positioning that balances high precision, high robustness and millisecond-level speed.

[0063] Furthermore, any content not described in detail in this specification is existing technology known to those skilled in the art.

[0064] In the embodiments provided by this invention, it should be understood that the disclosed system or method can be implemented in other ways. For example, the embodiments of the invention described above are merely illustrative; for instance, the division of modules is only a logical functional division, and there may be other division methods in actual implementation.

[0065] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0066] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or in the form of hardware plus software functional modules.

[0067] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the basic characteristics of the present invention.

[0068] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. An automatic focusing and positioning system for an optical inspection instrument based on machine vision, characterized in that, include: Multimodal image acquisition module: used to select multiple discrete acquisition positions on the Z-axis of the optical detector; Based on each acquisition location, images obtained under at least two imaging conditions are acquired to construct a multimodal image set for each acquisition location; Composite fitness calculation module: For each acquisition location, a composite fitness value is calculated based on the multimodal image set corresponding to the acquisition location; the composite fitness value is obtained by weighted fusion of at least two different types of sharpness evaluation indicators; Focus weight iterative optimization module: used to set multiple candidate focus positions and their initial weights; Based on the composite fitness values ​​of each acquisition location calculated by the composite fitness calculation module, the weights of the multiple candidate focal locations are iteratively calculated in multiple rounds until the preset convergence condition is met, thereby obtaining the weight distribution of the multiple candidate focal locations. Optimal focus determination module: Based on the weight distribution, obtain the candidate focus position corresponding to the maximum weight and set it as the final focus position; Positioning execution module: used to control the optical detector to move to the final focusing position, perform image acquisition, and complete the positioning of the sample in the X-axis and Y-axis planes.

2. The automatic focusing and positioning system for an optical inspection instrument based on machine vision as described in claim 1, characterized in that: In the multimodal image acquisition module, the at least two imaging conditions are as follows: the imaging conditions include: different optical bands, different polarization states, different illumination modes, and different defocus amounts.

3. The automatic focusing and positioning system for an optical inspection instrument based on machine vision as described in claim 2, characterized in that: The multimodal image acquisition module specifically includes: In the Z-axis range Within, N discrete acquisition locations are selected based on preset intervals. , where i = 1…N, and N is an integer greater than 1; At each collection location At this location, images are acquired synchronously based on imaging conditions; The acquisition location is constructed based on the synchronously acquired images. The corresponding multimodal image set; The preset interval ranges from 2µm to 10µm.

4. The automatic focusing and positioning system for an optical inspection instrument based on machine vision as described in claim 3, characterized in that: Images were acquired synchronously based on imaging conditions, as follows: The following images were acquired: a) One image in the visible light band and one image in the near-infrared band; b, Two linearly polarized images with mutually orthogonal illumination polarization directions; c, A random speckle illumination image formed by a digital micromirror device or a transmission mask; d, by position Based on the baseline, two images are acquired after being offset by a preset distance Δz in the positive and negative directions, respectively, where the value of Δz ranges from 0.5µm to 2µm.

5. The automatic focusing and positioning system for an optical inspection instrument based on machine vision as described in claim 1, characterized in that: In the composite fitness calculation module, the at least two different types of sharpness evaluation metrics are as follows: sharpness evaluation metrics include: metrics based on image physical characteristics, metrics based on image statistical features, and metrics based on information theory methods.

6. The automatic focusing and positioning system for an optical inspection instrument based on machine vision as described in claim 5, characterized in that: In the composite fitness calculation module, the composite fitness value is obtained by weighted fusion of at least two different types of sharpness evaluation metrics, as follows: Based on the sharpness evaluation index, the index based on image physical characteristics, the index based on image statistical features, and the index based on information theory methods are normalized to the same numerical range through a normalization algorithm, and corresponding three index values ​​are generated. Based on the above three index values, a weighted summation algorithm is used to obtain the composite fitness value according to the preset weight coefficients α, β, and γ. , where α+β+γ=1; The initial values ​​of α, β, and γ are 0.4, 0.4, and 0.2, respectively.

7. The automatic focusing and positioning system for an optical inspection instrument based on machine vision as described in claim 3, characterized in that: The focus weight iterative optimization module specifically includes the following steps: The Z-axis range M positions are selected at equal intervals as candidate focal positions, and each candidate focal position is assigned the same initial weight, wherein the value of M is greater than 1 and less than or equal to 15, and M is an integer; Perform weight iteration update: obtain the composite fitness value of each acquisition position, and perform multiple rounds of iterative calculation on the weights of the M candidate focal positions through the replicating sub-equation; After each round of weight iteration and update, calculate the Shannon entropy of all current weights.