Focusing method and device, camera equipment and storage medium

By calculating the change in image sharpness between the previous and current focus positions in the imaging device, the focusing step size is adaptively adjusted, solving the problem of low focusing efficiency with a fixed step size, and achieving a more efficient focusing process and a better shooting experience.

CN121908132APending Publication Date: 2026-04-21GEER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GEER TECH CO LTD
Filing Date
2025-12-31
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing imaging devices employ a fixed-step climbing search strategy during autofocus, resulting in low focusing efficiency, which makes it difficult to meet users' needs for rapid shooting and affects the shooting experience.

Method used

By acquiring the image sharpness values ​​of the previous and current focus positions, the sharpness change is calculated, and the focus step size is adaptively adjusted according to the sharpness change until the sharpness change is within a preset range, at which point focusing stops.

Benefits of technology

It improves focusing efficiency, enhances the shooting experience, and achieves a more accurate and efficient focusing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121908132A_ABST
    Figure CN121908132A_ABST
Patent Text Reader

Abstract

The invention discloses a focusing method and device, camera shooting equipment and a storage medium, and relates to the technical field of camera shooting, and the method comprises the steps: in a focusing process, obtaining a first focusing image at a previous focusing position and a second focusing image at a current focusing position; determining a first definition value of the first focusing image, determining a second definition value of the second focusing image, and determining a definition variation based on the first definition value and the second definition value; determining a focusing step length from the current focusing position to the next focusing position according to the definition variable quantity, wherein the definition variable quantity is positively correlated with the focusing step length; and performing focusing according to the focusing step length, and stopping focusing until the definition variation is within a preset range. Compared with an existing focusing mode adopting a fixed step length, the method and the device have the advantages that the focusing step length can be adaptively adjusted through the definition variation between the previous focusing position and the current focusing position, the focusing efficiency is improved, and the shooting experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of camera technology, and more particularly to a focusing method, apparatus, camera equipment, and storage medium. Background Technology

[0002] Currently, in autofocus scenarios of imaging devices (such as smartphones, digital cameras, and surveillance cameras), focusing is generally achieved by driving the lens to move in order to quickly and clearly image the target.

[0003] In the process of achieving autofocus, a fixed step-up search strategy is generally adopted, that is, the lens gradually moves towards the focus at a preset fixed distance, and after passing the focus, it repeatedly moves back and forth to adjust until the depth of focus is reached to complete the focusing process.

[0004] This process of repeatedly adjusting with a fixed step size results in low focusing efficiency, making it difficult to meet users' needs for fast shooting and affecting the shooting experience. Summary of the Invention

[0005] The main objective of this application is to provide a focusing method, apparatus, camera device, and storage medium, which aims to solve the technical problem of low focusing efficiency caused by the existing method of repeatedly adjusting the lens with a fixed step size.

[0006] To achieve the above objectives, this application proposes a focusing method, the method comprising: During the focusing process, the first focused image of the previous focused position and the second focused image of the current focused position are acquired; A first sharpness value of the first focused image is determined, and a second sharpness value of the second focused image is determined, and a sharpness change amount is determined based on the first sharpness value and the second sharpness value; The focus step size for moving from the current focus position to the next focus position is determined based on the change in sharpness, and the change in sharpness is positively correlated with the focus step size. Focusing is performed according to the stated focus step size until the change in sharpness is within a preset range, at which point focusing stops.

[0007] In one embodiment, the step of determining the focus step size for moving from the current focus position to the next focus position based on the change in sharpness includes: Obtain the preset sharpness change threshold and preset fixed step size; Divide the change in sharpness by the preset change in sharpness threshold to obtain the rate of change in sharpness, which is positively correlated with the focus step size. The preset fixed step size is adjusted according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position.

[0008] In one embodiment, the step of adjusting the preset fixed step size according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position includes: Obtain the preset step size adjustment index; The sharpness change rate is exponentially calculated based on the preset step size adjustment index to obtain the step size adjustment coefficient, which is positively correlated with the focus step size. The preset fixed step size is adjusted according to the step size adjustment coefficient to obtain the focus step size for moving from the current focus position to the next focus position.

[0009] In one embodiment, the step of adjusting the preset fixed step size according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position includes: When the sharpness change rate is zero, the preset minimum step size is used as the focus step size for moving from the current focus position to the next focus position; The step of focusing according to the focus step size until the change in sharpness is within a preset range includes: Focusing is performed according to the preset minimum step size until the change in sharpness is negative, and it is determined that the previous focus position corresponding to the negative change in sharpness is in the depth of focus range. Control the lens to move to the previous focus position corresponding to when the change in sharpness is negative, and stop focusing.

[0010] In one embodiment, the step of focusing according to the focus step size until the change in sharpness is within a preset range includes: The lens is moved to focus according to the focus step size control drive component; Based on the focusing step size, the required stabilization time of the driving component when the lens moves to the next focusing position is determined, and the focusing step size is positively correlated with the required stabilization time. After the lens moves to the next focusing position, the current waiting time of the drive component is recorded; If the current waiting time reaches the required stable time, return to the step of obtaining the first focus image of the previous focus position and the second focus image of the current focus position, and stop focusing when the sharpness change is within the preset range.

