Fitting method for automatic and rapid zooming and focus following of ophthalmology camera

By rapidly calibrating the optimal focusing position of a zoom lens in an ophthalmic camera and utilizing the Lagrange nonlinear fitting method, the problem of rapid and high-precision automatic focusing in low-cost ophthalmic equipment was solved. This enabled precise calibration of the zoom-focus relationship curve in an extremely short time, improving diagnostic efficiency and accuracy.

CN120935456APending Publication Date: 2025-11-11YAMOU MEDICAL TECH (WUXI) CO LTD

Patent Information

Application Number
CN202511093016.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-28
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve fast and high-precision autofocus in low-cost ophthalmic imaging devices, especially in completing accurate calibration and real-time fitting of the zoom-focus relationship curve in a very short time. Furthermore, existing solutions typically require additional high-cost sensors or complex hardware.

Method used

By quickly calibrating the optimal focusing position of the zoom lens at a fixed object distance, a zoom-focus mapping relationship is constructed. The curve is reconstructed using the Lagrange nonlinear fitting method, and combined with the motor control system, fast and accurate automatic focusing is achieved.

Benefits of technology

Without increasing additional hardware costs, the ophthalmic camera achieved fast and high-precision automatic focusing during zooming, ensuring that the image remains clear at all times, improving diagnostic efficiency and accuracy, and reducing equipment costs and complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120935456A_ABST
    Figure CN120935456A_ABST
Patent Text Reader

Abstract

The invention discloses a fitting method for automatic and rapid zooming and focus following of an ophthalmic camera, and relates to the technical field of image processing and automatic focusing. According to the method, firstly, rapid calibration is carried out, a lens is initialized to a minimum zoom position, an optimal focus point is obtained through an automatic focusing algorithm, Zoom-Focus mapping data are sequentially collected at five sites from ZoomA to ZoomE, and calibration is completed within one second; secondly, on the basis of Lagrange nonlinear fitting, by taking an exponential function model as a target, constructing a Lagrange function, iteratively solving parameters through a Newton method, and reconstructing a complete Zoom-Focus curve by using five sampling points; and finally, during real-time zooming, positioning a nearest sampling point according to a current Zoom value, dynamically calculating an optimal Focus value through a fitted curve, and driving a focusing motor to adjust an image distance. According to the invention, high-precision focus following can be realized by only needing five sampling points, the cost is remarkably reduced, and the clear imaging requirement of real-time zooming in ophthalmic diagnosis is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing and autofocus technology, and in particular to a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera. Background Technology

[0002] In ophthalmological examinations, near-field (typically between 0.5cm and 10cm) visual imaging devices (such as fundus cameras and imaging modules of slit-lamp microscopes) are widely used to observe and diagnose eye health. To obtain different fields of view (such as a global view of the eyeball or a detailed view of the iris), doctors need to frequently adjust the camera lens zoom during the examination. However, zooming changes the image distance of the optical system, causing the originally clear image to become out of focus and blurry. Therefore, there is an urgent need for a technology that can automatically adjust the focus position in real time to match the current zoom position, ensuring that the image remains clear throughout the entire process of the doctor adjusting the zoom level. This is crucial for improving diagnostic efficiency and accuracy.

[0003] Chinese Patent CN119395852A, entitled "A Laser Automatic Focusing Method, Apparatus, and Device," provides a laser automatic focusing method, apparatus, and device applied in the field of laser focusing technology. The method includes: after acquiring the laser spot of the target object, determining the observation position of the laser spot in the current focusing cycle; based on the observation position, using a control strategy to perform initial focusing on the laser spot, determining the initial control signal of the mechanical axis in the current focusing cycle; using the historical control signal and observation position of the mechanical axis in the previous focusing cycle to correct the initial control signal, obtaining the target control signal of the mechanical axis, and using the target control signal to control the mechanical axis to adjust the optical elements. This allows for rapid response to changes in the position of the laser spot, quickly adjusting the axis position and speed of the mechanical axis to ensure the laser spot is always at the optimal focus. It primarily utilizes laser ranging for focusing.

[0004] While existing technologies such as CN119395852A provide solutions for automatic focusing, their direct application to low-cost ophthalmic RGB imaging modules presents significant challenges. First, while solutions like infrared ranging, laser ranging, or special phase detection sensors are effective, they all require additional dedicated ranging modules or high-cost sensors, significantly increasing hardware complexity and equipment cost. This contradicts the needs of low-cost ophthalmic devices (especially consumer-grade or portable devices). Second, in specific scenarios like ophthalmic examinations, which involve extremely close proximity and require highly fluid doctor-patient operations (e.g., calibration must be completed within one second to maintain good doctor-patient interaction), existing physical ranging-based solutions may face challenges in accuracy, cost, or integration difficulty. Therefore, achieving fast, high-precision automatic focusing during zooming in ophthalmic cameras without increasing hardware costs (such as laser or infrared modules), especially accurately calibrating and real-time fitting the zoom-focus curve using a very small number of sampling points within an extremely short time (approximately one second), has become a critical technical problem urgently needing to be solved in this field. Summary of the Invention

[0005] In view of the aforementioned existing problems, the present invention is proposed.

[0006] Therefore, the present invention provides a fitting method for automatic fast zoom and focus tracking of ophthalmic cameras, which solves the problems of accuracy, hardware complexity, equipment cost, and integration difficulty.

[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0008] In a first aspect, the present invention provides a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera, comprising the following steps:

[0009] S1. Rapid object distance calibration: With a fixed object distance, the zoom lens of the ophthalmic camera is initialized to the minimum zoom position ZoomA, and the current best focus position FocusA is obtained through the autofocus algorithm; at least five discrete zoom positions ZoomA, ZoomB, ZoomC, ZoomD, and ZoomE are selected sequentially within the zoom range, and the best focus positions FocusA, FocusB, FocusC, FocusD, and FocusE corresponding to each position are recorded to form a Zoom-Focus mapping relationship dataset. The calibration process is completed within 1 second.

[0010] S2. Adjusting the zoom to change the image distance, calibrating the zoom and focus curves based on the object distance: By adjusting the zoom position of the ophthalmic camera in real time to switch the eye's observation angle, observe the overall picture and iris details, and ensure that the picture is clear throughout the zoom process; using only the zoom-focus mapping data of five sampling points A, B, C, D, and E, the complete curve is reconstructed through a fitting algorithm to achieve fast and accurate focus tracking;

[0011] S3. Automatic focus tracking and Lagrange nonlinear fitting to reconstruct the corresponding focus position: Based on the dataset, construct an exponential function model y = Ae -kx +B represents the zoom-focus relationship curve, where x is the zoom position and y is the focus position. The constraint A+B = C (where C is the initial focus position constant) is introduced to construct the Lagrangian function.

[0012]

[0013] The complete Zoom-Focus curve is reconstructed by iteratively solving for parameters A, B, k and Lagrange multiplier λ using Newton's method; S4. Real-time focus control sets the focus target position and responds to the focus motor for precise focusing: During zooming, the two nearest neighbor sampling points are located based on the current zoom position, and the optimal focus position is dynamically calculated by fitting the curve, driving the focus motor to adjust the image distance to maintain image clarity.

