An autofocus method, apparatus and electronic device

By combining the collaborative judgment of image sharpness and temporal variation parameters, the problem of false triggering of autofocus technology in complex scenes is solved, improving accuracy and stability while avoiding increased hardware costs and power consumption.

CN123123719APending Publication Date: 2026-11-17深圳今日芯科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611120564.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing autofocus technology is prone to false triggering in complex scenes due to target movement, device shake, or scene changes, and the introduction of additional hardware increases system cost and power consumption.

Method used

By acquiring continuous image frame data from the image acquisition device, and making a collaborative judgment based on image sharpness evaluation parameters and time-domain variation parameters, the autofocus operation is triggered only when preset conditions are met, thus avoiding the need for additional hardware.

Benefits of technology

It improves the accuracy and stability of autofocus trigger judgment, reduces the false trigger rate, reduces the amount of computation and system resource consumption, and reduces hardware cost and power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123719A_ABST
    Figure CN123123719A_ABST
Patent Text Reader

Abstract

This application relates to the field of autofocus technology, and discloses an autofocus method, apparatus, and electronic device. The method includes: acquiring continuous image frame data acquired by an image acquisition device; acquiring image sharpness evaluation parameters of the current image frame based on the continuous image frame data; if the image sharpness evaluation parameters of the current image frame meet a first preset condition, acquiring temporal variation parameters of the current image frame based on the continuous image frame data; and triggering the image acquisition device to perform autofocus operation if the temporal variation parameters of the current image frame meet a second preset condition. This application can reduce false triggering, reduce invalid focusing, reduce computational load, eliminate the need for additional hardware, and improve the accuracy and stability of autofocus trigger control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of autofocus technology, and more particularly to an autofocus method, apparatus and electronic device. Background Technology

[0002] With the widespread application of smartphones, security cameras, vehicle-mounted cameras, and industrial vision systems, autofocus (AF) technology has become an important component for improving image quality. Existing AF solutions typically rely on image evaluation metrics to reflect the current image quality and control the autofocus process based on changes in these metrics to achieve better imaging results. Due to its simplicity and high computational efficiency, this type of solution has become a common implementation method in current AF systems.

[0003] However, in practical applications, image evaluation metrics are influenced by a variety of factors. These variations can stem from changes in image quality, target state, environmental changes, the acquisition process, and other interfering factors. Therefore, triggering autofocus solely based on a single image evaluation metric can easily lead to inaccurate triggering control in complex scenarios. On the other hand, to improve autofocus control, some existing technologies employ the addition of auxiliary detection modules or the introduction of additional information sources. However, such solutions typically require increased hardware resources or system complexity, leading to increased equipment cost, power consumption, and implementation difficulty. Summary of the Invention

[0004] One objective of this application is to provide an autofocus method, apparatus, and electronic device to solve the technical problem of how to improve the accuracy of autofocus trigger judgment and reduce the false trigger rate in complex scenes without adding additional hardware.

[0005] To address the aforementioned technical problems, one technical solution adopted in this application is: providing an autofocus method, the method comprising: acquiring continuous image frame data acquired by an image acquisition device; acquiring image sharpness evaluation parameters of the current image frame based on the continuous image frame data; acquiring temporal variation parameters of the current image frame based on the continuous image frame data when the image sharpness evaluation parameters of the current image frame meet a first preset condition; and triggering the image acquisition device to perform autofocus operation when the temporal variation parameters of the current image frame meet a second preset condition.

[0006] In some embodiments, obtaining image sharpness evaluation parameters for the current image frame based on continuous image frame data includes: determining the current image frame based on continuous image frame data; obtaining the pixel grayscale value corresponding to the target region in the current image frame; calculating the grayscale variance corresponding to the target region based on the pixel grayscale value, and using the grayscale variance corresponding to the target region as the image sharpness evaluation parameter for the current image frame.

[0007] In some embodiments, when the image sharpness evaluation parameters of the current image frame meet the first preset condition, the temporal variation parameters of the current image frame are obtained based on continuous image frame data, including: when the gray-level variance corresponding to the target region is greater than the first preset threshold, the temporal variation parameters of the current image frame are obtained based on continuous image frame data; wherein, the first preset threshold includes a sharpness threshold.

[0008] In some embodiments, the method further includes: obtaining the brightness parameters of the current image frame and determining the corresponding brightness level based on the brightness parameters; and adjusting the sharpness threshold based on the brightness level.

[0009] In some embodiments, obtaining the temporal variation parameter of the current image frame based on continuous image frame data includes: obtaining the pixel grayscale value of the corresponding position of the current image frame and the adjacent historical image frame based on continuous image frame data; calculating the difference between the pixel grayscale value of the corresponding position of the current image frame and the adjacent historical image frame to obtain the pixel change amount; obtaining the temporal difference value of the current image frame based on the pixel change amount, and using the temporal difference value as the temporal variation parameter.