[0011] In one embodiment, the step of determining the required stabilization time of the drive component when the lens moves to the next focusing position based on the focusing step size includes: Obtain the preset stabilization time of the driving component; Divide the focusing step size by the maximum allowable step size to obtain the step size change rate, which is positively correlated with the required stabilization time. The preset stabilization time is adjusted according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

[0012] In one embodiment, the step of adjusting the preset stabilization time according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position includes: Get the preset duration adjustment index; The step size change rate is exponentially calculated based on the preset duration adjustment index to obtain the duration adjustment coefficient, which is positively correlated with the required stable duration. The preset stabilization time is adjusted according to the duration adjustment coefficient to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

[0013] To achieve the above objectives, this application also proposes a focusing device, the device comprising: The image module is used to acquire the first focused image of the previous focused position and the second focused image of the current focused position during the focusing process; A sharpness module is used to determine a first sharpness value of the first focused image and a second sharpness value of the second focused image, and to determine a sharpness change based on the first sharpness value and the second sharpness value; The step size module is used to determine the focus step size from the current focus position to the next focus position based on the change in sharpness, wherein the change in sharpness is positively correlated with the focus step size. The focusing module is used to focus according to the focusing step size until the change in sharpness is within a preset range and then stop focusing.

[0014] In addition, to achieve the above objectives, this application also proposes a camera device, the camera device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the focusing method described above.

[0015] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the focusing method described above.

[0016] One or more technical solutions proposed in this application have at least the following technical effects: The focusing method of this application includes: during the focusing process, acquiring a first focused image of the previous focusing position and a second focused image of the current focusing position; determining a first sharpness value of the first focused image and a second sharpness value of the second focused image, and determining a sharpness change based on the first sharpness value and the second sharpness value; determining a focusing step size from the current focusing position to the next focusing position according to the sharpness change, wherein the sharpness change is positively correlated with the focusing step size; focusing according to the focusing step size until the sharpness change is within a preset range and then stopping focusing.

[0017] This application first acquires a first focused image from the previous focusing position and a second focused image from the current focusing position. Then, it determines the change in sharpness between the two images. Based on this change in sharpness, it determines the focus step size for moving from the current focusing position to the next focusing position. Focusing is then performed according to this focus step size until the change in sharpness falls within a preset range. Compared to existing focusing methods that use a fixed step size, this application can adaptively adjust the focus step size based on the change in sharpness, improving focusing efficiency and thus enhancing the shooting experience. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the focusing method of this application in Embodiment 1. Figure 2 This is a flowchart illustrating the second embodiment of the focusing method of this application; Figure 3 This is a block diagram of the module structure of the focusing device according to an embodiment of this application; Figure 4 This is a schematic diagram of the hardware operating environment involved in the camera device in the embodiments of this application.

[0021] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0022] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0023] The main solution of this application is: Currently, in autofocus scenarios of imaging devices (such as smartphones, digital cameras and surveillance cameras), in order to achieve fast and clear imaging of the shooting target, focusing is generally achieved by driving the lens to move.

[0024] In the process of achieving autofocus, a fixed step-up search strategy is generally adopted, that is, the lens gradually moves towards the focus at a preset fixed distance, and after passing the focus, it repeatedly moves back and forth to adjust until the depth of focus is reached to complete the focus.

[0025] This process of repeatedly adjusting with a fixed step size results in low focusing efficiency, making it difficult to meet users' needs for fast shooting and affecting the shooting experience.

[0026] To address the aforementioned issues, this application provides a focusing method. First, a first focused image from the previous focusing position and a second focused image from the current focusing position are acquired. Then, the difference in sharpness between the two images is determined. Next, based on the difference in sharpness, a focusing step size is determined to move the focus from the current focusing position to the next focusing position. Focusing is then performed according to this focusing step size until the difference in sharpness falls within a preset range, at which point focusing stops. Compared to existing focusing methods that use a fixed step size, this application can adaptively adjust the focusing step size based on the difference in sharpness, improving focusing efficiency and thus enhancing the shooting experience.

[0027] It should be noted that the executing entity of this application embodiment can be an electronic device with data processing, sharpness calculation, and focusing functions, such as smart glasses with a camera, a camera, etc., or an electronic device capable of realizing the above functions, a camera device executing the focusing method of this application, etc. This embodiment does not limit this. The following uses a camera device (hereinafter referred to as the device) as an example to describe this embodiment and the following embodiments.

[0028] Based on this, this application proposes a focusing method according to a first embodiment, referring to... Figure 1 , Figure 1This is a flowchart illustrating a focusing method according to an embodiment of the present application. In this embodiment, the focusing method may include steps S10 to S40: Step S10: During the focusing process, acquire the first focus image of the previous focus position and the second focus image of the current focus position.

[0029] It should be noted that the previous focus position can be the previous focus position the lens was in during autofocus. The first focus image can be the image captured when the lens was in the previous focus position during autofocus. This first focus image reflects the imaging of the subject at the previous focus position and serves as the basis for subsequent calculations of sharpness changes.