[0014] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera according to the present invention, in the rapid calibration of step S1, the selection of discrete zoom positions needs to cover the entire range from the minimum to the maximum magnification of the ophthalmic camera. Specifically, this includes: taking the minimum zoom position ZoomA as the starting point and the maximum zoom position ZoomE as the ending point, selecting intermediate points ZoomB, ZoomC, and ZoomD at equal or non-equal intervals between the two to form at least five sampling points; when the fitting accuracy does not meet the sharpness threshold, the number of sampling points can be dynamically increased to more than 5. The newly added sampling points obtain the best focus position in real time through the autofocus algorithm and supplement the dataset.

[0015] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera described in this invention, the specific process of obtaining the optimal focus position through the autofocus algorithm in the rapid calibration of step S1 is as follows: for each discrete zoom position ZoomA to ZoomE, the focusing motor is controlled to traverse the focus position within its travel range, while the sharpness score of the current image is calculated in real time; the sharpness score function is constructed based on image gradient features, specifically using the Sobel operator to extract the image edge gradient, and calculating the sum of the absolute values ​​of the gradients across the entire frame as the scoring basis; when the score reaches a peak value, the position of the focusing motor at this time is recorded as the optimal focus point Focus value, and local extreme value interference is excluded during peak detection, with the global maximum score point as the final focus position.

[0016] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera described in this invention, the execution of the rapid calibration in step S1 must strictly limit the object distance between the ophthalmic camera and the patient's eye to between 0.5cm and 10cm, and establish a zoom-focus mapping relationship independently for different object distances; specifically, it includes: monitoring the object distance value in real time through the distance sensor on the ophthalmic device, and automatically triggering the recalibration process when the object distance change exceeds a set threshold (±0.2cm); for multiple examinations of the same patient, the system stores the zoom-focus curve corresponding to the object distance in the local database, and directly calls the historical curve during subsequent examinations, and performs the full calibration process only when the object distance deviation exceeds the threshold or during the first examination.

[0017] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera described in this invention, the core of the rapid calibration in step S1 lies in accurately determining the optimal focus positions (FocusA, FocusB, FocusC, FocusD, FocusE) corresponding to each discrete zoom position (ZoomA, ZoomB, ZoomC, ZoomD, ZoomE) through an autofocus algorithm. The core mechanism of this process relies on sharpness evaluation of the real-time image sequence captured by the motor. Specifically, the system drives the focusing motor to scan within the potential focus range corresponding to the current position, while continuously acquiring a series of images. For each acquired frame, the system calculates its sharpness score. This score is a key indicator for quantifying image sharpness, and its calculation depends on a preset sharpness scoring function.

[0018] Sharpness scoring functions are designed to sensitively capture changes in high-frequency detail information in an image, because sharp images typically contain rich edge and texture details; common implementations include, but are not limited to, the following:

[0019] Gradient energy function: Sobel, Roberts or Prewitt operators calculate the gradient magnitude of the image, and then calculate the sum of squares or absolute values ​​of the gradient magnitudes of the entire image or a specific region of interest (ROI);

[0020] Laplacian variance function: Apply the Laplacian operator to enhance the edges, then calculate the variance and frequency domain analysis function of the processed image, and calculate the energy of high-frequency components or the energy of detail coefficients based on wavelet transform after performing Fourier transform on the image.

[0021] In the specific application of ophthalmic imaging, since the focus is on the structure of the eyeball, the texture of the iris, and the fine details of the limbus, the scoring function needs to be optimized for the texture features of these structures, giving priority to operators that are more sensitive to mid-to-high frequency responses or calculating energy within a specific spatial frequency range.

[0022] During the focusing motor scanning process, the system calculates and records the sharpness score corresponding to each focusing position in real time. As the focusing position changes, the score values ​​form a sharpness response curve; the goal of the autofocus algorithm is to find the global peak point of this score curve. When the scan is completed or the maximum value of the score value is located through a specific search strategy, the focusing motor position corresponding to the maximum value point is determined as the optimal focusing point FocusA and FocusB at the current zoom position. This process requires high accuracy and stability to ensure that the recorded Focus value truly reflects the best image sharpness at the zoom position. Considering that rapid calibration needs to complete the focus search of at least 5 points within 1 second, the autofocus algorithm needs to adopt a variable step size hill climbing method combined with hardware acceleration and reduced image resolution calculation to balance the requirements of accuracy and speed.

[0023] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera according to the present invention, in the core calculation step of the automatic focus Lagrange nonlinear fitting in step S3, the Newton method iterative solution process needs to accurately realize the dynamic update of the parameter vector p = [A, B, k, λ]; this process is first based on the current parameter estimate p n Construct a nonlinear system of equations F(p) n Its specific form is defined by the partial derivatives of the Lagrange function:

[0024]

[0025] The first three components correspond to the partial derivatives of the objective function with respect to parameters A, B, and k, respectively, and the fourth component is the constraint condition A+B=C. The dimension of this system of equations is consistent with the parameter vector p, forming the mathematical basis for the solution process.

[0026] The core of iterative updates lies in solving the linear system JΔp=-F(p)n Here, J is the Jacobian matrix of the system of equations F, whose elements are the partial derivatives of each component of F with respect to each variable in the parameter vector p, forming a 4×4 matrix:

[0027]

[0028] Each element in matrix J needs to be obtained through analytical differentiation:

[0029]

[0030]

[0031] Where N is the number of sample points;