[0010] In some embodiments, obtaining the temporal variation parameters of the current image frame based on continuous image frame data includes: performing optical flow calculation based on continuous image frame data to obtain the pixel motion vector corresponding to the current image frame; calculating the motion change amount corresponding to the current image frame based on the pixel motion vector, and determining the motion change amount as the temporal variation parameter of the current image frame.

[0011] In some embodiments, when the temporal variation parameter of the current image frame meets a second preset condition, the image acquisition device is triggered to perform an autofocus operation, including: when the temporal difference value of the current image frame is less than a second preset threshold, the image acquisition device is triggered to perform an autofocus operation; wherein, the second preset threshold includes a motion threshold.

[0012] In some embodiments, the method further includes: obtaining temporal variation parameters corresponding to multiple historical image frames within a preset historical time window; determining historical temporal variation parameter statistics based on the temporal variation parameters corresponding to the multiple historical image frames; and determining a second preset threshold based on the historical temporal variation parameter statistics; wherein the historical temporal variation parameter statistics include the average value of the temporal variation parameters of the multiple historical image frames.

[0013] To address the aforementioned technical problems, one technical solution adopted in this application is: providing an autofocus device, comprising: a continuous image frame data acquisition module for acquiring continuous image frame data acquired by an image acquisition device; an image sharpness evaluation parameter determination module for acquiring image sharpness evaluation parameters of the current image frame based on the continuous image frame data; a temporal variation parameter determination module for acquiring temporal variation parameters of the current image frame based on the continuous image frame data when the image sharpness evaluation parameters of the current image frame meet a first preset condition; and an autofocus module for triggering the image acquisition device to perform autofocus operation when the temporal variation parameters of the current image frame meet a second preset condition.

[0014] To solve the above-mentioned technical problems, one technical solution adopted in this application is: to provide an electronic device, including: a memory and a processor, wherein the memory is connected to the processor, and the processor is used to execute one or more computer programs stored in the memory, wherein when the processor executes the one or more computer programs, the electronic device implements an autofocus method applicable to the electronic device.

[0015] Beneficial Effects: The autofocus method, apparatus, and electronic device provided in this application acquire continuous image frame data from an image acquisition device. First, they obtain image sharpness evaluation parameters for the current image frame. Only when the image sharpness evaluation parameters meet a first preset condition are the temporal change parameters of the current image frame further acquired. Then, based on the temporal change parameters, a decision is made on whether to trigger autofocus. Because the autofocus triggering adopts a tiered decision mechanism, further analysis of the temporal change information of continuous image frames is only performed when an autofocus requirement is initially determined. Therefore, the temporal change characteristics in continuous image frames can be used to further verify the image sharpness evaluation results, effectively reducing false autofocus triggering caused by non-focus change factors such as target movement, device shake, or scene changes, and improving the accuracy and stability of autofocus triggering judgment. Meanwhile, the solution in this embodiment completes temporal change analysis using continuous image frames acquired by the image acquisition device, eliminating the need for additional hardware such as gyroscopes and inertial measurement units, thus reducing system hardware costs and power consumption. Furthermore, the temporal change parameters are determined only when the image sharpness evaluation parameters meet a first preset condition, avoiding temporal change analysis for all image frames, reducing algorithm computation and system resource consumption, and achieving improved autofocus performance without significantly increasing system complexity. Therefore, the solution in this application embodiment can reduce false triggering, reduce invalid focusing, reduce computational load, eliminate the need for additional hardware, and improve the accuracy and stability of autofocus trigger control. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application; Figure 2 This is a flowchart illustrating an autofocus method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an autofocus device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0019] It should be noted that the user personal information involved in this application embodiment is all authorized (knowing and consenting) by the relevant parties or fully authorized by all parties, and the executing entity can obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with the relevant laws and regulations of the relevant countries and regions, and do not violate public order and good morals.

[0020] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. Moreover, the terms "first," "second," and "third" used in this application do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.

[0021] Auto focus (AF) is an automatic control technology in which an image acquisition device evaluates the current image quality by acquiring image information and automatically adjusts the lens focus position based on the evaluation results, so that the subject being photographed achieves or approaches the optimal image sharpness.

[0022] The relevant autofocus system uses the variance-based focus assessment method as the trigger for autofocus. This method calculates the variance of pixel grayscale values ​​in local areas of an image and evaluates the sharpness of the current image based on the magnitude of the variance. When the variance reaches a preset threshold, autofocus is triggered. Since image sharpness is correlated with the degree of grayscale change, this method is simple to implement, computationally inexpensive, and has good real-time performance, making it widely used in image acquisition devices such as smartphones. However, image grayscale variance reflects the dispersion of the image's grayscale distribution and does not directly reflect the true cause of changes in image sharpness. When the subject moves, the camera shakes, or the scene changes rapidly, large pixel grayscale changes occur between consecutive images, altering the grayscale distribution in image edge regions and causing significant fluctuations in the local variance value. At this point, even if the lens focus has not shifted, the system may still misinterpret the variance change as a decrease in sharpness, thereby incorrectly triggering autofocus, causing frequent lens adjustments, or even focusing oscillations. This not only affects the continuity and stability of image acquisition, but also increases the response time of autofocus control and the ineffective actions of the actuator.