[0030] It should also be noted that the current focus position can be the position the lens has moved to during autofocus. The second focus image can be the image captured after the lens has moved to the current focus position. This second focus image reflects the imaging of the subject at the current focus position. By comparing the second focus image at the current focus position with the first focus image at the previous focus position, the change in image sharpness before and after the lens movement can be determined.

[0031] Step S20: Determine a first sharpness value of the first focused image and a second sharpness value of the second focused image, and determine the sharpness change based on the first sharpness value and the second sharpness value.

[0032] Understandably, the first sharpness value can be an image sharpness value calculated by an image sharpness evaluation algorithm for the first focused image at the previous focus position, used to quantify the sharpness of the first focused image. For example, the device calculates a value representing the sharpness of the first focused image based on an image edge detection algorithm, and this embodiment does not limit this.

[0033] It is also understood that the second sharpness value can be an image sharpness value calculated using an image sharpness evaluation algorithm for the second focused image at the current focus position, used to measure the sharpness of the second focused image.

[0034] It should be understood that the change in sharpness can be calculated as the difference between a first sharpness value and a second sharpness value. This change in sharpness reflects the change in image sharpness after the lens moves from the previous focus position to the current focus position. If the change in sharpness is positive, it indicates that the image sharpness has improved, and subsequent focusing processing continues; if it is negative, it indicates that the sharpness has decreased, the focus has been missed, and refocusing is required. For example, if the first sharpness value is 50 and the second sharpness value is 60, then the change in sharpness is 10, representing the degree of change in image sharpness after the lens moves from the previous focus position to the current focus position.

[0035] In practical use, during the focusing process, the device can acquire a second focused image of the current focusing position and a first focused image of the previous focusing position. Then, based on an image edge detection algorithm, a first sharpness value is calculated for the first focused image, and a second sharpness value is calculated for the second focused image. The difference between the second and first sharpness values ​​is then calculated to obtain the change in sharpness between the current and previous focusing positions.

[0036] Step S30: Determine the focus step size from the current focus position to the next focus position based on the change in sharpness, wherein the change in sharpness is positively correlated with the focus step size.

[0037] Step S40: Focus according to the focus step size until the change in sharpness is within the preset range and then stop focusing.

[0038] It should be noted that the focus step size can be determined based on the change in sharpness, which is the distance the lens moves from the current focus position to the next focus position. This change in sharpness is positively correlated with the focus step size; that is, the larger the change in sharpness, the farther the lens is from the focus point, and the greater the adaptability of the subsequent lens movement focus step size, reducing the time spent in the focusing process and improving the efficiency of the focusing process. Conversely, the smaller the change in sharpness, the closer the lens is to the focus point, and to avoid the lens moving too far and skipping the focus point, the adaptability of the subsequent lens movement focus step size is reduced.

[0039] It's also worth noting that the preset range can be a pre-defined numerical range of sharpness change set in the device, indicating that the lens is close to or has reached the optimal focus position (i.e., focal point). In real-world scenarios, due to physical limitations or hardware constraints, the lens can never be perfectly aligned with the theoretical absolute focus. Therefore, it generally aims for the optimal focus within an allowable error range, i.e., within the preset range near the focal point limit. When the sharpness change is within this preset range, it means the lens is close to or has reached the optimal focus position, and focusing can be stopped. For example, if the preset range is set to [-2, 2], focusing will stop when the calculated sharpness change falls within this range.

[0040] In actual use, after the device obtains the above-mentioned change in sharpness, it can determine the focus step size from the current focus position to the next focus position based on the change in sharpness; then it focuses according to the focus step size until the change in sharpness is within the preset range and then stops focusing. At this time, the lens has approached or reached the near-focus limit.

[0041] Furthermore, in order to obtain the aforementioned focus step size, in this embodiment, the step of determining the focus step size from the current focus position to the next focus position based on the change in sharpness may include: Step S31: Obtain the preset sharpness change threshold and preset fixed step size.

[0042] Understandably, the preset sharpness change threshold can be pre-set, used to define the reference value with the largest sharpness change between two focus positions during autofocus, denoted as . .