[0032] Parameter updates are achieved via Δp = -J -1 F(p n Calculate the increment and execute p n+1 =p n +Δp. The linear equation system is solved directly using a numerical linear algebra library; the setting of the initial parameter p0 is crucial: A and B can be the average of the sampling points, k is estimated based on the curve trend, and λ is initialized to zero; F and J need to be recalculated after each iteration until the convergence condition is met.

[0033] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera according to the present invention, in the real-time focus tracking control of step S4, the hardware architecture of the ophthalmic camera serves as the physical carrier for the implementation of the method, and its core is the RGB module of the ophthalmic visual imaging device. The module employs a four-layer collaborative design: the front end features an optical filter group, including an infrared cut-off filter (IR-Cut Filter) and a visible light band enhancement filter, used to eliminate environmental infrared interference and improve the contrast of blood vessels and iris textures in the eye; subsequently coupled is a high frame rate CMOS image sensor, whose high-speed image reading capability forms the hardware basis for real-time calculation of sharpness scores during the rapid calibration stage; the optical core uses a motorized zoom lens, which integrates two independently driven voice coil motors (VCMs). The zoom motor continuously adjusts the lens group spacing to change the optical magnification, with a typical travel range of 3mm to 15mm, corresponding to an optical zoom ratio of 1.5x to 5x; the focus motor precisely controls the imaging plane position to compensate for image distance drift caused by zooming, with a displacement accuracy of ±1μm and a repeatability error of <0.5μm; the top layer uses a multi-core heterogeneous main control chip to achieve closed-loop control, where the CPU runs a Linux system to schedule the autofocus algorithm, and the FPGA processes the image sharpness score and motor drive pulses in real time;

[0034] When a doctor adjusts the zoom level using the device's knob, the Zoom motor receives a pulse width modulation (PWM) signal to drive the lens assembly to shift, simultaneously triggering a triple response chain:

[0035] 1. Zoom position feedback loop: The zoom motor displacement is monitored in real time by the lens's built-in Hall sensor, transmitting the current position z to the main controller with 12-bit ADC precision and 0.01mm resolution; 2. Real-time query of fitted curve: The main controller queries the reconstructed zoom-focus curve y=Ae based on the z value. -kx +B Interpolation calculation of target focus position f target The calculation delay is <1ms;

[0036] 3. Focus position execution loop: The Focus motor is based on f target A step-like micro-displacement is generated with a typical response time of 8ms / step. Simultaneously, the image sensor captures a new frame within 5ms after the displacement is completed, and the actual imaging quality is verified by the sharpness scoring function.

[0037] The innovative synergy of this hardware system is reflected in: the wide dynamic range of the zoom motor, covering the entire focal length from 10cm to 0.5cm object distance, complements the ultra-high precision of the focusing motor; while the parallel processing capability of the main control chip, the real-time calculation of the Jacobian matrix by the FPGA, and the asynchronous updating of the fitting curve by the CPU ensure that the duration of image blurring is compressed to ≤33ms below the human visual persistence limit when the doctor continuously rotates the zoom ring. Clinical tests show that even under extreme conditions of 5cm object distance and 4mm / s zoom speed, the system can still maintain diagnostic-grade sharpness with an MTF50 value >0.3.

[0038] As a preferred embodiment of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera described in this invention, in the real-time focus tracking control stage of step S4, the system ensures that the dynamic focusing response time is strictly less than 0.1 seconds through a third-order collaborative acceleration mechanism. This is the critical threshold for eliminating image blur perceptible to the human eye. This mechanism achieves a breakthrough first at the hardware driving layer: the focusing motor adopts a pre-loaded flux-optimized voice coil motor (VCM), and its step response time is compressed from the conventional 25ms to ≤8ms. This is due to three innovations:

[0039] Phase-leading current drive: Based on the motor inductance-back EMF model, the controller pre-injects 150% of the rated current to overcome static friction when receiving the target position command, and then switches to PID closed-loop control.

[0040] Position feedback upgrade: The traditional potentiometer is replaced with a 16-bit magnetic encoder with a resolution of 0.15μm and a sampling rate of 10kHz, which shortens the real-time position error compensation cycle to 0.1ms.

[0041] Mechanical resonance suppression: Active damping adhesive is embedded in the motor bracket to reduce the mechanical resonance peak from 800Hz to below 200Hz, thus avoiding displacement overshoot;

[0042] The intermediate control algorithm further optimizes the timing: when the zoom position z changes, the system performs dual-channel calculations in parallel.

[0043] Curve interpolation channel: The exponential function f is directly calculated using hardware logic circuits based on the fitting parameters A, k, and B pre-stored in the FPGA. target =Ae -kz +B, where f target Interpolate for the target;

[0044] Nearest Neighbor Prediction Channel: Simultaneously initiate dual-thread search. Thread 1 locates the nearest calibration point ZoomC to z, and thread 2 retrieves the next nearest point ZoomD and its corresponding historical focus position f. n f n+1 Load into cache; if the interpolation result f target Compared with the predicted value of 0.5 (f) n +f n+1 If the deviation is greater than 5%, the fitting curve verification process will be triggered immediately.

[0045] The top-level real-time verification system starts simultaneously with motor movement: the CMOS sensor outputs an image stream at 120fps, completing ROI locking, iris texture segmentation, and sharpness assessment within 3.3ms after each frame arrives; an adaptive dual-threshold strategy is employed.

[0046] The maximum score is 2000. When the Laplace variance value is L... var A value greater than 1500 indicates successful focus.

[0047] If L var If the value is less than 1200, micro-step compensation is initiated, with each step being 2μm, until L... var Three consecutive frames >1400. Actual test data shows that at an object distance of 5cm and a zoom speed of 6mm / s, the average time from zooming to restoring the diagnostic-grade sharpness MTF50 > 0.25 is 68ms ± 12ms; this performance has passed ISO 13485 medical device response time certification and meets the clinical requirement of imperceptible blur in 93.7% of operating conditions.

[0048] In a second aspect, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, it implements any step of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in the first aspect of the present invention.

[0049] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in the first aspect of the present invention.

[0050] The beneficial effects of this invention: The core value of this patented invention lies in significantly reducing the threshold and cost of achieving high-quality automatic zoom and focus tracking in ophthalmic examination equipment. It abandons the traditional approach that relies on additional physical ranging modules (such as laser emitters, infrared sensors, or special phase detection units), cleverly utilizing the device's existing RGB imaging module and motor control system. By acquiring only a handful of zoom-focus mapping points (e.g., only five points A-E) in a very short initial period (approximately 1 second), and applying innovative Lagrange nonlinear fitting technology, the ideal focus curve across the entire zoom range can be efficiently and accurately reconstructed. This design fundamentally eliminates the dependence on expensive dedicated hardware, greatly simplifies the system structure, and enables the automatic fast focus tracking function to be applied more economically and widely in various ophthalmic imaging devices, including portable and primary healthcare equipment, effectively reducing the overall manufacturing cost and maintenance complexity of the equipment.

[0051] This invention significantly optimizes the operational experience and efficiency for doctors during ophthalmological examinations, meeting the stringent requirements of real-time performance and smooth operation in medical settings. Its rapid calibration mechanism can instantly collect key data and fit curves after the patient's head is positioned, virtually eliminating interruptions or waiting times in doctor-patient interaction and avoiding the lengthy calibration times that can occur with traditional intensive sampling methods. More importantly, during subsequent diagnosis, regardless of how frequently the doctor adjusts the zoom magnification to observe different parts of the eye (e.g., switching from a global view to a detailed iris view), the system can calculate the optimal focus point corresponding to the current zoom position in near real-time based on a pre-fitted high-precision curve and instantly drive the focusing motor to the desired position. This ensures that the image remains clear and sharp throughout the zoom process, completely eliminating image blurring caused by zooming. This allows doctors to focus on the diagnosis itself without being distracted by manual focusing or enduring the frustration of out-of-focus images, significantly improving diagnostic accuracy and the smoothness of the examination process.

[0052] The Lagrangian nonlinear fitting method based on a small number of samples employed in this invention patent is not only the technological cornerstone for achieving the aforementioned goals of low cost and high efficiency, but also demonstrates excellent practicality and adaptability. This method can effectively capture the inherent nonlinear characteristics of the zoom-focus relationship. Even with extremely few sampling points (e.g., only five points), it can generate fitting results that highly match the curves of a large number of actual sampling points, ensuring that the accuracy of automatic focusing meets the needs of clinical observation. Simultaneously, the method itself possesses a certain degree of flexibility; for example, the number of sampling points can be appropriately increased according to actual accuracy requirements, or more complex constraints can be introduced into the fitting model to better match the characteristics of a specific optical system. This powerful fitting capability allows the solution to flexibly adapt to different specifications of ophthalmic imaging equipment and optical designs while maintaining its core advantages (speed and low cost), providing a highly practical core technological support for the intelligent and convenient upgrading of ophthalmic examination equipment. Attached Figure Description

[0053] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. 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.

[0054] Figure 1 This is a flowchart of a fitting method for automatic fast zoom and focus tracking in ophthalmic cameras.

[0055] Figure 2 This is a data fitting graph showing the matching degree between the fitted curve and the actual large sample curve. Detailed Implementation

[0056] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0057] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0058] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0059] Reference Figure 1 As one embodiment of the present invention, this embodiment provides a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera, including the following steps:

[0060] S1. Rapid object distance calibration: With a fixed object distance, the zoom lens of the ophthalmic camera is initialized to the minimum zoom position ZoomA, and the current best focus position FocusA is obtained through the autofocus algorithm; at least five discrete zoom positions ZoomA, ZoomB, ZoomC, ZoomD, and ZoomE are selected sequentially within the zoom range, and the best focus positions FocusA, FocusB, FocusC, FocusD, and FocusE corresponding to each position are recorded to form a Zoom-Focus mapping relationship dataset. The calibration process is completed within 1 second.

[0061] S2. Adjusting the zoom to change the image distance, calibrating the zoom and focus curves based on the object distance: By adjusting the zoom position of the ophthalmic camera in real time to switch the eye's observation angle, observe the overall picture and iris details, and ensure that the picture is clear throughout the zoom process; using only the zoom-focus mapping data of five sampling points A, B, C, D, and E, the complete curve is reconstructed through a fitting algorithm to achieve fast and accurate focus tracking;

[0062] S3. Automatic focus tracking and Lagrange nonlinear fitting to reconstruct the corresponding focus position: Based on the dataset, construct an exponential function model y = Ae -kx +B represents the zoom-focus relationship curve, where x is the zoom position and y is the focus position. The constraint A+B = C (where C is the initial focus position constant) is introduced to construct the Lagrangian function.

[0063]

[0064] The complete Zoom-Focus curve is reconstructed by iteratively solving for parameters A, B, k and Lagrange multiplier λ using Newton's method; S4. Real-time focus control sets the focus target position and responds to the focus motor for precise focusing: During zooming, the two nearest neighbor sampling points are located based on the current zoom position, and the optimal focus position is dynamically calculated by fitting the curve, driving the focus motor to adjust the image distance to maintain image clarity.

[0065] In the rapid calibration of step S1, the selection of discrete zoom positions needs to cover the entire range from the minimum to the maximum magnification of the ophthalmic camera. Specifically, this includes: taking the minimum zoom position ZoomA as the starting point and the maximum zoom position ZoomE as the ending point, selecting intermediate points ZoomB, ZoomC, and ZoomD at equal or non-equal intervals between the two to form at least five sampling points; when the fitting accuracy does not meet the sharpness threshold, the number of sampling points can be dynamically increased to more than 5. The newly added sampling points obtain the best focus position in real time through the autofocus algorithm and supplement the dataset.

[0066] The specific process of obtaining the optimal focus position through the autofocus algorithm is as follows: For each discrete zoom position from ZoomA to ZoomE, the focus motor is controlled to traverse the focus position within its travel range, while the sharpness score of the current image is calculated in real time; the sharpness score function is constructed based on image gradient features, specifically using the Sobel operator to extract the image edge gradient, and calculating the sum of the absolute values ​​of the gradients across the entire frame as the scoring basis; when the score reaches its peak, the position of the focus motor at this time is recorded as the optimal focus point (Focus value), and local extreme value interference is eliminated during peak detection, with the global maximum score point as the final focus position.

[0067] Rapid calibration requires strictly limiting the object distance between the ophthalmic camera and the patient's eye to between 0.5cm and 10cm, and establishing a separate zoom-focus mapping relationship for different object distances. Specifically, this includes: real-time monitoring of object distance values ​​through a distance sensor on the ophthalmic device; automatically triggering a recalibration process when the object distance change exceeds a set threshold (±0.2cm); and storing the zoom-focus curves corresponding to the object distances for multiple examinations of the same patient in a local database, directly calling historical curves during subsequent examinations, and performing a full calibration process only when the object distance deviation exceeds the threshold or during the first examination.

[0068] The core of rapid calibration lies in accurately determining the optimal focus position (FocusA, FocusB, FocusC, FocusD, FocusE) corresponding to each discrete zoom position (ZoomA, ZoomB, ZoomC, ZoomD, ZoomE) using an autofocus algorithm. The core mechanism of this process relies on sharpness evaluation of the real-time image sequence captured by the motor. In practice, the system drives the focus motor to scan within the potential focus range corresponding to the current position, while continuously acquiring a series of images. For each acquired frame, the system calculates its sharpness score. This score is a key indicator for quantifying the image sharpness, and its calculation depends on a preset sharpness scoring function.

[0069] Sharpness scoring functions are designed to sensitively capture changes in high-frequency detail information in an image, because sharp images typically contain rich edge and texture details; common implementations include, but are not limited to, the following:

[0070] Gradient energy function: Sobel, Roberts or Prewitt operators calculate the gradient magnitude of the image, and then calculate the sum of squares or absolute values ​​of the gradient magnitudes of the entire image or a specific region of interest (ROI);

[0071] Laplacian variance function: Apply the Laplacian operator to enhance the edges, then calculate the variance and frequency domain analysis function of the processed image, and calculate the energy of high-frequency components or the energy of detail coefficients based on wavelet transform after performing Fourier transform on the image.

[0072] In the specific application of ophthalmic imaging, since the focus is on the structure of the eyeball, the texture of the iris, and the fine details of the limbus, the scoring function needs to be optimized for the texture features of these structures, giving priority to operators that are more sensitive to mid-to-high frequency responses or calculating energy within a specific spatial frequency range.

[0073] During the focusing motor scanning process, the system calculates and records the sharpness score corresponding to each focusing position in real time. As the focusing position changes, the score values ​​form a sharpness response curve; the goal of the autofocus algorithm is to find the global peak point of this score curve. When the scan is completed or the maximum value of the score value is located through a specific search strategy, the focusing motor position corresponding to the maximum value point is determined as the optimal focusing point FocusA and FocusB at the current zoom position. This process requires high accuracy and stability to ensure that the recorded Focus value truly reflects the best image sharpness at the zoom position. Considering that rapid calibration needs to complete the focus search of at least 5 points within 1 second, the autofocus algorithm needs to adopt a variable step size hill climbing method combined with hardware acceleration and reduced image resolution calculation to balance the requirements of accuracy and speed.

[0074] In the core calculation step of automatic focus Lagrange nonlinear fitting in step S3, the Newton method iterative solution process needs to accurately realize the dynamic update of the parameter vector p = [A, B, k, λ]. This process is first based on the current parameter estimate p. n Construct a nonlinear system of equations F(p) n Its specific form is defined by the partial derivatives of the Lagrange function:

[0075]

[0076] The first three components correspond to the partial derivatives of the objective function with respect to parameters A, B, and k, respectively, and the fourth component is the constraint condition A+B=C. The dimension of this system of equations is consistent with the parameter vector p, forming the mathematical basis for the solution process.

[0077] The core of iterative updates lies in solving the linear system JΔp=-F(p) n Here, J is the Jacobian matrix of the system of equations F, whose elements are the partial derivatives of each component of F with respect to each variable in the parameter vector p, forming a 4×4 matrix:

[0078]

[0079] Each element in matrix J needs to be obtained through analytical differentiation:

[0080]

[0081] Where N is the number of sample points;

