Focusing method and device, computer equipment, storage medium and program product

By acquiring the initial focus curve of the terminal, performing Gaussian fitting and gyroscope sensor data compensation, a compensation curve is generated, which solves the impact of terminal shake on the sharpness of the focused ROI image and improves the autofocus quality without increasing hardware costs.

CN121462879APending Publication Date: 2026-02-03SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511555795.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-02-03

AI Technical Summary

Technical Problem

Camera shake can interfere with the sharpness of the image in the area of ​​interest that is in focus. Existing technologies that reduce this effect by using external hardware devices require additional hardware costs.

Method used

By acquiring the initial focus numerical curve, Gaussian fitting and gyroscope sensor data compensation are performed to generate a compensation curve. Focusing is then performed based on this curve, and the focus numerical curve is corrected by using angular velocity data collected by the gyroscope sensor on the terminal.

Benefits of technology

Without adding additional hardware, reduce the impact of camera shake on the sharpness of the focused ROI image and improve autofocus quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121462879A_ABST
    Figure CN121462879A_ABST
Patent Text Reader

Abstract

The invention relates to a focusing method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: acquiring an initial focusing numerical curve of an initial focusing region-of-interest (ROI) image; performing Gaussian fitting on the initial focusing numerical curve to obtain a first Gaussian curve; on the basis of the angular velocity data of each focusing position and the focusing numerical value fluctuation quantity corresponding to each focusing position, compensating the initial focusing numerical value curve to obtain a compensation curve; the focusing numerical value fluctuation quantity comprises a fluctuation quantity between a focusing numerical value corresponding to the focusing position on the first Gaussian curve and a focusing numerical value on the initial focusing numerical value curve; according to the method, the initial focusing ROI image is focused based on the compensation curve, and the focusing numerical curve can be corrected based on the angular velocity data acquired by the gyroscope sensor, so that the influence of terminal jitter on the definition of the focusing ROI image can be reduced and the quality of automatic focusing can be improved under the condition of not externally connecting additional hardware equipment.
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 in particular to a focusing method, apparatus, computer equipment, storage medium, and program product. Background Technology

[0002] Autofocus (AF) is a crucial component of a camera's imaging system, largely determining the fundamental image quality. The sharpness of the region of interest (ROI) image is a significant factor affecting AF focusing quality. However, camera shake during photography can interfere with the sharpness of the ROI image. Therefore, minimizing the impact of camera shake on the sharpness of the ROI image has become a pressing technical challenge in this field.

[0003] Currently, the impact of camera shake on the sharpness of the focused ROI image is usually reduced by using external hardware devices; however, this method requires additional hardware costs. Summary of the Invention

[0004] Therefore, it is necessary to provide a focusing method, apparatus, computer equipment, storage medium, and program product to address the aforementioned technical problems.

[0005] Firstly, this application provides a focusing method. The method includes:

[0006] Obtain the initial focus value curve of the region of interest (ROI) image;

[0007] Gaussian fitting is performed on the initial focus value curve to obtain the first Gaussian curve;

[0008] Based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, the initial focus value curve is compensated to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0009] The initial focused ROI image is then refocused based on this compensation curve.

[0010] In one embodiment, the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, are used to compensate the initial focus value curve to obtain a compensation curve, including:

[0011] Determine the average angular velocity based on the angular velocity data for each focus position;

[0012] The average focus value is determined based on the fluctuation of the focus value corresponding to each focus position.

[0013] Based on the average angular velocity, the average focus value, and the angular velocity data for each focus position, determine the focus value compensation amount corresponding to each focus position.

[0014] The initial focus value curve is compensated based on the focus value compensation amount corresponding to each focus position to obtain the compensation curve.

[0015] In one embodiment, determining the focus value compensation amount corresponding to each focus position based on the average angular velocity, the average focus value, and the angular velocity data for each focus position includes:

[0016] The envelope integral area is determined based on the average focus value;

[0017] Based on the average angular velocity and the angular velocity data corresponding to each focus position, determine the compensation ratio corresponding to each focus position.

[0018] Based on the envelope integral area and the compensation ratio corresponding to each focus position, the focus value compensation amount corresponding to each focus position is determined.

[0019] In one embodiment, focusing the initial focused ROI image based on the compensation curve includes:

[0020] Gaussian fitting is performed on the compensation curve to obtain the second Gaussian curve;

[0021] Parabolic fitting is performed on the peak region of the second Gaussian curve to obtain the target fitted curve.

[0022] The target focus position is determined based on the target fitting curve, and the initial focus ROI image is then focused based on the target focus position.

[0023] In one embodiment, determining the target focus position based on the target fitting curve includes:

[0024] The fitting result is determined based on the target fitting curve;