[0043] It is also understandable that the preset fixed step size can be a predefined fixed distance for each movement of the lens, and this preset fixed step size can be set to the maximum allowable step size of the lens (i.e., This embodiment does not impose any limitations on this. For example, the preset fixed step size can be set to 0.5mm, so that the lens can move in 0.5mm increments each time it moves, provided there are no other adjustment mechanisms.

[0044] Step S32: Divide the amount of sharpness change by the preset sharpness change threshold to obtain the sharpness change rate, which is positively correlated with the focus step size.

[0045] Step S33: Adjust the preset fixed step size according to the sharpness change rate to obtain the focus step size from the current focus position to the next focus position.

[0046] It should be noted that the sharpness change rate can be obtained by dividing the sharpness change amount by the preset sharpness change threshold, and is used to intuitively represent the proportional relationship between the degree of sharpness change and the preset sharpness change threshold. For example, if the sharpness change amount is 20 and the preset sharpness change threshold is 10, then the sharpness change rate is 2.

[0047] The rate of change in sharpness is positively correlated with the focus step size. That is, the larger the rate of change in sharpness, the farther the lens is from the focus point, and the greater the adaptability of the focus step size for subsequent lens movements, reducing the time spent in the focusing process and improving the efficiency of the focusing process. The smaller the rate of change in sharpness, the closer the lens is to the focus point. In order to avoid the lens moving too far and skipping the focus point, the adaptability of the focus step size for subsequent lens movements is reduced.

[0048] For example, to facilitate understanding of the process of adjusting the preset fixed step size based on the rate of change in sharpness, an example is given below. During lens focusing, the second sharpness value of the image at the current focusing position can be used as a reference. The first focused image compared to the image at the previous focus position. Difference, determining the amount of sharpness change between the two. Then, the focus step size for moving the lens from the current focus position to the next focus position is dynamically adjusted. ,Right now: ; in, This is the focus step size for the lens to move from the current focus position to the next focus position; This is the maximum allowable step size; Set a threshold for changes in sharpness; This represents the change in sharpness. This represents the rate of change in sharpness.

[0049] In this embodiment, after determining the change in sharpness between the previous focus position and the current focus position, the device first obtains a preset sharpness change threshold and a maximum allowable step size. Then, it divides the change in sharpness by the preset sharpness change threshold to obtain the sharpness change rate. Next, it multiplies this sharpness change rate by the maximum allowable step size to obtain the focus step size for moving from the current focus position to the next focus position. Compared to traditional focusing methods using a fixed step size, the sharpness change rate allows for more intelligent dynamic adjustment of the focus step size based on the actual changes in image sharpness, thereby achieving more precise focusing and effectively improving the accuracy of the focusing process.

[0050] Furthermore, to improve the sensitivity to changes in step size, in this embodiment, the step of adjusting the preset fixed step size according to the rate of change in sharpness to obtain the focus step size for moving from the current focus position to the next focus position includes: Step S331: Obtain the preset step size adjustment index.

[0051] Understandably, the preset step size adjustment index can be a pre-set parameter used to control the sensitivity of the step size to changes in sharpness, denoted as . This reflects the sensitivity of adjusting the focus step size based on the rate of change in sharpness during the focusing process.

[0052] Step S332: Perform a power operation on the sharpness change rate according to the preset step size adjustment index to obtain the step size adjustment coefficient, which is positively correlated with the focus step size.

[0053] Step S333: Adjust the preset fixed step size according to the step size adjustment coefficient to obtain the focus step size from the current focus position to the next focus position.

[0054] It should be noted that the step size adjustment coefficient can be obtained by exponentiation of the sharpness change rate (i.e., the exponent is the preset step size adjustment index), which determines the degree of magnification or reduction of the focus step size relative to the preset fixed step size. For example, if the sharpness change rate is 2 and the preset step size adjustment index is 3, the step size adjustment coefficient obtained by exponentiation is 8.

[0055] The step size adjustment coefficient is positively correlated with the focus step size. That is, the larger the step size adjustment coefficient, the farther the lens is from the focus point, and the greater the adaptability of the focus step size for subsequent lens movements, reducing the time spent in the focusing process and improving the efficiency of the focusing process. The smaller the step size adjustment coefficient, the closer the lens is to the focus point. In order to avoid the lens moving too far and skipping the focus point, the adaptability of the focus step size for subsequent lens movements is reduced.

[0056] For example, to facilitate understanding of the process of adjusting the preset fixed step size according to the step size adjustment coefficient, an example is given below. During lens focusing, if the change in sharpness between the current focusing position and the previous focusing position is obtained... Based on the aforementioned changes in sharpness, preset step size adjustment index, preset sharpness change threshold, and preset fixed step size, the focusing step size for the lens to move from the current focusing position to the next focusing position can be dynamically adjusted. ,Right now: ; in, This is the focus step size for the lens to move from the current focus position to the next focus position; This is the maximum allowable step size; Set a threshold for changes in sharpness; This represents the change in sharpness. Preset step size adjustment index (preferred) ∈[0.5,1]), used to control the sensitivity of the step size to the rate of change of sharpness; This is the step size adjustment coefficient.

[0057] After determining the aforementioned rate of change in sharpness, the device in this embodiment can further obtain a preset step size adjustment index. Then, it performs a power operation on the aforementioned rate of change in sharpness and the preset step size adjustment index to obtain a step size adjustment coefficient. Next, the step size adjustment coefficient is multiplied by the maximum allowable step size to obtain the focusing step size for moving from the current focusing position to the next focusing position. When the rate of change in sharpness is large, the power operation increases the step size adjustment coefficient, thereby increasing the focusing step size, allowing the lens to quickly approach the focus point, improving focusing efficiency, and avoiding wasting too much time due to a small step size when moving away from the focus point. When the rate of change in sharpness is small, the step size adjustment coefficient decreases, and the focusing step size also decreases. This prevents the lens from skipping the optimal focusing position due to an excessively large step size when approaching the focus point, enabling more precise focusing and further improving the adaptiveness of the focusing process.