[0082] Parameter updates are achieved via Δp = -J -1 F(p n Calculate the increment and execute p n+1 =p n +Δp. The linear equation system is solved directly using a numerical linear algebra library; the setting of the initial parameter p0 is crucial: A and B can be the average of the sampling points, k is estimated based on the curve trend, and λ is initialized to zero; F and J need to be recalculated after each iteration until the convergence condition is met.

[0083] In the real-time focus control of step S4, the hardware architecture of the ophthalmic camera serves as the physical carrier for the implementation of the method, and its core is the RGB module of the ophthalmic visual imaging device. The module employs a four-layer collaborative design: the front end features an optical filter group, including an infrared cut-off filter (IR-Cut Filter) and a visible light band enhancement filter, used to eliminate environmental infrared interference and improve the contrast of blood vessels and iris textures in the eye; subsequently coupled is a high frame rate CMOS image sensor, whose high-speed image reading capability forms the hardware basis for real-time calculation of sharpness scores during the rapid calibration stage; the optical core uses a motorized zoom lens, which integrates two independently driven voice coil motors (VCMs). The zoom motor continuously adjusts the lens group spacing to change the optical magnification, with a typical travel range of 3mm to 15mm, corresponding to an optical zoom ratio of 1.5x to 5x; the focus motor precisely controls the imaging plane position to compensate for image distance drift caused by zooming, with a displacement accuracy of ±1μm and a repeatability error of <0.5μm; the top layer uses a multi-core heterogeneous main control chip to achieve closed-loop control, where the CPU runs a Linux system to schedule the autofocus algorithm, and the FPGA processes the image sharpness score and motor drive pulses in real time;

[0084] When a doctor adjusts the zoom level using the device's knob, the Zoom motor receives a pulse width modulation (PWM) signal to drive the lens assembly to shift, simultaneously triggering a triple response chain:

[0085] 1. Zoom position feedback loop: The zoom motor displacement is monitored in real time by the lens's built-in Hall sensor, and the current position z is transmitted to the main controller with 12-bit ADC precision and 0.01mm resolution; 2. Real-time query of fitted curve: The main controller queries the reconstructed zoom-focus curve y=Ae based on the z value. -kx +B Interpolation calculation of target focus position f target The calculation delay is <1ms;

[0086] 3. Focus position execution loop: The Focus motor is based on f target A step-like micro-displacement is generated with a typical response time of 8ms / step. Simultaneously, the image sensor captures a new frame within 5ms after the displacement is completed, and the actual imaging quality is verified by the sharpness scoring function.

[0087] The innovative synergy of this hardware system is reflected in: the wide dynamic range of the zoom motor, covering the entire focal length from 10cm to 0.5cm object distance, complements the ultra-high precision of the focusing motor; while the parallel processing capability of the main control chip, the real-time calculation of the Jacobian matrix by the FPGA, and the asynchronous updating of the fitting curve by the CPU ensure that the duration of image blurring is compressed to ≤33ms below the human visual persistence limit when the doctor continuously rotates the zoom ring. Clinical tests show that even under extreme conditions of 5cm object distance and 4mm / s zoom speed, the system can still maintain diagnostic-grade sharpness with an MTF50 value >0.3.

[0088] The system employs a third-order collaborative acceleration mechanism to ensure that the dynamic focusing response time is strictly less than 0.1 seconds, which is the critical threshold for eliminating image blur perceptible to the human eye. This mechanism achieves a breakthrough first at the hardware driver layer: the focusing motor uses a pre-loaded flux-optimized voice coil motor (VCM), reducing its step response time from the conventional 25ms to ≤8ms. This is thanks to three innovations:

[0089] Phase-leading current drive: Based on the motor inductance-back EMF model, the controller pre-injects 150% of the rated current to overcome static friction when receiving the target position command, and then switches to PID closed-loop control.

[0090] Position feedback upgrade: The traditional potentiometer is replaced with a 16-bit magnetic encoder with a resolution of 0.15μm and a sampling rate of 10kHz, which shortens the real-time position error compensation cycle to 0.1ms.

[0091] Mechanical resonance suppression: Active damping adhesive is embedded in the motor bracket to reduce the mechanical resonance peak from 800Hz to below 200Hz, thus avoiding displacement overshoot;

[0092] The intermediate control algorithm further optimizes the timing: when the zoom position z changes, the system performs dual-channel calculations in parallel.

[0093] Curve interpolation channel: The exponential function f is directly calculated using hardware logic circuits based on the fitting parameters A, k, and B pre-stored in the FPGA. target =Ae -kz +B, where f target Interpolate for the target;

[0094] Nearest Neighbor Prediction Channel: Simultaneously initiate dual-thread search. Thread 1 locates the nearest calibration point ZoomC to z, and thread 2 retrieves the next nearest point ZoomD and its corresponding historical focus position f. n f n+1 Load into cache; if the interpolation result f target Compared with the predicted value of 0.5 (f) n +f n+1 If the deviation is greater than 5%, the fitting curve verification process will be triggered immediately.

[0095] The top-level real-time verification system starts simultaneously with motor movement: the CMOS sensor outputs an image stream at 120fps, completing ROI locking, iris texture segmentation, and sharpness assessment within 3.3ms after each frame arrives; an adaptive dual-threshold strategy is employed.

[0096] The maximum score is 2000. When the Laplace variance value is L... var A value greater than 1500 indicates successful focus.

[0097] If L var If the value is less than 1200, micro-step compensation is initiated, with each step being 2μm, until L... var Three consecutive frames >1400. Actual test data shows that at an object distance of 5cm and a zoom speed of 6mm / s, the average time from zooming to restoring the diagnostic-grade sharpness MTF50 > 0.25 is 68ms ± 12ms; this performance has passed ISO 13485 medical device response time certification and meets the clinical requirement of imperceptible blur in 93.7% of operating conditions.

[0098] The following is a flowchart and detailed implementation of an embodiment of a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera:

[0099] Once the patient's head is securely positioned on the ophthalmic imaging device, maintaining a fixed object distance (typically between 0.5 cm and 10 cm) between the device's built-in RGB imaging module and the eyeball, the system automatically initiates the initialization and rapid calibration process. The core of this process is quickly establishing a mapping between the zoom level and the optimal focus position at the current object distance. The system first drives the zoom motor to the minimum magnification position (called zoomA). At this position, the system triggers the built-in autofocus algorithm, which precisely locates and locks the sharpest focus point by moving the focus motor and analyzing image sharpness (e.g., using image gradient information), recording the focus value at this moment (focusA). Next, the system moves the zoom motor sequentially to these positions at preset intervals (e.g., selecting four points evenly between the minimum magnification zoomA and the maximum magnification zoomE, for a total of five points including the beginning and end: zoomA, zoomB, zoomC, zoomD, and zoomE). At each zoom position, the system repeatedly performs the autofocus process, accurately finding and recording the optimal focus point (focusB, focusC, focusD, focusE) for that position. The entire calibration process is strictly limited to one second to ensure it does not affect the doctor's and patient's interactive experience. Ultimately, the system collects data pairs (zoom value, focus value) for these five key positions, forming the initial calibration dataset and laying the foundation for subsequent real-time focusing.

[0100] After calibration, the system enters diagnostic mode. Doctors adjust the zoom level of the RGB module in real time via the interface, based on the examination needs. For example, a doctor might switch from a low-magnification view (e.g., zoom1) to a high-magnification view (e.g., zoom2) for observing iris details. Whenever a doctor changes the zoom setting, the system immediately captures this new zoom position value (let's say zoom_new). At this point, the system's key task is to quickly and accurately predict the optimal focus point corresponding to this new zoom position based on the limited five data points obtained during calibration. The system first finds the two points closest to the current zoom_new value in the calibration dataset (e.g., if zoom_new is between zoomB and zoomC, these two points are selected). Then, the system applies a Lagrange nonlinear fitting method. This method is based on a pre-defined mathematical model that describes the nonlinear relationship between zoom and focus. To ensure that the fitting results conform to the actual constraints of the physical system (e.g., requiring the model to meet specific initial conditions), this method cleverly introduces additional parameters (Lagrange multipliers) to handle these constraints, constructing a mathematical problem that needs optimization. The system uses a highly efficient Newton-Raphson iterative algorithm to solve for the key parameters in this problem. This calculation, supported by a powerful embedded processor, can be completed in an extremely short time (far less than 1 millisecond), ultimately outputting the optimal focus point value (focus_new) accurately predicted for the current zoom_new.

[0101] Upon obtaining the predicted focus_new value, the system immediately drives the focusing motor to that position. This ensures that regardless of how frequently the doctor adjusts the zoom to change the field of view and magnification, the camera's focusing system adjusts almost synchronously. As a result, the eye image captured and displayed by the camera remains clear and sharp throughout the doctor's procedure, completely eliminating the problem of blurry images caused by zooming and greatly improving diagnostic efficiency and accuracy. To ensure the system's reliability and adaptability, several safeguards are included in the implementation. The calibration phase strictly limits the number of sampling points (usually five) to ensure the total time does not exceed one second, while the fitting calculation uses a highly optimized algorithm library to ensure millisecond-level response. If the initial calibration is insufficiently accurate in certain zoom ranges, the system can dynamically add a small number of sampling points. After each successful diagnosis, the system automatically records the clear focus point data actually used by the doctor for continuous optimization of the subsequent model. If extreme situations cause complex fitting calculations to fail, the system will safely degrade, using a simpler linear interpolation method to provide a focusing reference, ensuring the availability of basic functions. The core of the solution lies in its full utilization of the device's existing hardware (RGB module, zoom and focus motors, processor), without the need to add any external expensive ranging sensors, thus achieving seamless coordination of zoom and focus for ophthalmic cameras while meeting the stringent real-time and reliability requirements of medical scenarios.

[0102] This embodiment also provides a computer device applicable to a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera, comprising: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as proposed in the above embodiment.

[0103] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0104] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as proposed in the above embodiments. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0105] In summary, the core value of this invention lies in significantly reducing the barrier and cost of achieving high-quality automatic zoom and focus tracking in ophthalmic examination equipment. It abandons the traditional approach that relies on additional physical ranging modules (such as laser emitters, infrared sensors, or special phase detection units), cleverly utilizing the device's existing RGB imaging module and motor control system. By acquiring only a handful of zoom-focus mapping points (e.g., only five points A-E) in a very short initial period (approximately 1 second), and applying innovative Lagrangian nonlinear fitting technology, the ideal focus curve across the entire zoom range can be efficiently and accurately reconstructed. This design fundamentally eliminates reliance on expensive dedicated hardware, greatly simplifies the system structure, and enables the automatic fast focus tracking function to be applied more economically and widely in various ophthalmic imaging devices, including portable and primary healthcare equipment, effectively reducing the overall manufacturing cost and maintenance complexity of the equipment.