[0025] If the fitting result is successful, the focus position of the target is determined according to the axis of symmetry of the fitting curve of the target.

[0026] If the fitting result is unsuccessful, the focus position of the target is determined based on the Gaussian mean of the first Gaussian curve.

[0027] In one embodiment, the initial focus value curve is subjected to Gaussian fitting to obtain a first Gaussian curve, including:

[0028] The size of the filter kernel is determined based on the angular velocity data.

[0029] Based on the size of the filter kernel, the initial focus value curve is filtered to obtain a smooth focus value curve.

[0030] Gaussian fitting is performed on the smoothed focus numerical curve to obtain the first Gaussian curve.

[0031] Secondly, this application also provides a focusing device. The device includes:

[0032] The acquisition module is used to acquire the initial focus value curve of the region of interest (ROI) image.

[0033] The Gaussian fitting module is used to perform Gaussian fitting on the initial focus value curve to obtain the first Gaussian curve.

[0034] The compensation module is used to compensate the initial focus value curve based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0035] The focusing module is used to focus the initial focused ROI image based on the compensation curve.

[0036] Thirdly, this application also provides a computer device, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of any of the above methods.

[0037] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above methods.

[0038] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above methods.

[0039] The aforementioned focusing method, apparatus, computer equipment, storage medium, and program product acquire an initial focus value curve of the region of interest (ROI) image; perform Gaussian fitting on the initial focus value curve to obtain a first Gaussian curve; compensate the initial focus value curve based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve; and focus the initial focus ROI image based on the compensation curve. Since the focus value curve can be corrected based on the angular velocity data collected by the gyroscope sensor in this embodiment, the impact of terminal shake on the sharpness of the focus ROI image can be reduced without connecting additional hardware devices, thereby improving the quality of autofocus. Attached Figure Description

[0040] Figure 1 This is an internal structural diagram of a computer device provided in an embodiment of this application;

[0041] Figure 2 This is a schematic flowchart of a focusing method provided in an embodiment of this application;

[0042] Figure 3 This is a schematic diagram of a focus numerical curve provided in an embodiment of this application;

[0043] Figure 4 This is a schematic diagram of the mobile phone coordinate axis and the rotation direction of the gyro provided in an embodiment of this application;

[0044] Figure 5 This is a schematic diagram of a dual-fit filtering model for fused sensing provided in an embodiment of this application;

[0045] Figure 6 This is a flowchart illustrating a method for determining a compensation curve provided in an embodiment of this application;

[0046] Figure 7 This is a schematic diagram of a gyro fusion compensation curve provided in an embodiment of this application;

[0047] Figure 8 This is a flowchart illustrating a method for determining focus value compensation provided in an embodiment of this application.

[0048] Figure 9 This is a flowchart illustrating another focusing method provided in an embodiment of this application;

[0049] Figure 10 This is a flowchart illustrating a method for determining the focus position of a target according to an embodiment of this application;

[0050] Figure 11 This is a flowchart illustrating a method for determining a first Gaussian curve according to an embodiment of this application.

[0051] Figure 12 This is a flowchart illustrating an AF hand shaking filtering method based on double fitting of long-tailed FV curves provided in an embodiment of this application.

[0052] Figure 13 This is a structural block diagram of a focusing device provided in an embodiment of this application. Detailed Implementation

[0053] 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.

[0054] Autofocus (AF) is a crucial component of a camera's imaging system, largely determining the fundamental image quality. The sharpness of the region of interest (ROI) image is a significant factor affecting AF focusing quality. However, camera shake during photography can interfere with the sharpness of the ROI image. Therefore, minimizing the impact of camera shake on the sharpness of the ROI image has become a pressing technical challenge in this field.

[0055] Currently, the impact of camera shake on the sharpness of the focused ROI image is usually reduced by using external hardware devices; however, this method requires additional hardware costs.

[0056] The focusing method provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown. Figure 1 This is an internal structure diagram of a computer device provided in an embodiment of this application. The computer device can be a terminal, and its internal structure diagram can be as follows: Figure 1As shown, the computer device includes 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, mobile cellular 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. The computer program, when executed by the processor, implements a focusing method.

[0057] Those skilled in the art will understand that Figure 1 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0058] In one embodiment, such as Figure 2 As shown, Figure 2 This is a flowchart illustrating a focusing method provided in an embodiment of this application. This method can be applied to... Figure 1 The method, using a computer device, includes the following steps:

[0059] S201, Obtain the initial focus value curve of the region of interest (ROI) image.