[0023] To address the aforementioned issues, some solutions attempt to introduce auxiliary detection information into the autofocus system. For example, they integrate external sensors such as gyroscopes and inertial measurement units (IMUs) to acquire changes in the device or scene state, and then suppress or adjust the autofocus triggering process based on the detection results. However, such solutions require additional hardware components, increasing system cost and power consumption, as well as the complexity of device structure design and control. Furthermore, because the external sensors and the autofocus evaluation process are independent, there is a lack of coordinated optimization between them for the autofocus triggering logic, making it difficult to fully utilize the information contained within the image itself to achieve efficient and accurate autofocus control.

[0024] This application embodiment performs collaborative judgment based on image sharpness evaluation parameters and temporal variation parameters. When the sharpness evaluation conditions are met, it further utilizes the change information between consecutive image frames to verify the current scene state. This distinguishes between image changes caused by focus changes and those caused by target movement or scene changes, reducing autofocus false triggers caused by non-focus factors and improving the accuracy and stability of autofocus trigger judgment. Simultaneously, this application embodiment uses existing information from the image acquisition process for auxiliary judgment, eliminating the need for additional external sensors such as gyroscopes and IMUs. This reduces system hardware costs and power consumption while improving the accuracy and stability of the autofocus system in complex scenes.

[0025] Please see Figure 1 , Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application. The application scenario includes an image acquisition device 10 and an electronic device 20.

[0026] The image acquisition device 10 is used to acquire continuous image frame data of the target scene and send the acquired continuous image frame data to the electronic device 20. The electronic device 20 processes the continuous image frame data to obtain the image sharpness evaluation parameters and temporal variation parameters corresponding to the current image frame, and detects whether to trigger the image acquisition device 10 to perform autofocus operation based on the image sharpness evaluation parameters and temporal variation parameters.

[0027] Specifically, the electronic device 20 acquires image sharpness evaluation parameters based on the current image frame, such as obtaining the sharpness of the current image by calculating the grayscale variance of pixel grayscale values ​​within the target area. When the image sharpness evaluation parameters meet preset conditions, it further acquires temporal variation parameters based on the change relationship between consecutive image frames, such as obtaining the degree of change between consecutive image frames through time difference. When the temporal variation parameters meet the autofocus triggering conditions, the electronic device 20 sends an autofocus control command to the image acquisition device 10 to control the image acquisition device 10 to adjust the lens focal length, thereby obtaining a sharp image.

[0028] The image acquisition device 10 can be a camera, surveillance equipment, mobile terminal camera module, or other device with image acquisition capabilities. The electronic device 20 can be a processing terminal, control chip, processor module, or server connected to the image acquisition device 10. The image acquisition device 10 and the electronic device 20 can exchange data via wired or wireless means.

[0029] In some embodiments, the image acquisition device 10 and the electronic device 20 are integrated into one device, which may specifically be a smartphone, tablet computer, smart camera, digital camera, etc. This device can analyze the acquired continuous image frame data through an internal processor, image processing chip, or other processing module, and determine whether to perform autofocus operation based on image sharpness evaluation parameters and temporal variation parameters.

[0030] In some embodiments, the image acquisition device 10 and the electronic device 20 may not be integrated into one device; that is, the image acquisition device 10 and the electronic device 20 can exist as independent devices. In this case, the image acquisition device 10 can be a standalone camera, a surveillance camera, a vehicle-mounted camera, etc., and the electronic device 20 can be a computer, server, edge computing device, or other electronic device with image processing capabilities that is communicatively connected to the image acquisition device 10.

[0031] Please see Figure 2 , Figure 2 This is a flowchart illustrating an autofocus method provided in an embodiment of this application. Figure 2 As shown, this method can be applied to the above-mentioned electronic device 20, and the method includes, but is not limited to, the following steps: S11. Acquire continuous image frame data collected by the image acquisition device.

[0032] When the image acquisition device is in image preview mode, video acquisition mode, photo capture mode, video recording mode, or monitoring mode, it can continuously acquire consecutive image frames of the target scene. The image acquisition device can output consecutive image frames at a preset frame rate, and the electronic device receives these consecutive image frames.

[0033] For example, when a smartphone is in camera preview mode, photo mode, or video recording mode, or when security cameras, vehicle cameras, etc. are in the process of real-time image acquisition, their respective image acquisition devices can continuously acquire image data of the target scene and form continuous image frame data.