[0058] Furthermore, to prevent the lens from getting stuck in the focusing process due to ineffective shaking at a microscopic scale, in this embodiment, the step of adjusting the preset fixed step size according to the sharpness change rate to obtain the focusing step size from the current focusing position to the next focusing position includes: When the sharpness change rate is zero, the preset minimum step size is used as the focus step size for moving from the current focus position to the next focus position; The step of focusing according to the focus step size until the change in sharpness is within a preset range includes: Focusing is performed according to the preset minimum step size until the change in sharpness is negative, and it is determined that the previous focus position corresponding to the negative change in sharpness is in the depth of focus range. Control the lens to move to the previous focus position corresponding to when the change in sharpness is negative, and stop focusing.

[0059] It should be noted that the preset minimum step size can be the minimum distance the lens can move in advance. In certain special situations (such as zero change in sharpness), the lens will move according to this minimum distance to avoid insufficient focus adjustment due to an excessively small step size, or to prevent infinite loops caused by an unreasonable step size setting. For example, if the preset minimum step size is set to 0.01mm, the lens will move by 0.01mm when the minimum step size is required.

[0060] It should also be noted that the depth of focus range can be the range near the focal limit. Within this range, it means that the lens is in focus and has completed focusing. Because in real-world scenarios, due to physical limitations or hardware constraints, lenses can never be perfectly aligned with the theoretical absolute focus. Therefore, generally, reaching the depth of focus range is sufficient for the lens to complete focusing.

[0061] For example, to facilitate understanding of the preset minimum step size set above, an example is given below. When determining the change in sharpness between the current focus position and the previous focus position... Then, the focus step size for moving the lens from the current focus position to the next focus position can be adjusted based on the following formula. : ; in, This is the focus step size for the lens to move from the current focus position to the next focus position; This is the maximum allowable step size; Set a threshold for changes in sharpness; This represents the change in sharpness. This is the minimum allowable step size.

[0062] when When the focus is large (i.e., far from the focal point, the sharpness increases rapidly). near At this point, a rapid search can be achieved. When When the focus is low (i.e., close to the point of focus, the sharpness increases slowly), the sharpness increases slowly. near It can perform fine-grained searches in small steps, moving infinitely close to the focus point to avoid skipping it.

[0063] In practical use, considering that image sharpness values ​​can be affected by noise, the lens may experience ineffective shaking at a microscopic scale when approaching focus, causing the focusing process to lock up and unable to exit. Therefore, a preset minimum step size can be used as a safety measure. When the sharpness change rate is zero, the device can focus according to the preset minimum step size until the sharpness change is negative. At this point, it indicates that the lens has passed the focus point, and the corresponding previous focus position is closer to the focus point and within the depth of focus range. Then, the lens is controlled to move to this previous focus position and focus stops. This prevents the focusing process from locking up and improves its stability.

[0064] This application provides a focusing method that first acquires a first focused image from the previous focusing position and a second focused image from the current focusing position. Then, it determines the change in sharpness between the two images. Based on this change in sharpness, it determines the focusing step size for moving from the current focusing position to the next focusing position. Focusing is then performed according to this focusing step size until the change in sharpness falls within a preset range, at which point focusing stops. Compared to existing focusing methods that use a fixed step size, this embodiment can adaptively adjust the focusing step size based on the change in sharpness, improving focusing efficiency and thus enhancing the shooting experience.

[0065] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to the above embodiment can be referred to the above description, and will not be repeated hereafter. On this basis, a second embodiment of the dialogue method of this application is proposed, please refer to... Figure 2 , Figure 2 This is a flowchart illustrating a second embodiment of the focusing method of this application. To obtain the waiting time of the lens's driving components during the focusing process, such as... Figure 2 As shown, in this embodiment, the step of focusing according to the focus step size until the change in sharpness is within a preset range may include: Step S41: Move the lens to focus according to the focusing step size control drive component.

[0066] It should be noted that the driving component can be a device used to drive the lens movement, such as a stepper motor or a voice coil motor (VCM), and this embodiment is not limited to this. This driving component can drive the lens to move according to the focusing step size, as instructed by the control signal, to achieve focusing.

[0067] Step S42: Based on the focusing step size, determine the required stabilization time of the driving component when the lens moves to the next focusing position, wherein the focusing step size is positively correlated with the required stabilization time.

[0068] Understandably, the required stabilization time can be determined based on the focus step size; it's the time needed for the lens to remain stable after the drive component moves it to the next focus position. This is because vibrations and other unstable factors can occur during lens movement, thus requiring a certain amount of time for the lens to stabilize to ensure the accuracy and reliability of subsequently acquired image sharpness data.

[0069] The required stabilization time is positively correlated with the focus step size; that is, the larger the focus step size, the greater the lens movement, and the longer the required stabilization time. For example, the required stabilization time is 50ms when the focus step size is 0.2mm, but when the focus step size is increased to 0.4mm, the required stabilization time may become 100ms.

[0070] Step S43: After the lens moves to the next focusing position, record the current waiting time of the drive component.

[0071] Step S44: If the current waiting time reaches the required stable time, return to the step of obtaining the first focus image of the previous focus position and the second focus image of the current focus position, and stop focusing when the sharpness change is within the preset range.