[0060] Reference Figure 3 , Figure 3 This is a schematic diagram of a focus value curve provided in an embodiment of this application. During the autofocus process of the terminal, the voice coil motor (VCM) is first placed in the initial position (i.e., the macro end, such as Code 500). Then, the VCM is pushed from near to far, focusing on a distant target object during the pushing process. In this case, the image on the terminal will show a process from blurry to clear and then back to blurry. The position corresponding to the clearest image is called the focus position (i.e., the target focus position). The focus value (FV) curve corresponding to the above process of image from blurry to clear and then back to blurry can be shown as follows: Figure 3 As shown, the focusing numerical curve conforms to the characteristics of a long-tailed distribution.

[0061] In this embodiment, the focusing status of the terminal can be detected first, that is, it can be determined whether the terminal is in stable focusing. If the terminal is in stable focusing, there will be no terminal shaking, and it will not interfere with the sharpness of the focused ROI image. If the terminal is not in stable focusing, that is, there may be terminal shaking, then the initial focusing value curve of the terminal can be obtained and processed to reduce the impact of terminal shaking on the sharpness of the focused ROI image.

[0062] S202, Gaussian fitting is performed on the initial focus numerical curve to obtain the first Gaussian curve.

[0063] Optionally, initial fitting parameters (e.g., amplitude, mean, and variance) can be estimated, and then Gaussian fitting can be performed on the initial focus numerical curve based on a constrained least squares fitting algorithm to obtain the first Gaussian curve.

[0064] Alternatively, before performing Gaussian fitting, the initial focus value curve can be Gaussian filtered to reduce interference from camera shake (such as hand shake). Then, Gaussian fitting is performed on the smoothed focus value curve obtained after Gaussian filtering based on the above method to obtain the first Gaussian curve.

[0065] S203, based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the corresponding focus value fluctuation of each focus position, compensates the initial focus value curve to obtain the compensation curve.

[0066] The focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0067] Reference Figure 4 , Figure 4 This is a schematic diagram illustrating the coordinate axis of a mobile phone and the rotation direction of the gyroscope, provided in an embodiment of this application. For example, taking a mobile phone as the terminal, the mobile phone is equipped with a gyroscope system, i.e., the aforementioned gyroscope sensor, such as... Figure 4 As shown, the gyro system can acquire the angular velocity data of the phone's X / Y / Z axes during focusing. This angular velocity data can characterize the angular velocity path of the phone's attitude change during focusing.

[0068] Reference Figure 5 , Figure 5 This is a schematic diagram of a dual-fit filtering model for fusion sensing provided in an embodiment of this application. Figure 5Curve 1 is the initial focus value curve, curve 2 is the first Gaussian curve, curve 3 is the compensation curve, curve 4 is the second Gaussian curve, curve 5 is the target fitting curve, and curve 9 is used to characterize the interpolation frame gyro angular velocity. Figure 5 Marker 6 is used to mark the peak of the initial focus numerical curve, mark 7 is used to mark the peak of the second Gaussian curve, and mark 8 is used to mark the peak of the target fitting curve.

[0069] Reference Figure 7 , Figure 7 This is a schematic diagram of a gyro fusion compensation curve provided in an embodiment of this application. For example, as shown... Figure 7 As shown, the initial focus value curve [P1, P] can be used to... n Each point within the range is taken as the focus position. For each focus position, the focus value fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve is determined. Then, based on the angular velocity data corresponding to each focus position, the focus value fluctuation is compensated to the initial focus value curve in a weighted manner to obtain the compensation curve.

[0070] S204 focuses the initial ROI image based on the compensation curve.

[0071] Alternatively, the peak value of the compensation curve can be directly determined as the target focus position, so as to focus the initial focus ROI image at the target focus position.

[0072] Alternatively, a second Gaussian fit can be performed on the compensation curve to obtain a second Gaussian curve. Then, the peak value of the second Gaussian curve can be determined as the target focus position, so as to focus the initial focus ROI image at the target focus position.

[0073] Alternatively, after the second Gaussian fitting, a parabolic fitting can be performed on the second Gaussian curve to obtain the target parabola, which is the target fitting curve mentioned above. Then, the position of the axis of symmetry of the target fitting curve is determined as the target focus position, so as to focus the initial focus ROI image at the target focus position.

[0074] In this embodiment, an initial focus value curve of the region of interest (ROI) image is obtained; a Gaussian fit is performed on the initial focus value curve to obtain a first Gaussian curve; based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, the initial focus value curve is compensated to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve; the initial focus ROI image is then focused based on the compensation curve. Because this embodiment can correct the focus value curve based on the angular velocity data collected by the gyroscope sensor, the impact of terminal shake on the sharpness of the focus ROI image can be reduced without connecting additional hardware devices, thereby improving the quality of autofocus.