[0034] Continuous image frame data refers to multiple image frames acquired sequentially by an image acquisition device within a continuous time period according to a preset sampling frequency or frame rate. These image frames have a temporal sequence and can reflect image information of the target scene at different acquisition times. In some embodiments, continuous image frame data includes the current image frame and one or more historical image frames adjacent to the current image frame.

[0035] S12. Based on continuous image frame data, obtain the image sharpness evaluation parameters of the current image frame.

[0036] Image sharpness evaluation parameters are parameters that reflect the sharpness of the current image frame. For example, they may include parameters reflecting the richness of image details, texture information, or edge information in the current image frame. In some embodiments, these image sharpness evaluation parameters include grayscale variance, grayscale standard deviation, sharpness score, gradient value, and other parameters that can reflect the image sharpness.

[0037] The methods for obtaining image sharpness evaluation parameters for the current image frame may include: extracting image features of the current image frame and determining image sharpness evaluation parameters based on these features; wherein, image features may include image gradient features, edge features, texture features, frequency domain features, or other features that can reflect the degree of image sharpness. Specifically, the image sharpness evaluation parameters can be determined based on the gradient information of the current image frame; or, based on the edge information of the current image frame; or, by performing frequency domain analysis on the current image frame and determining the image sharpness evaluation parameters based on the frequency domain features; or, by inputting the current image frame into a pre-trained image quality evaluation model and determining the image sharpness evaluation parameters based on the evaluation results output by the image quality evaluation model.

[0038] In this embodiment, the purpose of obtaining the image sharpness evaluation parameter is to evaluate the sharpness of the current image frame, serving as the first-level judgment criterion for autofocus triggering. The image sharpness evaluation parameter directly reflects the sharpness of the current image frame and can be used to initially determine whether the current image requires autofocus. When the image sharpness evaluation parameter meets the first preset condition, the temporal variation parameter of the current image frame is further determined to analyze whether the changes in the current image are caused by non-focus change factors such as target movement or scene changes, thereby avoiding false autofocus triggering due to motion interference. Furthermore, the temporal variation parameter is determined only when the image sharpness evaluation parameter meets the first preset condition, which avoids performing temporal variation analysis on all image frames, thus reducing the computational load of the algorithm and the consumption of system resources.

[0039] In some embodiments, step S12, obtaining the image sharpness evaluation parameters of the current image frame based on continuous image frame data, includes: S121. Determine the current image frame based on continuous image frame data.

[0040] Here, the current image frame is the image frame selected from the continuous image frame data that is currently being used to trigger autofocus. The current image frame can be any frame in the continuous image frame data. In addition, the historical image frame refers to one or more image frames acquired before the current image frame. For example, if the current image frame is F3, then the historical image frames can be F2 or F1, F2.

[0041] S122. Obtain the pixel grayscale value corresponding to the target region in the current image frame.

[0042] The target region can be the entire image region in the current image frame, or a portion of the image region in the current image frame, such as the center region of the current image frame, the autofocus region, or a user-specified region. The target region can also be divided into one or more local windows, and image analysis can be performed on each local window separately.

[0043] A pixel grayscale value refers to a numerical value that represents the brightness information of each pixel in an image. In a grayscale image, each pixel corresponds to a grayscale value.

[0044] For example, the target area in the current image frame can be defined as a 3×3 pixel window, and the grayscale value corresponding to each pixel within the 3×3 pixel window can be obtained.

[0045] S123. Calculate the grayscale variance corresponding to the target area based on the pixel grayscale value, and use the grayscale variance corresponding to the target area as the image sharpness evaluation parameter of the current image frame.

[0046] The grayscale variance can be calculated using the following formula: ; Where N is the number of pixels contained in the target region, and μ is the average grayscale value of each pixel in the target region. It is the grayscale value corresponding to the i-th pixel within the target area. It is the grayscale variance.

[0047] In some embodiments, N is the number of pixels contained in the current calculation window. For example, when the target area is a 3×3 pixel window, N is 9; μ is the average gray value of all pixels in the 3×3 pixel window. It is the grayscale value corresponding to the i-th pixel within a 3×3 pixel window.

[0048] In this embodiment, the gray-level variance corresponding to the target region is used as the image sharpness evaluation parameter of the current image frame. The gray-level variance reflects the degree of change in pixel gray-level distribution within the target region. When the image is sharp, the target region has rich details such as edges and textures, resulting in significant pixel gray-level changes and a typically large gray-level variance. Conversely, when the image is blurry, image details decrease, pixel gray-level changes become more gradual, and the corresponding gray-level variance is typically smaller. Therefore, the gray-level variance can be used to quantitatively evaluate the sharpness of the current image frame. Furthermore, based on this gray-level variance, it is possible to preliminarily determine whether the current image frame meets the conditions for further autofocus triggering. If the first preset condition is met, the cause of the current image change can be further analyzed by combining the temporal domain variation parameters, thereby improving the accuracy of the autofocus triggering judgment.