[0072] It should be noted that the current waiting time can be the time recorded after the lens moves to the next focus position, during which the drive unit is in a waiting state. This current waiting time is used to compare with the required stabilization time to determine whether the lens has reached a stable state. For example, starting from when the lens stops moving, the current waiting time increases over time. When it equals the required stabilization time, it indicates that the lens has stabilized, and subsequent focusing operations can then proceed.

[0073] In practical use, after determining the aforementioned focusing step size, the device controls the drive component to move the lens for focusing according to this step size. Then, based on this focusing step size, it determines the required stabilization time for the drive component when the lens moves to the next focusing position. Next, after the lens moves to the next focusing position, the current waiting time of the drive component is recorded. If the current waiting time reaches the required stabilization time, the current change in sharpness is recalculated for subsequent focusing processes until the change in sharpness is within a preset range, at which point focusing stops. This ensures that focusing only occurs after the lens has stabilized, avoiding inaccurate image sharpness due to lens instability and thus improving the reliability of the focusing process.

[0074] Furthermore, in order to obtain the required stabilization time mentioned above, in this embodiment, the step of determining the required stabilization time of the driving component when the lens moves to the next focusing position based on the focusing step size includes: Step S421: Obtain the preset stabilization time of the drive component.

[0075] Understandably, the preset stabilization time can be pre-set, representing the baseline time required for the drive component to maintain a stable state and eliminate unstable factors such as vibration after completing a focus movement. For example, in typical autofocus scenarios, based on testing and experience, the preset stabilization time for the drive component can be set to 50 milliseconds.

[0076] Step S422: Divide the focusing step size by the maximum allowable step size to obtain the step size change rate, which is positively correlated with the required stabilization time.

[0077] Step S423: Adjust the preset stabilization time according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

[0078] It should be noted that the step size change rate is a relative value obtained by dividing the focus step size by the maximum permissible step size. It represents the ratio of the current focus step size to the maximum permissible step size, reflecting the relative magnitude of the current focus step size within the system's allowable range. The step size change rate is positively correlated with the required stabilization time. A larger step size change rate indicates a larger lens movement, thus requiring a longer stabilization time for the drive components to eliminate unstable factors such as vibrations during movement, preventing inaccurate image sharpness due to instability. Conversely, a smaller step size change rate reduces the required stabilization time, improving focusing efficiency and avoiding unnecessary waiting time.

[0079] In practical use, after the lens is moved to focus according to the focus step size control drive component, the device can first obtain the preset stabilization time of the drive component; then divide the focus step size by the maximum allowable step size to obtain the step size change rate; finally, adjust the preset stabilization time according to the step size change rate to obtain the required stabilization time of the drive component when the lens moves to the next focus position, thereby accurately determining the adjustment range of the required stabilization time through the step size change rate.

[0080] Furthermore, in order to accurately obtain the required stabilization time, in this embodiment, the step of adjusting the preset stabilization time according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position includes: Get the preset duration adjustment index; The step size change rate is exponentially calculated based on the preset duration adjustment index to obtain the duration adjustment coefficient, which is positively correlated with the required stable duration. The preset stabilization time is adjusted according to the duration adjustment coefficient to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

[0081] Understandably, the preset duration adjustment index can be pre-set as a parameter to adjust the sensitivity of the stable duration, denoted as... .

[0082] It is also understandable that the duration adjustment coefficient can be obtained by exponentiation of the step change rate with a preset duration adjustment index. This duration adjustment coefficient is proportional to the required stabilization time. That is, the larger the duration adjustment coefficient, the greater the lens movement, and therefore the longer the stabilization time required for the drive component; when the duration adjustment coefficient is small, the lens movement is small, and the required stabilization time is reduced accordingly.

[0083] For example, to facilitate understanding of the process of determining the required stabilization time, after the driving component moves, the focusing step size of the driving component's movement can be used as a reference. Dynamically calculate the required settling time of the drive components This replaces the traditional fixed delay time, and its calculation formula is as follows: ; in, This is the focus step size for the lens to move from the current focus position to the next focus position; This is the maximum allowable step size; This is the waiting time corresponding to the maximum allowable step size of the driven component movement; The waiting time corresponding to the minimum allowable step size of the drive component movement; Adjust the index for the preset duration (preferred) ∈[0.5,1]), used to control the stabilization time required for the drive components and the sensitivity of the focus step size.

[0084] The focusing step size when the drive component moves A larger value indicates a larger range of camera movement. near This ensures stable component movement. The focusing step size used to drive component movement... A smaller movement indicates a smaller camera movement. near This can reduce unnecessary waiting time, improve focusing efficiency, and avoid unnecessary waiting time.

[0085] In this embodiment, considering that a fixed hardware stabilization time is required after each movement of the driving component, the large number of movement operations of the driving component significantly slows down the focusing speed. Therefore, a preset duration adjustment index can be introduced. The duration adjustment coefficient is obtained by exponentiation of the step size change rate, thereby more precisely determining the adjustment range of the required stabilization time of the driving component, and further improving the focusing efficiency.

