Infrared thermal imaging rapid automatic focusing method and system
By optimizing the focus algorithm of infrared thermal imaging equipment, combining Gaussian and median filters, dynamically adjusting the motor step size and direction, the problems of focus oscillation and time-consuming are solved, and a smooth and fast focus effect is achieved, which is suitable for complex environments such as security monitoring.
Patent Information
- Application Number
- CN202510887006.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-06-30
AI Technical Summary
Existing infrared thermal imaging devices have problems of large sense of oscillation and time-consuming when focusing, especially when scene switching or focusing is triggered, which affects the user experience.
A fast automatic focusing method for infrared thermal imaging is adopted. Through steps such as image data acquisition, clarity evaluation, median filtering processing, overshoot detection and fallback, combined with Gaussian filter and median filter, the focus algorithm is optimized, and the motor step size and direction are dynamically adjusted to achieve smooth focus.
It significantly reduces focus oscillation, improves focus speed and accuracy, is suitable for security monitoring applications in complex environments, and enhances the application range and effect of the equipment.
Smart Images

Figure CN120455843A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of infrared imaging, and in particular to a method and system for rapid automatic focusing of infrared thermal imaging. Background Art
[0002] Currently, the automatic focus solutions of existing products mostly use a large-scale search for clear points to focus. This focusing method usually causes a large degree of image oscillation when switching scenes and triggering focus, affecting the user experience. In particular, when the current image is already relatively clear but focus still needs to be triggered, the image will first be blurred over a large area, then clear again, and then blurred again, thus causing a sense of oscillation and increasing focusing time.
[0003] In summary, a method and system for rapid automatic focusing of infrared thermal imaging is needed to address the deficiencies in the prior art. Summary of the Invention
[0004] In view of the shortcomings of the existing technology, the present invention provides an infrared thermal imaging fast automatic focusing method and system, aiming to solve the above problems.
[0005] To achieve the above object, the present invention provides the following technical solution: a method for rapid automatic focusing of infrared thermal imaging, comprising the following steps:
[0006] Step S1: Image data acquisition: The thermal imaging detector captures the thermal radiation of the object being photographed. The lens focuses the infrared thermal radiation image onto the infrared sensor, collects the original image data, and sends it to the FPGA module for processing.
[0007] Step S2: clarity evaluation calculation, extracting image edge information and calculating the clarity evaluation value of the current image using a clarity evaluation function;
[0008] Step S3: median filtering, storing the clarity evaluation value data of each frame of the image into a queue, sorting the clarity evaluation values in the queue, and taking the median as the clarity evaluation value after filtering;
[0009] Step S4: Record the maximum value of the clarity evaluation value and the corresponding Focus motor position in real time;
[0010] Step S5: Control the focus direction and step length, calculate the slope of the clarity evaluation value curve, and adjust the Focus motor step length according to the slope;
[0011] Step S6: Overshoot detection and retraction, detect the clarity evaluation value. If the clarity evaluation value continuously decreases, it is determined that the Focus motor has passed the clarity point, and the Focus motor is driven to reverse and retract to the recorded maximum clarity evaluation value position to complete the focus.
[0012] Optionally, in step S1, the FPGA module performs image preprocessing in the following manner:
[0013] The image is smoothed by using a Gaussian filter, and the degree of smoothing is controlled by adjusting the standard deviation;
[0014] The Gaussian filter formula is:
[0015] ,
[0016] Where σ is the standard deviation, x is the horizontal coordinate of the pixel, and y is the vertical coordinate of the pixel.
[0017] Optionally, in step S3, the median is taken as the filtered clarity evaluation value in the following manner:
[0018] Set the queue length to L and determine the queue length. If the queue length is an odd number, the median is:
[0019] , ,
[0020] If the queue length is even, the median is:
[0021] .
[0022] Optionally, the slope of the clarity evaluation value curve in step S5 is calculated by:
[0023] D fv = (FV1-FV2) / FV2, where FV1 is the current field clarity evaluation value and FV2 is the previous field clarity evaluation value.
[0024] Optionally, in step S5, the Focus motor step size is adjusted according to the slope in the following manner:
[0025] When the slope is less than the slope threshold and the clarity evaluation value curve is flat, increase the Focus motor step size;
[0026] When the slope exceeds the slope threshold, the Focus motor step size is reduced.
[0027] Optionally, when the Focus motor is in the clarity peak area, the step length of the Focus motor and the slope of the curve D fv The step size adjustment is proportional to:
[0028] , where k and m are compensation adjustment coefficients, k is the scaling amount of the slope, m is the offset of the slope value, D fv is the slope of the clarity evaluation value curve.
[0029] An infrared thermal imaging fast automatic focusing system adopts the infrared thermal imaging fast automatic focusing method, including an infrared thermal imaging core module, a data processing module, a median filter module, a focus control algorithm module, an overshoot detection and backoff module, and a motor drive module;
[0030] Infrared thermal imaging core module, used to collect infrared thermal radiation data of target objects;
[0031] A data processing module is used to receive the original image and perform bottom-level filtering, edge extraction and clarity evaluation;
[0032] The median filter module is used to perform sliding window median filtering on the clarity evaluation value to eliminate abnormal data;
[0033] Focus control algorithm module, used to dynamically adjust motor compensation according to the slope of the clarity evaluation value and control the focus direction;
[0034] The overshoot detection and backoff module is used to detect when the clarity evaluation value continuously decreases and trigger the backoff mechanism to drive the motor back to the position of the maximum clarity evaluation value;
[0035] The motor drive module is used to receive algorithm instructions, control motor movement, and adjust the lens optical path.
[0036] Optionally, the infrared thermal imaging module has the following working process: the infrared detector captures thermal radiation data, generates an original grayscale image, and transmits it to the FPGA module;
[0037] The workflow of the data processing module is as follows: receiving the original grayscale image, performing Gaussian filtering, extracting edge information, and calculating the current clarity evaluation value.
[0038] Optionally, the workflow of the median filter module is as follows: set the queue length, update the clarity evaluation value data in real time using a sliding window, and output the median after sorting;
[0039] The working process of the focus control algorithm module is: calculating the slope of the clarity evaluation value curve, and dynamically adjusting the step size according to the calculated slope.
[0040] Optionally, the overshoot detection and backoff module operates as follows: detecting the clarity evaluation value, and when detecting that the clarity evaluation value continuously decreases, backing off to the maximum clarity evaluation value position, and focusing is completed.
[0041] Beneficial effects of the present invention:
[0042] 1. By optimizing the focusing algorithm, the present invention reduces the large fluctuations that occur in traditional focusing methods when switching between images or triggering focus, providing a smoother user experience and significantly accelerating focusing speed without sacrificing focus accuracy. In particular, when far from a clear point, the step size can be increased to quickly approach the peak point; when approaching a clear point, the step size is reduced to ensure precise positioning.
[0043] 2. In this invention, a Gaussian filter is introduced to eliminate noise interference, and a median filter is used to process abnormal data, thereby improving the accuracy and reliability of the clarity evaluation value, thereby enhancing the precision of focus. It is suitable for security monitoring applications in scenes with high and low temperature differences, can effectively cope with challenges in complex environments, and enhance the application scope and effect of infrared thermal imaging equipment;
[0044] 3. In the present invention, in order to address the problem of low control accuracy of DC motors, the step size is adjusted by adjusting the coefficients k and m, which effectively reduces the overshoot when approaching the clear point and ensures the smoothness of the focusing process. The system can record the maximum clarity evaluation value and its corresponding focus position information in real time, and when it detects that the clarity begins to decrease, it reverses and falls back to the optimal focus position to fix the focus, further ensuring the accuracy and efficiency of focusing. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 The present invention is a schematic diagram of a process structure of a method.
[0046] Figure 2 This is a clarity evaluation value curve diagram before median filtering of the present invention.
[0047] Figure 3 This is a clarity evaluation value curve diagram after median filtering of the present invention. DETAILED DESCRIPTION
[0048] In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0049] like Figure 1 、 2 As shown in FIG3 , a method for rapid automatic focusing of infrared thermal imaging comprises the following steps:
[0050] Step S1: Image data acquisition: The thermal imaging detector captures the thermal radiation of the object being photographed. The lens focuses the infrared thermal radiation image onto the infrared sensor, collects the original image data, and sends it to the FPGA module for processing.
[0051] Step S2: clarity evaluation calculation, extracting image edge information and calculating the clarity evaluation value of the current image using a clarity evaluation function;
[0052] Step S3: median filtering, storing the clarity evaluation value data of each frame of the image into a queue, sorting the clarity evaluation values in the queue, and taking the median as the clarity evaluation value after filtering;
[0053] Step S4: Record the maximum value of the clarity evaluation value and the corresponding Focus motor position in real time;
[0054] Step S5: Control the focus direction and step length, calculate the slope of the clarity evaluation value curve, and adjust the Focus motor step length according to the slope;
[0055] Step S6: Overshoot detection and retraction, detect the clarity evaluation value. If the clarity evaluation value continuously decreases, it is determined that the Focus motor has passed the clarity point, and the Focus motor is driven to reverse and retract to the recorded maximum clarity evaluation value position to complete the focus.
[0056] Infrared thermal imaging sensors typically consist of specialized components such as a thermal imaging lens and a thermal imaging detector. The thermal imaging detector primarily captures the subject's thermal radiation, while the lens focuses the infrared thermal radiation image onto the infrared sensor. After acquiring the raw image data, the thermal imaging detector feeds the grayscale data into the FPGA module for processing. The FPGA uses an underlying filtering algorithm to extract edge information from the current image source data and, using a clarity evaluation function, calculates and outputs the image clarity evaluation value, or Focus Value (FV). Generally, the clearer the image, the higher the clarity evaluation value.
[0057] Changing the Focus motor position alters the optical path in the lens, ultimately causing the focal plane of the image to fall on the sensor plane, resulting in a clear image. The autofocus algorithm module uses the current and historical image clarity evaluation values to determine the direction and step size of the Focus motor to drive, and then moves the motor to achieve a clear image. To further improve the accuracy of the clarity evaluation value and eliminate noise interference, a Gaussian filter is introduced in the filtering stage.
[0058] The image is smoothed by using a Gaussian filter, and the degree of smoothing is controlled by adjusting the standard deviation;
[0059] The Gaussian filter formula is:
[0060] ,
[0061] Where σ is the standard deviation, x is the horizontal coordinate of the pixel, and y is the vertical coordinate of the pixel.
[0062] The slope of the clarity rating curve is calculated as follows:
[0063] D fv = (FV1-FV2) / FV2, where FV1 is the current field clarity evaluation value and FV2 is the previous field clarity evaluation value.
[0064] When the current Focus motor position is far away from the clear point, the curve is relatively flat, that is, when the motor moves one step, the clarity evaluation value does not change much, that is, D fv is smaller, then you can increase the step size and quickly approach the peak point. When the real-time curve slope exceeds the preset slope threshold, deceleration is performed. Considering that the current thermal imaging lens uses a DC motor; compared with the stepper motor, the DC motor has the problem of low control accuracy. Therefore, even if the current curve slope exceeds the preset threshold Dthreshold, and the drive step size is reduced at the software level, there is still a large overshoot problem. Therefore, when approaching the clear point, it is necessary to further reduce the speed; according to the test data, the curve near the clear point is basically smooth, and its shape is close to the shape near the peak point of the normal distribution function curve, that is, when approaching the peak point, the step size of the Focus motor and the slope of the curve D fv Directly proportional, that is, D fv The smaller is, the smaller is the step size; so it can be expressed by the following formula:
[0065] , where k and m are compensation adjustment coefficients, k is the scaling amount of the slope, m is the offset of the slope value, D fv is the slope of the clarity evaluation value curve.
[0066] Because D fv It is positive before reaching the peak point, so the step adjustment amount is negative. fv The smaller it is, the closer the current Focus is to the clear point, and the smaller the step adjustment value △step is. When superimposed on the current step data, it is manifested as a smaller step size. By adjusting the coefficients k and m, the overshoot of the clear point during autofocus can be effectively reduced, thereby reducing overshoot and oscillation without sacrificing focusing speed.
[0067] If the current Focus motor position is in a state where the image is very blurry, the FV curve will usually have no trend or appear glitchy, and may even have occasional abnormal data. At this time, if the Focus adjustment step size is small, the final focus may be in a blurry position, resulting in focusing failure.
[0068] To address this type of problem, this algorithm introduces a sliding window median filter module. After the Focus motor obtains the clarity evaluation information for each frame, the current data is sent to the data queue Q. The data arrangement of this queue is FILO (First In Last Out). The queue length L can be configured according to the actual debugging effect. Every time the Focus motor moves, the sliding window moves synchronously and fills the current FV data into the queue Q. When the data is filled, the entire data queue is sorted from small to large, and the median is taken and output.
[0069] Set the queue length to L and determine the queue length. If the queue length is an odd number, the median is:
[0070] , ,
[0071] If the queue length is even, the median is:
[0072] .
[0073] Indicates that the output filtered data is the mean of the two middle data after the data are sorted.
[0074] During this process, the program records the maximum FV value and its corresponding Focus position in real time. When the program detects that the FV value begins to decrease and continues to decrease for n steps, it assumes that the Focus motor has passed the sharp point and drives the Focus motor back m steps to the Focus position with the maximum FV value, thus completing the focusing process.
[0075] An infrared thermal imaging fast automatic focusing system adopts the infrared thermal imaging fast automatic focusing method, including an infrared thermal imaging core module, a data processing module, a median filter module, a focus control algorithm module, an overshoot detection and backoff module, and a motor drive module;
[0076] Infrared thermal imaging core module, used to collect infrared thermal radiation data of target objects;
[0077] A data processing module is used to receive the original image and perform bottom-level filtering, edge extraction and clarity evaluation;
[0078] The median filter module is used to perform sliding window median filtering on the clarity evaluation value to eliminate abnormal data;
[0079] Focus control algorithm module, used to dynamically adjust motor compensation according to the slope of the clarity evaluation value and control the focus direction;
[0080] The overshoot detection and backoff module is used to detect when the clarity evaluation value continuously decreases and trigger the backoff mechanism to drive the motor back to the position of the maximum clarity evaluation value;
[0081] The motor drive module is used to receive algorithm instructions, control motor movement, and adjust the lens optical path.
[0082] The infrared thermal imaging module’s workflow is as follows: the infrared detector captures thermal radiation data, generates a raw grayscale image, and transmits it to the FPGA module;
[0083] The workflow of the data processing module is as follows: receiving the original grayscale image, performing Gaussian filtering, extracting edge information, and calculating the current clarity evaluation value.
[0084] The workflow of the median filter module is as follows: set the queue length, update the clarity evaluation value data in real time through the sliding window, and output the median after sorting;
[0085] The working process of the focus control algorithm module is: calculate the slope of the clarity evaluation value curve and dynamically adjust the step size according to the calculated slope.
[0086] The workflow of the overshoot detection and backoff module is as follows: the clarity evaluation value is detected, and when it is detected that the clarity evaluation value continuously decreases, it is backed off to the maximum clarity evaluation value position, and the focus is completed.
[0087] By optimizing the focusing algorithm, this invention reduces the large fluctuations that occur in traditional focusing methods when switching between images or triggering focus, providing a smoother user experience. It can significantly speed up focusing without sacrificing focus accuracy. In particular, when far from a clear point, the step size can be increased to quickly approach the peak point; when approaching a clear point, the step size is reduced to ensure precise positioning.
[0088] A Gaussian filter is introduced to eliminate noise interference, and a median filter is used to process abnormal data, which improves the accuracy and reliability of the clarity evaluation value, thereby enhancing the precision of focus. This makes it suitable for security monitoring applications in scenes with high and low temperature differences, can effectively cope with challenges in complex environments, and enhances the application range and effectiveness of infrared thermal imaging equipment.
[0089] To address the problem of low DC motor control accuracy, the step size is adjusted by adjusting the coefficients k and m, which effectively reduces the overshoot when approaching the clarity point and ensures the smoothness of the focusing process. The system can record the maximum clarity evaluation value and its corresponding focus position information in real time, and when it detects that the clarity begins to decrease, it reverses to the optimal focus position to focus, further ensuring the accuracy and efficiency of focusing.
[0090] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions or improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
[0091] The embodiment described above is only a preferred solution of the present application and does not limit the present application in any form. There are other variations and modifications without exceeding the technical solution described in the claims.
Claims
1. A fast automatic focusing method for infrared thermal imaging, characterized in that: The following steps are involved: Step S1: Image data acquisition: The thermal imaging detector captures the thermal radiation of the object being photographed. The lens focuses the infrared thermal radiation image onto the infrared sensor, collects the original image data, and sends it to the FPGA module for processing. Step S2: clarity evaluation calculation, extracting image edge information and calculating the clarity evaluation value of the current image using a clarity evaluation function; Step S3: median filtering, storing the clarity evaluation value data of each frame of the image into a queue, sorting the clarity evaluation values in the queue, and taking the median as the clarity evaluation value after filtering; Step S4: Record the maximum value of the clarity evaluation value and the corresponding Focus motor position in real time; Step S5: Control the focus direction and step length, calculate the slope of the clarity evaluation value curve, and adjust the Focus motor step length according to the slope; Step S6: Overshoot detection and retraction, detect the clarity evaluation value. If the clarity evaluation value continuously decreases, it is determined that the Focus motor has passed the clarity point, and the Focus motor is driven to reverse and retract to the recorded maximum clarity evaluation value position to complete the focus.
2. The infrared thermal imaging rapid automatic focusing method according to claim 1, characterized in that: In step S1, the FPGA module performs image preprocessing in the following manner: The image is smoothed by using a Gaussian filter, and the degree of smoothing is controlled by adjusting the standard deviation; The Gaussian filter formula is: , Where σ is the standard deviation, x is the horizontal coordinate of the pixel, and y is the vertical coordinate of the pixel.
3. The infrared thermal imaging rapid automatic focusing method according to claim 1, characterized in that: In step S3, the median is taken as the filtered clarity evaluation value in the following manner: Set the queue length to L and determine the queue length. If the queue length is an odd number, the median is: , , If the queue length is even, the median is: 。 4. The infrared thermal imaging rapid automatic focusing method according to claim 1, characterized in that: The slope of the clarity evaluation value curve in step S5 is calculated as follows: D fv = (FV1-FV2) / FV2, where FV1 is the current field clarity evaluation value and FV2 is the previous field clarity evaluation value.
5. The infrared thermal imaging rapid automatic focusing method according to claim 4, characterized in that: In step S5, the Focus motor step size is adjusted according to the slope in the following manner: When the slope is less than the slope threshold and the clarity evaluation value curve is flat, increase the Focus motor step size; When the slope exceeds the slope threshold, the Focus motor step size is reduced.
6. The infrared thermal imaging rapid automatic focusing method according to claim 5, characterized in that: When the Focus motor is in the peak clarity area, the step length of the Focus motor and the slope of the curve D fv The step size adjustment is proportional to: , where k and m are compensation adjustment coefficients, k is the scaling amount of the slope, m is the offset of the slope value, D fv is the slope of the clarity evaluation value curve.
7. An infrared thermal imaging fast autofocus system, using the infrared thermal imaging fast autofocus method according to any one of claims 1 to 6, characterized in that: It includes infrared thermal imaging core module, data processing module, median filter module, focus control algorithm module, overshoot detection and backoff module and motor drive module; Infrared thermal imaging core module, used to collect infrared thermal radiation data of target objects; A data processing module is used to receive the original image and perform bottom-level filtering, edge extraction and clarity evaluation; The median filter module is used to perform sliding window median filtering on the clarity evaluation value to eliminate abnormal data; Focus control algorithm module, used to dynamically adjust motor compensation according to the slope of the clarity evaluation value and control the focus direction; The overshoot detection and backoff module is used to detect when the clarity evaluation value continuously decreases and trigger the backoff mechanism to drive the motor back to the position of the maximum clarity evaluation value; The motor drive module is used to receive algorithm instructions, control motor movement, and adjust the lens optical path.
8. The infrared thermal imaging fast automatic focusing system according to claim 7, characterized in that: The infrared thermal imaging module workflow is as follows: the infrared detector captures thermal radiation data, generates an original grayscale image, and transmits it to the FPGA module; The workflow of the data processing module is as follows: receiving the original grayscale image, performing Gaussian filtering, extracting edge information, and calculating the current clarity evaluation value.
9. The infrared thermal imaging fast automatic focusing system according to claim 7, characterized in that: The workflow of the median filter module is as follows: set the queue length, update the clarity evaluation value data in real time through a sliding window, and output the median after sorting; The working process of the focus control algorithm module is: calculating the slope of the clarity evaluation value curve, and dynamically adjusting the step size according to the calculated slope.
10. The infrared thermal imaging fast automatic focusing system according to claim 7, characterized in that: The working process of the overshoot detection and backoff module is as follows: detecting the clarity evaluation value, and when detecting that the clarity evaluation value continuously decreases, backing off to the maximum clarity evaluation value position, and focusing is completed.
Citation Information
Patent Citations
Auto-focusing method and device of thermal imager
CN101660946A
Automatic focus adjustment method for zoom camera systems
CN106534676A
Automatic focusing method and device
CN106921830A
Automatic focusing method based on image processing
CN111770271A
Focusing method and device based on multi-region active transformation
CN112672039A