[0075] Reference Figure 6 , Figure 6 This is a flowchart illustrating a compensation curve determination method provided in an embodiment of this application. This embodiment relates to a possible implementation of how to compensate for the initial focus value curve based on angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the corresponding focus value fluctuation amount, to obtain a compensation curve. Based on the above embodiment, S203 includes the following steps:

[0076] S601 determines the average angular velocity based on the angular velocity data of each focus position.

[0077] In one embodiment, the angular velocity data of each focus position in each direction can be obtained first, and then the maximum value in each direction can be determined as the angular velocity data of that focus position. The above process can be expressed as the following formula (1):

[0078] (1)

[0079] Optionally, the probability density function (PDF) value can be determined based on the first Gaussian curve, and then the average angular velocity can be determined based on the PDF value and the angular velocity data at each focus position. :

[0080] (2)

[0081] In formula (2), This is the PDF value.

[0082] S602 determines the average focus value based on the fluctuation of the focus value corresponding to each focus position.

[0083] Alternatively, the average focus value can be determined according to the following formula (3). :

[0084] (3)

[0085] In formula (3), This is the FV value of the initial focus numerical curve. The FV value is the value of the first Gaussian curve.

[0086] S603 determines the corresponding focus value compensation amount for each focus position based on the average angular velocity, average focus value, and angular velocity data for each focus position.

[0087] For example, such as Figure 5 The blue area shown has the same area above curve 2 as its area below curve 2. Figure 5 The blue area between curve 1 and curve 2 shown in the figure represents the focus value fluctuation. Therefore, the part with the same area opposite to the blue area between curve 1 and curve 2 is the focus value compensation area.

[0088] Alternatively, it can be based on the average focus value. Determine [P1, P] n The area of ​​the envelope integral within the range :

[0089] (4)

[0090] Then, based on the average angular velocity and the first The angular velocity data corresponding to the first focus position is used to determine the first... The compensation ratio corresponding to each focus position :

[0091] (5)

[0092] Therefore, based on the area of ​​the envelope integral and the The compensation ratio corresponding to each focus position Determine the first Focus value compensation amount corresponding to each focus position :

[0093] (6)

[0094] S604 compensates the initial focus value curve based on the focus value compensation amount corresponding to each focus position, and obtains the compensation curve.

[0095] Optionally, with the first Taking a single focus position as an example, compensation can be based on the focus value. For the Compensate the focus values ​​at each focus position:

[0096] (7)

[0097] In this embodiment, the average angular velocity is determined based on the angular velocity data of each focus position; the average focus value is determined based on the focus value fluctuation corresponding to each focus position; the focus value compensation amount corresponding to each focus position is determined based on the average angular velocity, the average focus value, and the angular velocity data of each focus position; the initial focus value curve is compensated based on the focus value compensation amount corresponding to each focus position to obtain a compensation curve, thereby correcting the focus value curve and reducing the impact of terminal shake on the sharpness of the focused ROI image without connecting additional hardware devices, thus improving the quality of autofocus.

[0098] Reference Figure 8 , Figure 8 This is a flowchart illustrating a method for determining focus value compensation based on an embodiment of this application. This embodiment relates to a possible implementation of determining the focus value compensation amount corresponding to each focus position based on average angular velocity, average focus value, and angular velocity data for each focus position. Based on the above embodiment, step S603 includes the following steps:

[0099] S801 determines the envelope integral area based on the average focus value.

[0100] Alternatively, it can be based on the average focus value. Determine [P1, P] n The area of ​​the envelope integral within the range :

[0101] (4)

[0102] S802 determines the compensation ratio for each focus position based on the average angular velocity and the angular velocity data corresponding to each focus position.

[0103] Alternatively, it can be based on the average angular velocity and the first The angular velocity data corresponding to the first focus position is used to determine the first... The compensation ratio corresponding to each focus position :

[0104] (5)

[0105] S803 determines the focus value compensation amount corresponding to each focus position based on the envelope integral area and the compensation ratio corresponding to each focus position.

[0106] Alternatively, it can be based on the area of ​​the envelope integral. and the The compensation ratio corresponding to each focus position Determine the first Focus value compensation amount corresponding to each focus position :

[0107] (6)

[0108] In this embodiment, the envelope integral area is determined based on the average focus value; the compensation ratio corresponding to each focus position is determined based on the average angular velocity and the angular velocity data corresponding to each focus position; and the focus value compensation amount corresponding to each focus position is determined based on the envelope integral area and the compensation ratio corresponding to each focus position. This allows the focus value curve to be corrected based on the focus value compensation amount, thereby reducing the impact of terminal shake on the sharpness of the focused ROI image and improving the quality of autofocus without the need for additional external hardware devices.