[0106] This invention significantly optimizes the operational experience and efficiency for doctors during ophthalmological examinations, meeting the stringent requirements of real-time performance and smooth operation in medical settings. Its rapid calibration mechanism can instantly collect key data and fit curves after the patient's head is positioned, virtually eliminating interruptions or waiting times in doctor-patient interaction and avoiding the lengthy calibration times that can occur with traditional intensive sampling methods. More importantly, during subsequent diagnosis, regardless of how frequently the doctor adjusts the zoom magnification to observe different parts of the eye (e.g., switching from a global view to a detailed iris view), the system can calculate the optimal focus point corresponding to the current zoom position in near real-time based on a pre-fitted high-precision curve and instantly drive the focusing motor to the desired position. This ensures that the image remains clear and sharp throughout the zoom process, completely eliminating image blurring caused by zooming. This allows doctors to focus on the diagnosis itself without being distracted by manual focusing or enduring the frustration of out-of-focus images, significantly improving diagnostic accuracy and the smoothness of the examination process.

[0107] The Lagrangian nonlinear fitting method based on a small number of samples employed in this invention patent is not only the technological cornerstone for achieving the aforementioned goals of low cost and high efficiency, but also demonstrates excellent practicality and adaptability. This method can effectively capture the inherent nonlinear characteristics of the zoom-focus relationship. Even with extremely few sampling points (e.g., only five points), it can generate fitting results that highly match the curves of a large number of actual sampling points, ensuring that the accuracy of automatic focusing meets the needs of clinical observation. Simultaneously, the method itself possesses a certain degree of flexibility; for example, the number of sampling points can be appropriately increased according to actual accuracy requirements, or more complex constraints can be introduced into the fitting model to better match the characteristics of a specific optical system. This powerful fitting capability allows the solution to flexibly adapt to different specifications of ophthalmic imaging equipment and optical designs while maintaining its core advantages (speed and low cost), providing a highly practical core technological support for the intelligent and convenient upgrading of ophthalmic examination equipment.

[0108] Example 2, referring to Table 1, is the second embodiment of the present invention. To further verify the technical solution of the present invention, the following are the experimental simulation data and analysis of Example 2, which are verified based on the key technical indicators of a fitting method for automatic fast zoom and focus tracking of an ophthalmic camera:

[0109] The details are shown in Table 1 below:

[0110] Table 1: Performance Validation Data of Automatic Zoom and Focus Fitting Method

[0111]

[0112]

[0113] Experimental Design Description

[0114] 1. Test platform:

[0115] An ophthalmic camera prototype system was built, configured with: a zoom lens (electric zoom travel 0-1000 steps); a focusing motor (5000 steps); a 2-megapixel CMOS sensor; an ARM Cortex-A53 processor; and a fixed object distance of 5cm (simulating a typical examination distance).

[0116] 2. Testing process:

[0117] Calibration phase: The focus position was recorded using two modes: 5 points (zoom positions: 0, 250, 500, 750, 1000 steps) and 30 points (sampling every 33 steps).

[0118] Dynamic zoom: Doctor simulation operation (zoom continuously sweeps from 0 to 1000 steps at a speed of 20 steps / ms).

[0119] Accuracy verification: Pause image acquisition every 50 steps, calculate the structural similarity index (SSIM) and compare it with the theoretically optimal focus point.

[0120] Key data analysis

[0121] 1. Efficiency Advantage

[0122] Calibration time: The 5-point calibration of this invention only takes 820ms (meeting the clinical requirement of ≤1s), which is 6.2 times faster than 30-point dense sampling.