[0049] S13. If the image sharpness evaluation parameters of the current image frame meet the first preset condition, obtain the temporal variation parameters of the current image frame based on continuous image frame data.

[0050] First, the image sharpness evaluation parameters of the current image frame are compared with the first preset condition to determine whether the first preset condition is matched. If the first preset condition is matched, the temporal variation parameters are obtained; if the first preset condition is not matched, the autofocus operation is not triggered.

[0051] The first preset condition is a judgment condition set based on the image sharpness evaluation parameters, used to determine whether the current image frame needs to be further judged for autofocus triggering. The time-domain variation parameter is a parameter used to describe the degree of change between consecutive image frames over time.

[0052] For example, the first preset condition could be that the image sharpness evaluation parameter is greater than a preset sharpness threshold, or that the preset sharpness evaluation rule is met. The temporal variation parameter could be a parameter that reflects the changes in the image over time, such as time difference value, pixel motion amount, motion vector statistics, or optical flow change.

[0053] In some embodiments, step S13, when the image sharpness evaluation parameters of the current image frame meet a first preset condition, obtains the temporal variation parameters of the current image frame based on continuous image frame data, including: when the gray-level variance corresponding to the target region is greater than a first preset threshold, obtaining the temporal variation parameters of the current image frame based on continuous image frame data; wherein, the first preset threshold includes a sharpness threshold. Specifically, when the gray-level variance corresponding to the target region is greater than the sharpness threshold, the temporal variation parameters of the current image frame are obtained based on continuous image frame data.

[0054] The sharpness threshold is a preset threshold used to determine the sharpness of the current image frame. The sharpness threshold can be preset according to actual application needs, or it can be dynamically determined based on the image acquisition environment, device parameters, or historical image data.

[0055] In some embodiments, the method further includes: obtaining the brightness parameters of the current image frame and determining the corresponding brightness level based on the brightness parameters; adjusting the sharpness threshold based on the brightness level. For example, based on the brightness parameter L (0-255) of the current frame, the following calculation is made: Threshold1 = 100 + 0.5 × (L-128); where Threshold1 is the sharpness threshold; 100 is the reference value of the sharpness threshold, used to represent the initial sharpness threshold corresponding to the reference brightness condition; and 0.5 is the brightness adjustment coefficient.

[0056] For example, in low-light scenes (L<128), the sharpness threshold can be appropriately lowered to reduce the impact of image noise on the sharpness evaluation results and reduce false triggers; in high-light scenes (L>128), the sharpness threshold can be appropriately increased to improve the accuracy of sharpness judgment.

[0057] In some embodiments, obtaining the temporal variation parameter of the current image frame based on continuous image frame data includes: obtaining the pixel grayscale value of the corresponding position of the current image frame and the adjacent historical image frame based on continuous image frame data; calculating the difference between the pixel grayscale value of the corresponding position of the current image frame and the adjacent historical image frame to obtain the pixel change amount; obtaining the temporal difference value of the current image frame based on the pixel change amount, and using the temporal difference value as the temporal variation parameter.

[0058] The specific calculation formula can be found below:

[0059] Where TD is the time difference score. It is the grayscale value of the pixel corresponding to the i-th pixel position in the current image frame; It is the pixel grayscale value corresponding to the i-th pixel position in the historical image frame adjacent to the current image frame; M is the total number of image pixels involved in the calculation.

[0060] The aforementioned use of the time difference score as a temporal variation parameter allows for the assessment of temporal changes in the current scene by observing the degree of grayscale variation at corresponding pixel positions across consecutive image frames. When there is movement or object change in the target area or scene, the pixel difference between adjacent image frames typically increases, leading to a higher time difference score. Conversely, when the scene is relatively stable, the pixel difference between adjacent image frames is smaller, resulting in a lower time difference score. Therefore, the time difference score can help determine whether changes in the current image are caused by non-focusing factors such as scene movement. It, along with image sharpness evaluation parameters, serves as a basis for autofocus triggering, thereby reducing false autofocus triggers caused by target movement or scene changes, and improving the accuracy and stability of autofocus control. Furthermore, this time difference score is calculated based on continuous image frame data acquired by the image acquisition device, eliminating the need for additional motion detection sensors to obtain scene change information, thus reducing system hardware complexity and cost.