[0086] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the focusing method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0087] This application also provides a focusing device; please refer to... Figure 3 , Figure 3 This is a block diagram of the module structure of the focusing device according to an embodiment of this application; in this embodiment, the focusing device includes: Image module 301 is used to acquire a first focused image of the previous focused position and a second focused image of the current focused position during the focusing process; The sharpness module 302 is used to determine a first sharpness value of the first focused image and a second sharpness value of the second focused image, and to determine a sharpness change amount based on the first sharpness value and the second sharpness value; Step module 303 is used to determine the focus step size from the current focus position to the next focus position based on the change in sharpness, wherein the change in sharpness is positively correlated with the focus step size. The focusing module 304 is used to focus according to the focusing step size until the sharpness change is within a preset range and then stop focusing.

[0088] This embodiment first acquires a first focused image from the previous focusing position and a second focused image from the current focusing position. Then, it determines the change in sharpness between the two images. Based on this change in sharpness, it determines the focusing step size for moving from the current focusing position to the next focusing position. Focusing is then performed according to this focusing step size until the change in sharpness falls within a preset range, at which point focusing stops. Compared to existing focusing methods that use a fixed step size, this embodiment can adaptively adjust the focusing step size based on the change in sharpness, improving focusing efficiency and thus enhancing the shooting experience.

[0089] In one implementation, the step size module 303 is further configured to obtain a preset sharpness change threshold and a preset fixed step size; divide the sharpness change amount by the preset sharpness change threshold to obtain a sharpness change rate, wherein the sharpness change rate is positively correlated with the focus step size; and adjust the preset fixed step size according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position.

[0090] In one implementation, the step size module 303 is further configured to obtain a preset step size adjustment index; perform a power operation on the sharpness change rate according to the preset step size adjustment index to obtain a step size adjustment coefficient, wherein the step size adjustment coefficient is positively correlated with the focusing step size; and adjust the preset fixed step size according to the step size adjustment coefficient to obtain the focusing step size for moving from the current focusing position to the next focusing position.

[0091] In one implementation, the step size module 303 is further configured to use a preset minimum step size as the focus step size for moving from the current focus position to the next focus position when the sharpness change rate is zero. The focusing module 304 is further configured to focus according to the preset minimum step size until the change in sharpness is negative, and determine that the previous focusing position corresponding to the negative change in sharpness is within the depth of focus range; control the lens to move to the previous focusing position corresponding to the negative change in sharpness and stop focusing.

[0092] In one implementation, the focusing module 304 is further configured to control the driving component to move the lens for focusing according to the focusing step size; determine the required stabilization time of the driving component when the lens moves to the next focusing position according to the focusing step size, wherein the focusing step size is positively correlated with the required stabilization time; after the lens moves to the next focusing position, record the current waiting time of the driving component; if the current waiting time reaches the required stabilization time, return to the step of acquiring the first focusing image of the previous focusing position and the second focusing image of the current focusing position, until focusing stops when the change in sharpness is within a preset range.

[0093] In one implementation, the focusing module 304 is further configured to obtain a preset stabilization time of the driving component; divide the focusing step size by the maximum allowable step size to obtain the step size change rate, wherein the step size change rate is positively correlated with the required stabilization time; and adjust the preset stabilization time according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

[0094] In one implementation, the focusing module 304 is further configured to obtain a preset duration adjustment index; perform a power operation on the step size change rate according to the preset duration adjustment index to obtain a duration adjustment coefficient, wherein the duration adjustment coefficient is positively correlated with the required stable duration; and adjust the preset stable duration according to the duration adjustment coefficient to obtain the required stable duration of the driving component when the lens moves to the next focusing position.

[0095] Other embodiments or specific implementations of the focusing device of this application can be found in the above-described method embodiments, and will not be repeated here.

[0096] The focusing device provided in this application, employing the focusing method described in the above embodiments, can solve the technical problem of low focusing efficiency caused by repeatedly adjusting the lens with a fixed step size in existing methods. Compared with the prior art, the beneficial effects of the focusing device provided in this application are the same as those of the focusing method provided in the above embodiments, and other technical features in the focusing device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0097] This application provides a camera device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the focusing method in the above embodiments.

[0098] The following is for reference. Figure 4 , Figure 4 This is a schematic diagram of the hardware operating environment involved in the camera device in the embodiments of this application, showing a structural schematic diagram suitable for implementing the camera device in the embodiments of this application. The camera device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (PADs), portable media players (PMPs), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The camera device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of this application.

[0099] like Figure 4As shown, the camera device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in the read-only memory 1002 or a program loaded from the storage device 1003 into the random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the camera device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the camera device to communicate wirelessly or wiredly with other devices to exchange data. Although camera devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0100] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0101] The camera device provided in this application, employing the focusing method described in the above embodiments, can solve the technical problem of low focusing efficiency caused by repeatedly adjusting the lens with a fixed step size in existing methods. Compared with the prior art, the beneficial effects of the camera device provided in this application are the same as those of the focusing method provided in the above embodiments, and other technical features of this camera device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0102] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0103] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0104] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the focusing method in the above embodiments.

[0105] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination thereof.