[0109] Reference Figure 9 , Figure 9 This is a flowchart illustrating another focusing method provided in this application embodiment. This embodiment relates to a possible implementation of focusing an initial focusing ROI image based on a compensation curve. Based on the above embodiment, S204 includes the following steps:

[0110] S901, Gaussian fitting is performed on the compensation curve to obtain the second Gaussian curve.

[0111] In one embodiment, the compensation curve can be Gaussian fitted based on a constrained least squares fitting algorithm to obtain a second Gaussian curve.

[0112] Alternatively, the constrained least squares fitting algorithm can be, for example, the LM (Levenberg-Marquardt) trust region algorithm, whose mathematical model can be expressed as:

[0113] (8)

[0114] (9)

[0115] S902, parabolic fitting is performed on the peak region of the second Gaussian curve to obtain the target fitted curve.

[0116] In one embodiment, based on the Pareto principle of the long-tailed distribution, the region that plays a decisive role in the peak sharpness of a curve that conforms to the long-tailed distribution is the region within 3 frames on both sides of the peak. In other words, the region within 7 frames near the peak can determine the peak sharpness. Therefore, the region within 7 frames near the peak can be taken as the peak region, and parabolic fitting is performed on the peak region in the second Gaussian curve to obtain the target fitted curve.

[0117] Optionally, the weights corresponding to each focus position in the parabolic fitting are determined based on the PDF of that focus position.

[0118] S903 determines the target focus position based on the target fitting curve and focuses the initial focus ROI image based on the target focus position.

[0119] Optionally, the fitting result can be determined based on the target fitting curve, i.e., whether the fitting is successful. If the fitting is successful, the position of the axis of symmetry of the target fitting curve is determined as the target focus position; if the fitting is unsuccessful, the position corresponding to the Gaussian mean of the first Gaussian curve is determined as the target focus position.

[0120] In this embodiment, the compensation curve is fitted with Gaussian curve to obtain a second Gaussian curve; the peak region in the second Gaussian curve is fitted with parabola to obtain a target fitting curve; the target focus position is determined based on the target fitting curve, and the initial focus ROI image is focused based on the target focus position, thereby realizing the secondary fitting of the focus numerical curve and further correcting the focus numerical curve.

[0121] Reference Figure 10 , Figure 10 This is a flowchart illustrating a method for determining the focus position of a target according to an embodiment of this application. This embodiment relates to a possible implementation of determining the focus position of a target based on a target fitting curve. Based on the above embodiment, S902 includes the following steps:

[0122] S1001, determine the fitting result based on the target fitting curve.

[0123] For example, the success of the fitting can be determined based on the target fitting curve. If it is successful, the fitting result is considered successful; if it is unsuccessful, the fitting result is considered unsuccessful.

[0124] S1002, if the fitting result is successful, determine the target focus position based on the axis of symmetry of the target fitting curve.

[0125] For example, if the fit is successful, the position of the axis of symmetry of the target fitted curve is determined as the target focus position.

[0126] S1003, if the fitting result is unsuccessful, the target focus position is determined based on the Gaussian mean of the first Gaussian curve.

[0127] For example, if the fitting fails, the position corresponding to the Gaussian mean of the first Gaussian curve is determined as the target focus position.

[0128] In this embodiment, the fitting result is determined based on the target fitting curve; if the fitting result is successful, the target focus position is determined based on the axis of symmetry of the target fitting curve; if the fitting result is unsuccessful, the target focus position is determined based on the Gaussian mean of the first Gaussian curve. The target focus position is determined based on different fitting results, which further improves the flexibility and reliability of autofocus.

[0129] Reference Figure 11 , Figure 11 This is a flowchart illustrating a method for determining a first Gaussian curve according to an embodiment of this application. This embodiment relates to a possible implementation of Gaussian fitting on an initial focus numerical curve to obtain a first Gaussian curve. Based on the above embodiment, step S1003 includes the following steps:

[0130] S1101 determines the size of the filter kernel based on the angular velocity data.

[0131] For example, the integral of the angular velocity of each axis can be calculated based on the correction drift coefficient wd, and then Euler angle interpolation can be performed on the angular velocity data based on the integral of the angular velocity and the time delay td, so as to determine the size of the filter kernel based on the interpolated angular velocity data.

[0132] S1102 filters the initial focus value curve based on the filter kernel size to obtain a smooth focus value curve.

[0133] S1103, Gaussian fitting is performed on the smoothed focus numerical curve to obtain the first Gaussian curve.

[0134] Optionally, Gaussian filtering can be applied to the initial focus value curve to reduce the interference of terminal shake (e.g., hand shake) on the focus value curve. Then, the initial fitting parameters (e.g., amplitude, mean, and variance) are estimated, and then Gaussian fitting is performed on the smoothed focus value curve obtained after the initial Gaussian filtering based on a constrained least squares fitting algorithm to obtain the first Gaussian curve.