[0061] In some embodiments, obtaining the temporal variation parameters of the current image frame based on continuous image frame data includes: performing optical flow calculation based on continuous image frame data to obtain the pixel motion vector corresponding to the current image frame; calculating the motion change amount corresponding to the current image frame based on the pixel motion vector, and determining the motion change amount as the temporal variation parameter of the current image frame. In this embodiment, the motion change amount is used as the temporal variation parameter. This motion change amount can be used to represent the degree of positional change of pixels in the target area of ​​the current image frame over time. For example, the pixel motion vector corresponding to the current image frame can be obtained by optical flow calculation method, and the motion change amount can be determined based on the magnitude, direction, or statistical characteristics of the pixel motion vector. Specifically, when there is movement in the target area, the pixel motion change amount increases; when the target area remains relatively stable, the pixel motion change amount is small. Therefore, the motion change amount can be used to help determine whether the current image change is caused by scene movement, and combined with image sharpness evaluation parameters to jointly determine whether to trigger autofocus operation, thereby reducing false triggering in moving scenes and improving the reliability of autofocus trigger judgment.

[0062] S14. If the temporal change parameters of the current image frame meet the second preset condition, trigger the image acquisition device to perform automatic focusing operation.

[0063] Based on the above steps, it can be known that the time-domain change parameters include time difference value, motion change amount, etc. When the time difference value and / or motion change amount meet the second preset condition, the image acquisition device is triggered to perform automatic focusing operation.

[0064] Specifically, by determining whether the temporal domain variation parameters meet the second preset condition, it can be further determined whether the current image acquisition scene is in a relatively stable state. When the time difference value and / or motion change amount meet the second preset condition, it indicates that the degree of change between the current image frame and the historical image frame is small, and there are few image changes caused by target motion or environmental changes in the current scene. At this time, the image acquisition device is triggered to perform automatic focusing operation.

[0065] Autofocus is used to adjust the focus state of an image acquisition device to improve the sharpness of the acquired image. This includes adjusting the lens's focal length, lens position, the relative position between the sensor and lens, or other parameters affecting image sharpness, ensuring that the target object in the scene is in sharp focus. However, in practical applications, image changes can be caused not only by focus changes but also by factors such as target movement, scene changes, or lighting changes. If autofocus is triggered directly without distinguishing the source of the image change, it can easily lead to frequent autofocus activation or focus oscillation. Therefore, this embodiment combines image sharpness evaluation parameters and temporal variation parameters to comprehensively judge the current scene state, triggering autofocus only when the current image meets preset sharpness conditions and the temporal variation meets preset stability conditions, thereby improving the accuracy and stability of autofocus triggering.

[0066] In some embodiments, the second preset condition can be set according to different types of time-domain change parameters. For example, when the time-domain change parameter is a time difference value, the second preset condition may include a time difference value less than a preset motion threshold; when the time-domain change parameter is a motion change amount, the second preset condition may include a motion change amount less than a preset motion threshold. This motion threshold is used as a reference parameter to determine the degree of motion change in the current scene. When the time-domain change parameter is less than the motion threshold, it indicates that the degree of change between the current image frame and historical image frames is small, and the motion factors in the current scene are weak, satisfying the autofocus triggering condition; when the time-domain change parameter is greater than or equal to the motion threshold, it indicates that there is significant motion or change in the current scene, making it unsuitable to immediately trigger autofocus operation.

[0067] In some embodiments, step S14, triggering the image acquisition device to perform autofocus operation when the temporal change parameter of the current image frame meets the second preset condition, includes: triggering the image acquisition device to perform autofocus operation when the time difference value of the current image frame is less than the second preset threshold; wherein, the second preset threshold includes a motion threshold.

[0068] In some embodiments, step S14, triggering the image acquisition device to perform autofocus operation when the temporal change parameter of the current image frame meets the second preset condition, includes: triggering the image acquisition device to perform autofocus operation when the motion change of the current image frame is less than the second preset threshold; wherein the second preset threshold includes a motion threshold.

[0069] When the time-domain change parameter is a time difference value, the motion threshold can be understood as a threshold used to judge the degree of change in pixel grayscale. When the time-domain change parameter is a motion change amount, the motion threshold can be understood as a threshold used to judge the degree of change in pixel position or the amplitude of motion between adjacent image frames.

[0070] In some embodiments, the motion threshold can be predetermined by experimental calibration or dynamically adjusted based on the current image acquisition environment, historical time-domain variation parameters, image brightness information, or target motion state.

[0071] In some embodiments, the method further includes: obtaining temporal variation parameters corresponding to multiple historical image frames within a preset historical time window; determining historical temporal variation parameter statistics based on the temporal variation parameters corresponding to the multiple historical image frames; and determining a second preset threshold based on the historical temporal variation parameter statistics; wherein the historical temporal variation parameter statistics include the average value of the temporal variation parameters of the multiple historical image frames.

[0072] The motion threshold can be determined based on the temporal difference scores within historical time periods. Specifically, the temporal difference scores corresponding to multiple historical image frames can be statistically analyzed to obtain the historical average temporal difference score, and the motion threshold can be calculated based on this average. For example, it can be calculated using the following formula: Threshold2 = 0.7 × avg(TD); Where Threshold2 is the motion threshold; avg(TD) is the average of the time difference values ​​corresponding to multiple historical image frames; 0.7 is a preset adjustment coefficient, which can be determined according to the actual application scenario, image acquisition device parameters or experimental calibration results, and is not fixed.