[0123] Real-time latency: The Lagrange fitting calculation takes 0.45ms per iteration (Newton's method converges after 3-5 iterations), which can support focus response above 2000Hz and ensure no image stuttering during zooming.

[0124] 2. Accuracy Performance

[0125] Focusing deviation: Compared to the 30-point reference value, the maximum deviation of this invention is 12 steps (0.24% of the entire focusing range), and it still maintains SSIM > 0.97 even in the mid-focal range where non-linearity is strongest (zoom = 300-700 steps). Figure 2 The fitted curves shown have a matching degree of over 95%. The red curve represents the curve with a large sample size, and the blue curve represents the fitted curve.

[0126] Sharpness comparison: Because linear interpolation ignores optical nonlinearity, it deviates by 48 steps around zoom=500 steps, and SSIM drops to 0.85 (visible blur to the naked eye).

[0127] 3. Cost and Robustness

[0128] Zero new hardware: Equivalent accuracy to laser solutions (SSIM difference <0.007) but eliminates the need for a laser module, reducing BOM costs by more than 30%.

[0129] Anti-disturbance capability: When simulating the micro-movement of the patient (fluctuation of object distance ±1cm), this invention can reduce the deviation to within 15 steps by dynamically supplementing 1-2 calibration points.

[0130] Data from Example 2 confirms:

[0131] 1.5-point Lagrange fitting, while ensuring clinical accuracy (SSIM≥0.97), reduces calibration time to within 1 second, breaking through the efficiency bottleneck of traditional methods;

[0132] 2. Millisecond-level real-time fitting capability perfectly matches the doctor's operating rhythm, eliminating defocusing during zooming;

[0133] 3. It significantly improves accuracy compared to linear interpolation and reduces hardware complexity compared to laser solutions, providing an ideal technical path for portable ophthalmic devices.

[0134] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A fitting method for automatic fast zoom and focus tracking of an ophthalmic camera, characterized in that, Includes the following steps: S1. Rapid object distance calibration: With a fixed object distance, the zoom lens of the ophthalmic camera is initialized to the minimum zoom position ZoomA, and the current best focus position FocusA is obtained through the autofocus algorithm; at least five discrete zoom positions ZoomA, ZoomB, ZoomC, ZoomD, and ZoomE are selected sequentially within the zoom range, and the best focus positions FocusA, FocusB, FocusC, FocusD, and FocusE corresponding to each position are recorded to form a Zoom-Focus mapping relationship dataset. The calibration process is completed within 1 second. S2. Adjusting the zoom to change the image distance, calibrating the zoom and focus curves based on the object distance: By adjusting the zoom position of the ophthalmic camera in real time to switch the eye's observation angle, observe the overall picture and iris details, and ensure that the picture is clear throughout the zoom process; using only the zoom-focus mapping data of five sampling points A, B, C, D, and E, the complete curve is reconstructed through a fitting algorithm to achieve fast and accurate focus tracking; S3. Automatic focus tracking and Lagrange nonlinear fitting to reconstruct the corresponding focus position: Based on the dataset, construct an exponential function model y = Ae -kx +B represents the zoom-focus relationship curve, where x is the zoom position and y is the focus position. The constraint A+B=C is introduced, where C is the initial focus position constant. A Lagrangian function is then constructed. The complete Zoom-Focus curve is reconstructed by iteratively solving for parameters A, B, k and Lagrange multiplier λ using Newton's method. S4. Real-time focus control, setting the focus target position to the focus motor for precise focusing: During zooming, the two nearest sampling points are located based on the current zoom position, and the optimal focus position is dynamically calculated by fitting a curve, driving the focus motor to adjust the image distance to maintain image clarity.

2. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 1, characterized in that, In the rapid calibration of step S1, the selection of discrete zoom positions needs to cover the entire range from the minimum to the maximum magnification of the ophthalmic camera. Specifically, this includes: taking the minimum zoom position ZoomA as the starting point and the maximum zoom position ZoomE as the ending point, selecting intermediate points ZoomB, ZoomC, and ZoomD at equal or non-equal intervals between the two to form at least five sampling points; when the fitting accuracy does not meet the sharpness threshold, the number of sampling points can be dynamically increased to more than 5. The newly added sampling points obtain the best focus position in real time through the autofocus algorithm and supplement the dataset.

3. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 2, characterized in that, In the rapid calibration of step S1, the specific process of obtaining the optimal focus position through the autofocus algorithm is as follows: for each discrete zoom position from ZoomA to ZoomE, the focus motor is controlled to traverse the focus position within its travel range, while the sharpness score of the current image is calculated in real time; the sharpness score function is constructed based on image gradient features, specifically using the Sobel operator to extract the image edge gradient, and calculating the sum of the absolute values ​​of the gradients of the entire frame as the scoring basis; when the score value reaches the peak, the position of the focus motor at this time is recorded as the optimal focus point Focus value, and local extreme value interference is excluded during the peak detection process, with the global maximum score point as the final focus position.

4. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 3, characterized in that, The rapid calibration in step S1 requires strictly limiting the object distance between the ophthalmic camera and the patient's eye to between 0.5cm and 10cm, and establishing a Zoom-Focus mapping relationship independently for different object distances. Specifically, this includes: real-time monitoring of the object distance value through the distance sensor on the ophthalmic device; when the object distance changes beyond a set threshold of ±0.2cm, the recalibration process is automatically triggered; for multiple examinations of the same patient, the system stores the Zoom-Focus curves corresponding to the object distances in the local database, and the historical curves are directly called during subsequent examinations, with the full calibration process only executed when the object distance deviation exceeds the threshold or during the first examination.

5. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 4, characterized in that, In the rapid calibration step S1, the core element lies in accurately determining the optimal focus position (FocusA, FocusB, FocusC, FocusD, FocusE) corresponding to each discrete zoom position (ZoomA, ZoomB, ZoomC, ZoomD, ZoomE) using an autofocus algorithm. The core mechanism of this process relies on sharpness evaluation of the real-time image sequence captured by the motor. Specifically, the system drives the focus motor to scan within the potential focus range corresponding to the current position, while continuously acquiring a series of images. For each acquired frame, the system calculates its sharpness score. This score is a key indicator for quantifying the sharpness of an image, and its calculation depends on a preset sharpness scoring function. Sharpness scoring functions are designed to sensitively capture changes in high-frequency detail information in an image, because sharp images typically contain rich edge and texture details; common implementations include, but are not limited to, the following: Gradient energy function: Sobel, Roberts or Prewitt operators calculate the gradient magnitude of the image, and then calculate the sum of squares or absolute values ​​of the gradient magnitudes of the entire image or a specific region of interest (ROI); Laplacian variance function: Apply the Laplacian operator to enhance the edges, then calculate the variance and frequency domain analysis function of the processed image, and calculate the energy of high-frequency components or the energy of detail coefficients based on wavelet transform after performing Fourier transform on the image. In the specific application of ophthalmic imaging, since the focus is on the structure of the eyeball, the texture of the iris, and the fine details of the limbus, the scoring function needs to be optimized for the texture features of these structures, giving priority to operators that are more sensitive to mid-to-high frequency responses or calculating energy within a specific spatial frequency range. During the focusing motor scanning process, the system calculates and records the sharpness score corresponding to each focusing position in real time. As the focusing position changes, the score values ​​form a sharpness response curve; the goal of the autofocus algorithm is to find the global peak point of this score curve. When the scan is completed or the maximum value of the score value is located through a specific search strategy, the focusing motor position corresponding to the maximum value point is determined as the optimal focusing point FocusA and FocusB at the current zoom position. This process requires high accuracy and stability to ensure that the recorded Focus value truly reflects the best image sharpness at the zoom position. Considering that rapid calibration needs to complete the focus search of at least 5 points within 1 second, the autofocus algorithm needs to adopt a variable step size hill climbing method combined with hardware acceleration and reduced image resolution calculation to balance the requirements of accuracy and speed.

6. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 5, characterized in that, In the core calculation step of automatic focus Lagrange nonlinear fitting in step S3, the Newton method iterative solution process needs to accurately realize the dynamic update of the parameter vector p = [A, B, k, λ]. This process is first based on the current parameter estimate p. n Construct a nonlinear system of equations F(p) n Its specific form is defined by the partial derivatives of the Lagrange function: The first three components correspond to the partial derivatives of the objective function with respect to parameters A, B, and k, respectively, and the fourth component is the constraint condition A+B=C. The dimension of this system of equations is consistent with the parameter vector p, forming the mathematical basis for the solution process. The core of iterative updates lies in solving the linear system JΔp = -F(p) n Here, J is the Jacobian matrix of the system of equations F, whose elements are the partial derivatives of each component of F with respect to each variable in the parameter vector p, forming a 4×4 matrix: Each element in matrix J needs to be obtained through analytical differentiation: Where N is the number of sample points; Parameter updates are achieved via Δp = -J -1 F(p n Calculate the increment and execute p n+1 =p n +Δp. The linear equation system is solved directly using a numerical linear algebra library; the setting of the initial parameter p0 is crucial: A and B can be the average of the sampling points, k is estimated based on the curve trend, and λ is initialized to zero; F and J need to be recalculated after each iteration until the convergence condition is met.

7. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 6, characterized in that, In the real-time focus control of step S4, the hardware architecture of the ophthalmic camera serves as the physical carrier for the method's implementation, with its core being the RGB module of the ophthalmic visual imaging device. This module employs a four-layer collaborative design: the front end is configured with an optical filter group, including an infrared cut-off filter (IR-Cut Filter) and a visible light band enhancement filter, used to eliminate environmental infrared interference and improve the contrast of ocular blood vessels and iris texture; subsequently coupled is a high frame rate CMOS image sensor, whose high-speed image reading capability forms the hardware basis for real-time calculation of sharpness scores during the rapid calibration stage; the optical core uses an electric zoom lens, which integrates two independently driven voice coil motors (VCMs). The zoom motor is responsible for continuously adjusting the lens group spacing to change the optical magnification, with a typical travel range of 3mm to 15mm, corresponding to an optical zoom ratio of 1.5x to 5x; the focus motor precisely controls the imaging plane position to compensate for image distance drift caused by zooming, with a displacement accuracy of ±1μm and a repeatability error of <0.5μm. The top layer is controlled by a multi-core heterogeneous main control chip, in which the CPU runs the Linux system to schedule the autofocus algorithm, and the FPGA processes the image sharpness score and motor drive pulses in real time. When a doctor adjusts the zoom level using the device's knob, the Zoom motor receives a pulse width modulation (PWM) signal to drive the lens assembly to shift, simultaneously triggering a triple response chain:

1. Zoom position feedback loop: The zoom motor displacement is monitored in real time by the Hall sensor built into the lens, and the current position z is transmitted to the main controller with 12-bit ADC precision and 0.01mm resolution; 2. Real-time query of fitted curve: The master controller queries the reconstructed Zoom-Focus curve y=Ae based on the z-value. -kx +B Interpolation calculation of target focus position f target The calculation delay is <1ms; 3. Focus position execution loop: The Focus motor is based on f target A step-like micro-displacement is generated with a typical response time of 8ms / step. Simultaneously, the image sensor captures a new frame within 5ms after the displacement is completed, and the actual imaging quality is verified by the sharpness scoring function. The innovative synergy of this hardware system is reflected in the following aspects: the wide dynamic range of the zoom motor, covering the entire focal length from 10cm to 0.5cm object distance, complements the ultra-high precision of the focusing motor; while the parallel processing capability of the main control chip, the real-time calculation of the Jacobian matrix by the FPGA, and the asynchronous updating of the fitting curve by the CPU ensure that the duration of image blurring is compressed to ≤33ms below the human visual persistence limit when the doctor continuously rotates the zoom ring. Clinical tests show that even under extreme conditions of 5cm object distance and 4mm / s zoom speed, the system can still maintain diagnostic-grade clarity with an MTF50 value >0.

3.

8. The fitting method for automatic fast zoom and focus tracking of an ophthalmic camera as described in claim 7, characterized in that, In the real-time focus control stage of step S4, the system ensures that the dynamic focusing response time is strictly less than 0.1 seconds through a third-order collaborative acceleration mechanism. This is the critical threshold for eliminating image blur perceptible to the human eye. This mechanism achieves a breakthrough first at the hardware drive layer: the focusing motor adopts a pre-loaded flux-optimized voice coil motor (VCM), and its step response time is compressed from the conventional 25ms to ≤8ms. This is thanks to three innovations: Phase-leading current drive: Based on the motor inductance-back EMF model, the controller pre-injects 150% of the rated current to overcome static friction when receiving the target position command, and then switches to PID closed-loop control. Position feedback upgrade: The traditional potentiometer is replaced with a 16-bit magnetic encoder with a resolution of 0.15μm and a sampling rate of 10kHz, which shortens the real-time position error compensation cycle to 0.1ms. Mechanical resonance suppression: Active damping adhesive is embedded in the motor bracket to reduce the mechanical resonance peak from 800Hz to below 200Hz, thus avoiding displacement overshoot; The intermediate control algorithm further optimizes the timing: when the zoom position z changes, the system performs dual-channel calculations in parallel. Curve interpolation channel: The exponential function f is directly calculated using hardware logic circuits based on the fitting parameters A,k,B pre-stored in the FPGA. target =Ae -kz +B, where f target Interpolate for the target; Nearest neighbor prediction channel: Simultaneously start dual-thread search. Thread 1 locates the nearest calibration point ZoomC to z, and thread 2 retrieves the next nearest point ZoomD and its corresponding historical focus position f. n f n+1 Load into cache; if the interpolation result f target Compared with the predicted value of 0.5 (f) n +f n+1 If the deviation is greater than 5%, the fitting curve verification process will be triggered immediately. The top-level real-time verification system starts simultaneously with the motor movement: the CMOS sensor outputs an image stream at a rate of 120fps, and completes ROI locking, iris texture segmentation, and sharpness assessment within 3.3ms after each frame arrives; Adaptive dual threshold strategy: The maximum score is 2000. When the Laplace variance value is L... var A value greater than 1500 indicates successful focus. If L var If the value is less than 1200, micro-step compensation is initiated, with each step being 2μm, until L... var Three consecutive frames >1400. Actual test data shows that, at an object distance of 5cm and a zoom speed of 6mm / s, the average time from zooming to restoring the diagnostic-grade sharpness MTF50>0.25 is 68ms±12ms; this performance has passed the ISO 13485 medical device response time certification and meets the clinical requirement of no perceptible blur in 93.7% of operating conditions.

Citation Information

Patent Citations

  • Automatic laser focus following method, device and equipment

    CN119395852A

Cited By

  • Wide-temperature adaptive continuous zooming television camera control method and system

    CN122317416A