[0135] In this embodiment, the size of the filter kernel is determined based on the angular velocity data; the initial focus value curve is filtered based on the size of the filter kernel to obtain a smooth focus value curve; Gaussian fitting is performed on the smooth focus value curve to obtain a first Gaussian curve, thereby reducing the interference of terminal shake on the focus value curve through Gaussian filtering and improving the accuracy of subsequent fitting.

[0136] Reference Figure 12 , Figure 12 This is a flowchart illustrating an AF (Analog-Based Image) hand shaking filtering method based on double fitting of a long-tailed FV curve, provided in an embodiment of this application. The method includes the following steps:

[0137] S1201 determines whether tripod focusing or stable focusing is used.

[0138] S1202, Gaussian adaptive filtering, yields a smooth focus numerical curve.

[0139] S1203, Frame Angle Alignment and Interpolation.

[0140] S1204, determine whether the initial FV curve follows a long-tailed distribution.

[0141] S1205, filter out special scenarios.

[0142] S1206, initial Gaussian fitting, yields the first Gaussian curve.

[0143] S1207 compensates the initial focus value curve to obtain the compensation curve.

[0144] S1208, perform a second Gaussian fit on the compensation curve to obtain the second Gaussian curve.

[0145] S1209, Parabolic fitting is performed on the second Gaussian curve to obtain the target fitted curve.

[0146] S1210, determine the fitting result based on the target fitting curve.

[0147] S1211, if the fitting result is successful, outputs the axis of symmetry of the target fitted curve.

[0148] S1212, if the fitting result is unsuccessful, outputs the Gaussian mean of the first Gaussian curve.

[0149] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0150] Based on the same inventive concept, this application also provides a focusing device for implementing the focusing method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more focusing device embodiments provided below can be found in the limitations of the focusing method described above, and will not be repeated here.

[0151] In one embodiment, such as Figure 13 As shown, Figure 13 This is a structural block diagram of a focusing device provided in an embodiment of this application. The device 1300 includes:

[0152] The acquisition module 1301 is used to acquire the initial focus value curve of the region of interest (ROI) image.

[0153] The Gaussian fitting module 1302 is used to perform Gaussian fitting on the initial focus numerical curve to obtain the first Gaussian curve.

[0154] The compensation module 1303 is used to compensate the initial focus value curve based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0155] The focusing module 1304 is used to focus the initial focused ROI image based on the compensation curve.

[0156] In one embodiment, the compensation module 1303 includes:

[0157] The first determining unit is used to determine the average angular velocity based on the angular velocity data of each focusing position.

[0158] The second determining unit is used to determine the average focus value based on the fluctuation of the focus value corresponding to each focus position.

[0159] The third determining unit is used to determine the corresponding focus value compensation amount for each focus position based on the average angular velocity, the average focus value, and the angular velocity data of each focus position.

[0160] The compensation unit is used to compensate the initial focus value curve based on the focus value compensation amount corresponding to each focus position, so as to obtain the compensation curve.

[0161] In one embodiment, the second determining unit includes:

[0162] The first determining sub-unit is used to determine the envelope integral area based on the average focus value.

[0163] The second determining subunit is used to determine the compensation ratio corresponding to each focusing position based on the average angular velocity and the angular velocity data corresponding to each focusing position.

[0164] The third determining subunit is used to determine the focusing numerical compensation amount corresponding to each focusing position based on the envelope integral area and the compensation ratio corresponding to each focusing position.

[0165] In one embodiment, the focusing module 1304 includes:

[0166] The first Gaussian fitting unit is used to perform Gaussian fitting on the compensation curve to obtain the second Gaussian curve.

[0167] The parabolic fitting unit is used to perform parabolic fitting on the peak region of the second Gaussian curve to obtain the target fitted curve.

[0168] The focusing unit is used to determine the target focus position based on the target fitting curve, and to focus the initial focus ROI image based on the target focus position.

[0169] In one embodiment, the focusing unit is specifically configured to determine the fitting result based on the target fitting curve; if the fitting result is successful, determine the target focusing position based on the axis of symmetry of the target fitting curve; if the fitting result is unsuccessful, determine the target focusing position based on the Gaussian mean of the first Gaussian curve.

[0170] In one embodiment, the Gaussian fitting module 1302 includes:

[0171] The fourth determining unit is used to determine the size of the filter kernel based on the angular velocity data.

[0172] The filtering unit is used to filter the initial focus value curve based on the filter kernel size to obtain a smooth focus value curve.