[0073] By dynamically adjusting the motion threshold based on historical time difference scores, the motion threshold can be adapted to image change characteristics in different scenarios. For example, in scenarios with significant motion changes, such as moving vehicles or rapidly moving targets, the average historical time difference score is high, and the motion threshold can be adjusted accordingly (e.g., increased) to reduce false positives caused by normal scene changes. In static scenes, the average historical time difference score is low, and the motion threshold can be adjusted accordingly (e.g., decreased) to improve the detection sensitivity of minute changes, thereby improving the reliability of autofocus trigger judgment.

[0074] This application provides an autofocus method that acquires continuous image frame data from an image acquisition device. First, it obtains the image sharpness evaluation parameters of the current image frame. Then, only when the image sharpness evaluation parameters meet a first preset condition, it further obtains the temporal variation parameters of the current image frame. Finally, it determines whether to trigger autofocus based on the temporal variation parameters. Because the autofocus triggering adopts a hierarchical decision mechanism, further analysis of the temporal variation information of continuous image frames is only performed when an autofocus requirement is initially determined. Therefore, the temporal variation characteristics in continuous image frames can be used to further verify the image sharpness evaluation results, effectively reducing false autofocus triggering caused by non-focus change factors such as target movement, device shake, or scene changes, and improving the accuracy and stability of autofocus triggering judgment. Meanwhile, the solution in this embodiment completes temporal change analysis using continuous image frames acquired by the image acquisition device, eliminating the need for additional hardware such as gyroscopes and inertial measurement units, thus reducing system hardware costs and power consumption. Furthermore, the temporal change parameters are determined only when the image sharpness evaluation parameters meet a first preset condition, avoiding temporal change analysis for all image frames, reducing algorithm computation and system resource consumption, and achieving improved autofocus performance without significantly increasing system complexity. Therefore, the solution in this application embodiment can reduce false triggering, reduce invalid focusing, reduce computational load, eliminate the need for additional hardware, and improve the accuracy and stability of autofocus trigger control.

[0075] Please see Figure 3 , Figure 3 This is a schematic diagram of an autofocus device provided in an embodiment of this application. The device 30 includes: The continuous image frame data acquisition module 301 is used to acquire continuous image frame data acquired by the image acquisition device; The image sharpness evaluation parameter determination module 302 is used to obtain the image sharpness evaluation parameters of the current image frame based on continuous image frame data; The temporal variation parameter determination module 303 is used to obtain the temporal variation parameters of the current image frame based on continuous image frame data, provided that the image sharpness evaluation parameters of the current image frame meet the first preset condition. The autofocus module 304 is used to trigger the image acquisition device to perform autofocus operation when the temporal change parameters of the current image frame meet the second preset condition.

[0076] The aforementioned autofocus device 30 can be a software module, which includes several instructions stored in a memory. The processor can access the memory, call the instructions, and execute them to complete the autofocus method described in the above embodiments.

[0077] In some embodiments, the autofocus device 30 can also be constructed from hardware components. For example, the autofocus device 30 can be constructed from one or more chips, which can work in coordination to complete the autofocus method described in the various embodiments. Furthermore, the autofocus device 30 can also be constructed from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM (Acorn RISC Machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.

[0078] It should be noted that the autofocus device 30 described above can execute the autofocus method for electronic devices provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the embodiments of the autofocus device 30 can be found in the autofocus method for electronic devices provided in the embodiments of this application.

[0079] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 20 includes one or more processors 201 and a memory 202. The memory 202 is connected to one or more processors 201, for example, via a bus.

[0080] Processor 201 is configured to support the electronic device 20 in performing the corresponding functions in the methods described in the above method embodiments. Processor 201 may be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof. The aforementioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0081] Memory 202 is used to store program code, etc. Memory 202 may include volatile memory (VM), such as random access memory (RAM); memory may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); memory 202 may also include combinations of the above types of memory.

[0082] The memory 202 can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the autofocus method in the embodiments of this application. The processor 201 executes various functional applications and data processing of the autofocus method and autofocus device by running the non-volatile software programs, instructions, and modules stored in the memory 202, thereby realizing the functions of the various modules or units of the autofocus method and autofocus device provided in the above method embodiments.

[0083] The memory 202 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function. The data storage area may store data created based on the use of the autofocus device, etc. In some embodiments, the memory 202 may include memory remotely located relative to the processor 201, and such remote memory may be connected to the autofocus device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0084] The one or more modules are stored in the memory 202. When executed by the one or more processors 201, they perform the autofocus method in any of the above method embodiments. For example, they perform the method steps described in the above method embodiments to realize the functions of the modules described in the above device embodiments.