[0106] The aforementioned computer-readable storage medium may be included in the camera device; or it may exist independently and not assembled into the camera device.

[0107] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a camera device, cause the camera device to: acquire a first focused image of the previous focused position and a second focused image of the current focused position during the focusing process; determine a first sharpness value of the first focused image and a second sharpness value of the second focused image, and determine a sharpness change based on the first sharpness value and the second sharpness value; determine a focusing step size for moving from the current focused position to the next focused position based on the sharpness change, wherein the sharpness change is positively correlated with the focusing step size; and focus according to the focusing step size until the sharpness change is within a preset range and then stop focusing.

[0108] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0109] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0110] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0111] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described focusing method. This solves the technical problem of low focusing efficiency caused by repeatedly adjusting the lens with a fixed step size in existing methods. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the focusing method provided in the above embodiments, and will not be repeated here.

[0112] The above description is only a part of the embodiments of this application and does not limit the scope of protection of this application. All equivalent structural transformations made under the technical concept of this application and using the content of this application specification and drawings, or direct / indirect applications in other related technical fields, are included in the scope of protection of this application.

Claims

1. A focusing method, characterized in that, The method includes: During the focusing process, the first focused image of the previous focused position and the second focused image of the current focused position are acquired; A first sharpness value of the first focused image is determined, and a second sharpness value of the second focused image is determined, and a sharpness change amount is determined based on the first sharpness value and the second sharpness value; The focus step size for moving from the current focus position to the next focus position is determined based on the change in sharpness, and the change in sharpness is positively correlated with the focus step size. Focusing is performed according to the stated focus step size until the change in sharpness is within a preset range, at which point focusing stops.

2. The method as described in claim 1, characterized in that, The step of determining the focus step size from the current focus position to the next focus position based on the change in sharpness includes: Obtain the preset sharpness change threshold and preset fixed step size; Divide the change in sharpness by the preset change in sharpness threshold to obtain the rate of change in sharpness, which is positively correlated with the focus step size. The preset fixed step size is adjusted according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position.

3. The method as described in claim 2, characterized in that, The step of adjusting the preset fixed step size according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position includes: Obtain the preset step size adjustment index; The sharpness change rate is exponentially calculated based on the preset step size adjustment index to obtain the step size adjustment coefficient, which is positively correlated with the focus step size. The preset fixed step size is adjusted according to the step size adjustment coefficient to obtain the focus step size for moving from the current focus position to the next focus position.

4. The method as described in claim 2, characterized in that, The step of adjusting the preset fixed step size according to the sharpness change rate to obtain the focus step size for moving from the current focus position to the next focus position includes: When the sharpness change rate is zero, the preset minimum step size is used as the focus step size for moving from the current focus position to the next focus position; The step of focusing according to the focus step size until the change in sharpness is within a preset range includes: Focusing is performed according to the preset minimum step size until the change in sharpness is negative, and it is determined that the previous focus position corresponding to the negative change in sharpness is in the depth of focus range. Control the lens to move to the previous focus position corresponding to when the change in sharpness is negative, and stop focusing.

5. The method as described in claim 1, characterized in that, The step of focusing according to the focus step size until the change in sharpness is within a preset range includes: The lens is moved to focus according to the focus step size control drive component; Based on the focusing step size, the required stabilization time of the driving component when the lens moves to the next focusing position is determined, and the focusing step size is positively correlated with the required stabilization time. After the lens moves to the next focusing position, the current waiting time of the drive component is recorded; If the current waiting time reaches the required stable time, return to the step of acquiring the first focus image of the previous focus position and the second focus image of the current focus position, and stop focusing when the sharpness change is within the preset range.

6. The method as described in claim 5, characterized in that, The step of determining the required stabilization time of the drive component when the lens moves to the next focusing position based on the focusing step size includes: Obtain the preset stabilization time of the driving component; Divide the focusing step size by the maximum allowable step size to obtain the step size change rate, which is positively correlated with the required stabilization time. The preset stabilization time is adjusted according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

7. The method as described in claim 6, characterized in that, The step of adjusting the preset stabilization time according to the step size change rate to obtain the required stabilization time of the driving component when the lens moves to the next focusing position includes: Get the preset duration adjustment index; The step size change rate is exponentially calculated based on the preset duration adjustment index to obtain the duration adjustment coefficient, which is positively correlated with the required stable duration. The preset stabilization time is adjusted according to the duration adjustment coefficient to obtain the required stabilization time of the driving component when the lens moves to the next focusing position.

8. A focusing device, characterized in that, The device includes: The image module is used to acquire the first focused image of the previous focused position and the second focused image of the current focused position during the focusing process; A sharpness module is used to determine a first sharpness value of the first focused image and a second sharpness value of the second focused image, and to determine a sharpness change based on the first sharpness value and the second sharpness value; The step size module is used to determine the focus step size from the current focus position to the next focus position based on the change in sharpness, wherein the change in sharpness is positively correlated with the focus step size. The focusing module is used to focus according to the focusing step size until the change in sharpness is within a preset range and then stop focusing.

9. A camera device, characterized in that, The camera device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the focusing method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the focusing method as described in any one of claims 1 to 7.