[0173] The second Gaussian fitting unit is used to perform Gaussian fitting on the smoothed focus numerical curve to obtain the first Gaussian curve.

[0174] Each module in the aforementioned focusing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0175] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0176] Obtain the initial focus value curve of the region of interest (ROI) image;

[0177] Gaussian fitting is performed on the initial focus numerical curve to obtain the first Gaussian curve;

[0178] Based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation of each focus position, the initial focus value curve is compensated to obtain the compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0179] Focusing is performed on the initial focused ROI image based on the compensation curve.

[0180] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0181] The average angular velocity is determined based on the angular velocity data at each focus position.

[0182] The average focus value is determined based on the fluctuation of the focus value corresponding to each focus position.

[0183] Based on the average angular velocity, average focus value, and angular velocity data at each focus position, determine the focus value compensation amount corresponding to each focus position.

[0184] The initial focus value curve is compensated based on the focus value compensation amount corresponding to each focus position to obtain the compensation curve.

[0185] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0186] The envelope integral area is determined based on the average focus value;

[0187] Based on the average angular velocity and the angular velocity data corresponding to each focus position, determine the compensation ratio corresponding to each focus position.

[0188] Based on the envelope integral area and the compensation ratio corresponding to each focus position, determine the focus value compensation amount corresponding to each focus position.

[0189] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0190] Gaussian fitting is performed on the compensation curve to obtain the second Gaussian curve;

[0191] Parabolic fitting is performed on the peak region of the second Gaussian curve to obtain the target fitted curve;

[0192] The target focus position is determined based on the target fitting curve, and the initial focus ROI image is then focused based on the target focus position.

[0193] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0194] Determine the fitting result based on the target fitting curve;

[0195] If the fitting result is successful, the target focus position is determined according to the axis of symmetry of the target fitting curve;

[0196] If the fitting result is unsuccessful, the target focus position is determined based on the Gaussian mean of the first Gaussian curve.

[0197] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0198] Determine the size of the filter kernel based on the angular velocity data;

[0199] The initial focus value curve is filtered based on the filter kernel size to obtain a smooth focus value curve.

[0200] Gaussian fitting is performed on the smoothed focus numerical curve to obtain the first Gaussian curve.

[0201] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0202] Obtain the initial focus value curve of the region of interest (ROI) image;

[0203] Gaussian fitting is performed on the initial focus numerical curve to obtain the first Gaussian curve;

[0204] Based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation of each focus position, the initial focus value curve is compensated to obtain the compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0205] Focusing is performed on the initial focused ROI image based on the compensation curve.

[0206] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0207] The average angular velocity is determined based on the angular velocity data at each focus position.

[0208] The average focus value is determined based on the fluctuation of the focus value corresponding to each focus position.

[0209] Based on the average angular velocity, average focus value, and angular velocity data at each focus position, determine the focus value compensation amount corresponding to each focus position.

[0210] The initial focus value curve is compensated based on the focus value compensation amount corresponding to each focus position to obtain the compensation curve.

[0211] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0212] The envelope integral area is determined based on the average focus value;

[0213] Based on the average angular velocity and the angular velocity data corresponding to each focus position, determine the compensation ratio corresponding to each focus position.

[0214] Based on the envelope integral area and the compensation ratio corresponding to each focus position, determine the focus value compensation amount corresponding to each focus position.

[0215] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0216] Gaussian fitting is performed on the compensation curve to obtain the second Gaussian curve;

[0217] Parabolic fitting is performed on the peak region of the second Gaussian curve to obtain the target fitted curve;

[0218] The target focus position is determined based on the target fitting curve, and the initial focus ROI image is then focused based on the target focus position.

[0219] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0220] Determine the fitting result based on the target fitting curve;

[0221] If the fitting result is successful, the target focus position is determined according to the axis of symmetry of the target fitting curve;

[0222] If the fitting result is unsuccessful, the target focus position is determined based on the Gaussian mean of the first Gaussian curve.

[0223] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0224] Determine the size of the filter kernel based on the angular velocity data;

[0225] The initial focus value curve is filtered based on the filter kernel size to obtain a smooth focus value curve.

[0226] Gaussian fitting is performed on the smoothed focus numerical curve to obtain the first Gaussian curve.

[0227] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0228] Obtain the initial focus value curve of the region of interest (ROI) image;

[0229] Gaussian fitting is performed on the initial focus numerical curve to obtain the first Gaussian curve;

[0230] Based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation of each focus position, the initial focus value curve is compensated to obtain the compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve.

[0231] Focusing is performed on the initial focused ROI image based on the compensation curve.

[0232] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0233] The average angular velocity is determined based on the angular velocity data at each focus position.

[0234] The average focus value is determined based on the fluctuation of the focus value corresponding to each focus position.