[0085] The electronic device 20 in this application embodiment may specifically be a processing terminal, a control chip, a processor module, or a server, etc.

[0086] This application provides a non-volatile computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, for example... Figure 4One of the processors 201 can enable the one or more processors to execute the autofocus method in any of the above method embodiments, for example, to perform the above-described... Figure 2 Methods, steps, and implementation in [the context of the text] Figure 3 The functionality of the modules within.

[0087] This application provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium. The computer program includes program instructions that, when executed by the electronic device, enable the electronic device to perform the autofocus method in any of the above-described method embodiments, for example, to perform the above-described... Figure 2 Methods, steps, and implementation in [the context of the text] Figure 3 The functionality of the modules within.

[0088] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0089] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.

Claims

1. An autofocus method, characterized in that, The method includes: Acquire continuous image frame data captured by the image acquisition device; Based on the continuous image frame data, obtain the image sharpness evaluation parameters of the current image frame; If the image sharpness evaluation parameters of the current image frame meet the first preset condition, the temporal variation parameters of the current image frame are obtained based on the continuous image frame data. When the temporal variation parameters of the current image frame meet the second preset condition, the image acquisition device is triggered to perform an autofocus operation.

2. The method according to claim 1, characterized in that, The step of obtaining the image sharpness evaluation parameters of the current image frame based on the continuous image frame data includes: The current image frame is determined based on the continuous image frame data; Obtain the pixel grayscale value corresponding to the target region in the current image frame; The grayscale variance of the target region is calculated based on the pixel grayscale value, and the grayscale variance of the target region is used as the image sharpness evaluation parameter of the current image frame.

3. The method according to claim 2, characterized in that, When the image sharpness evaluation parameters of the current image frame meet the first preset condition, the temporal variation parameters of the current image frame are obtained based on the continuous image frame data, including: If the grayscale variance corresponding to the target region is greater than a first preset threshold, the temporal variation parameters of the current image frame are obtained based on the continuous image frame data; wherein, the first preset threshold includes a sharpness threshold.

4. The method according to claim 3, characterized in that, The method further includes: Obtain the brightness parameters of the current image frame, and determine the corresponding brightness level based on the brightness parameters; The sharpness threshold is adjusted based on the brightness level.

5. The method according to claim 1, characterized in that, The step of obtaining the temporal variation parameters of the current image frame based on the continuous image frame data includes: Based on the continuous image frame data, obtain the pixel grayscale values ​​of the corresponding positions of the current image frame and the adjacent historical image frames; The difference between the pixel grayscale values ​​at corresponding positions in the current image frame and the adjacent historical image frames is calculated to obtain the pixel change. The temporal difference value of the current image frame is obtained based on the pixel change, and the temporal difference value is used as the temporal domain change parameter.

6. The method according to claim 1, characterized in that, The step of obtaining the temporal variation parameters of the current image frame based on the continuous image frame data includes: Optical flow calculation is performed based on the continuous image frame data to obtain the pixel motion vector corresponding to the current image frame; The motion change amount corresponding to the current image frame is calculated based on the pixel motion vector, and the motion change amount is determined as the temporal change parameter of the current image frame.

7. The method according to claim 5, characterized in that, The step of triggering the image acquisition device to perform autofocus operation when the temporal variation parameters of the current image frame meet the second preset condition includes: If the time difference of the current image frame is less than a second preset threshold, the image acquisition device is triggered to perform an autofocus operation; wherein, the second preset threshold includes a motion threshold.

8. The method according to claim 7, characterized in that, The method further includes: Obtain the temporal variation parameters corresponding to multiple historical image frames within a preset historical time window; Based on the temporal variation parameters corresponding to the multiple historical image frames, determine the statistical values ​​of the historical temporal variation parameters; The second preset threshold is determined based on the statistical values ​​of the historical time-domain change parameters; The historical temporal variation parameter statistics include the average temporal variation parameters of multiple historical image frames.

9. An automatic focusing device, characterized in that, The device includes: The continuous image frame data acquisition module is used to acquire continuous image frame data acquired by the image acquisition device. The image sharpness evaluation parameter determination module is used to obtain the image sharpness evaluation parameters of the current image frame based on the continuous image frame data; The temporal variation parameter determination module is used to obtain the temporal variation parameters of the current image frame based on the continuous image frame data, when the image sharpness evaluation parameters of the current image frame meet the first preset condition. An autofocus module is used to trigger the image acquisition device to perform autofocus operation when the temporal change parameters of the current image frame meet a second preset condition.

10. An electronic device, characterized in that, include: A memory and a processor, the memory being connected to the processor, the processor being configured to execute one or more computer programs stored in the memory, the processor, when executing the one or more computer programs, causing the electronic device to perform the method as described in any one of claims 1-8.