[0235] Based on the average angular velocity, average focus value, and angular velocity data at each focus position, determine the focus value compensation amount corresponding to each focus position.

[0236] The initial focus value curve is compensated based on the focus value compensation amount corresponding to each focus position to obtain the compensation curve.

[0237] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0238] The envelope integral area is determined based on the average focus value;

[0239] Based on the average angular velocity and the angular velocity data corresponding to each focus position, determine the compensation ratio corresponding to each focus position.

[0240] Based on the envelope integral area and the compensation ratio corresponding to each focus position, determine the focus value compensation amount corresponding to each focus position.

[0241] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0242] Gaussian fitting is performed on the compensation curve to obtain the second Gaussian curve;

[0243] Parabolic fitting is performed on the peak region of the second Gaussian curve to obtain the target fitted curve;

[0244] The target focus position is determined based on the target fitting curve, and the initial focus ROI image is then focused based on the target focus position.

[0245] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0246] Determine the fitting result based on the target fitting curve;

[0247] If the fitting result is successful, the target focus position is determined according to the axis of symmetry of the target fitting curve;

[0248] If the fitting result is unsuccessful, the target focus position is determined based on the Gaussian mean of the first Gaussian curve.

[0249] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0250] Determine the size of the filter kernel based on the angular velocity data;

[0251] The initial focus value curve is filtered based on the filter kernel size to obtain a smooth focus value curve.

[0252] Gaussian fitting is performed on the smoothed focus numerical curve to obtain the first Gaussian curve.

[0253] 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 computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0254] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0255] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A focusing method, characterized in that, The method includes: Obtain the initial focus value curve of the region of interest (ROI) image; Gaussian fitting is performed on the initial focus numerical curve to obtain the first Gaussian curve; Based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, the initial focus value curve is compensated to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve. The initial focus ROI image is refocused based on the compensation curve.

2. The method according to claim 1, characterized in that, The angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, are used to compensate the initial focus value curve to obtain a compensation curve, including: The average angular velocity is determined based on the angular velocity data of each focusing position. The average focus value is determined based on the fluctuation of the focus value corresponding to each focus position. Based on the average angular velocity, the average focus value, and the angular velocity data at each focus position, determine the focus value compensation amount corresponding to each focus position. The initial focus value curve is compensated based on the focus value compensation amount corresponding to each focus position to obtain the compensation curve.

3. The method according to claim 2, characterized in that, The step of determining the focus value compensation amount corresponding to each focus position based on the average angular velocity, the average focus value, and the angular velocity data at each focus position includes: The envelope integral area is determined based on the average focus value; Based on the average angular velocity and the angular velocity data corresponding to each of the focusing positions, the compensation ratio corresponding to each of the focusing positions is determined; Based on the envelope integral area and the compensation ratio corresponding to each of the focus positions, the focus value compensation amount corresponding to each focus position is determined.

4. The method according to any one of claims 1-3, characterized in that, The process of focusing the initial focus ROI image based on the compensation curve includes: Gaussian fitting is performed on the compensation curve to obtain a second Gaussian curve; Parabolic fitting is performed on the peak region of the second Gaussian curve to obtain the target fitted curve; The target focus position is determined based on the target fitting curve, and the initial focus ROI image is focused based on the target focus position.

5. The method according to claim 4, characterized in that, Determining the target focus position based on the target fitting curve includes: The fitting result is determined based on the target fitting curve; If the fitting result is successful, the target focus position is determined according to the axis of symmetry of the target fitting curve; If the fitting result is unsuccessful, the target focus position is determined based on the Gaussian mean of the first Gaussian curve.

6. The method according to any one of claims 1-3, characterized in that, The step of performing Gaussian fitting on the initial focus numerical curve to obtain the first Gaussian curve includes: The size of the filter kernel is determined based on the angular velocity data described above; The initial focus value curve is filtered based on the filter kernel size to obtain a smooth focus value curve. Gaussian fitting is performed on the smoothed focus numerical curve to obtain the first Gaussian curve.

7. A focusing device, characterized in that, The device includes: The acquisition module is used to acquire the initial focus value curve of the region of interest (ROI) image. The Gaussian fitting module is used to perform Gaussian fitting on the initial focus numerical curve to obtain the first Gaussian curve. The compensation module is used to compensate the initial focus value curve based on the angular velocity data of each focus position collected by the gyroscope sensor on the terminal, and the focus value fluctuation corresponding to each focus position, to obtain a compensation curve; the focus value fluctuation includes the fluctuation between the focus value corresponding to the focus position on the first Gaussian curve and the focus value on the initial focus value curve. A focusing module is used to focus the initial focused ROI image based on the compensation curve.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.