Automatic focusing method and device, storage medium and computer program product
Optimizing the autofocus strategy through deep reinforcement learning model, the problems of traditional methods' sensitivity to environmental factors and slow response speed are solved, and more efficient and robust autofocus performance is achieved.
Patent Information
- Application Number
- CN202411853038.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-18
AI Technical Summary
The traditional autofocus method is not sensitive to environmental factors such as light and noise, and is slow to respond to changes in the distance of the target object, resulting in insufficient performance and robustness.
By constructing a deep reinforcement learning model, the image clarity and acquisition parameters of the current image are used as the state space, the focal length and aperture size are adjusted as the action space, and the reward function is defined to optimize the focus strategy.
The focus strategy is optimized, and the performance and robustness of autofocus are improved, so that it can adapt to different environments and scenarios faster and more accurately.
Smart Images

Figure CN119653234A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of detection imaging technology, and in particular to an automatic focusing method and device, a storage medium, and a computer program product. Background Art
[0002] Autofocus technology is an important research direction. Traditional autofocus methods are usually based on relevant image clarity indicators (such as contrast, gradient, etc.) or feature point matching (such as SIFT (a scale-invariant feature extraction method), SURF (a feature detection algorithm for image recognition), etc.), and automatically adjust the camera's focal length or aperture size by analyzing and processing the image to achieve focusing. However, the above traditional autofocus methods have problems such as low sensitivity to environmental factors such as light and noise, and slow response speed to changes in the distance of the target object. Summary of the invention
[0003] The main technical problem solved by the present invention is how to improve the performance and robustness of auto-focus. The present invention provides an auto-focus method and a device thereof, which can optimize the focusing strategy and improve the performance and robustness of auto-focus.
[0004] According to the first aspect, an embodiment provides an automatic focusing method, including:
[0005] Determine the state space, action space, and reward function of the deep reinforcement learning model;
[0006] Acquire acquisition parameters when the image acquisition unit acquires the current image and the image clarity of the current image; wherein the state space includes the image clarity and the acquisition parameters; the action space includes the acquisition parameters; the acquisition parameters include focal length and / or aperture size; the reward function is a function obtained according to the change amount of the acquisition parameters in two adjacent acquisitions of the current image and the image clarity;
[0007] The deep reinforcement learning model outputs an optimal autofocus strategy based on the image clarity and the acquisition parameters.
[0008] In one embodiment, the reward function is expressed as:
[0009] R = α·C-β·|P|;
[0010] Among them, C represents the image clarity; P represents the above-mentioned change amount, |P| represents the sum of the absolute values of the above-mentioned change amounts; α represents the first weight coefficient, α>0; β represents the second weight coefficient, β>0.
[0011] In one embodiment, the reward function is expressed as:
[0012] R = α·C-β·|P|+γ·G;
[0013] Among them, C represents the image clarity; P represents the above-mentioned change, |P| represents the sum of the absolute values of the above-mentioned change; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0.
[0014] In one embodiment, the reward function is expressed as:
[0015] R=α·C-β·w(C,|P|)·|P|+γ·G;
[0016] Among them, C represents the image clarity; P represents the above-mentioned change amount, |P| represents the sum of the absolute values of the above-mentioned change amounts; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0; w(C,|P|) represents a dynamic adjustment function, and the value of w(C,|P|) decreases when the C and the |P| increase.
[0017] In one embodiment, the expression of w(C,|P|) is:
[0018]
[0019] Among them, the above b and k are both preset hyperparameters.
[0020] According to the second aspect, an embodiment provides an automatic focusing device, comprising:
[0021] A model building unit, configured to determine a state space, an action space, and a reward function of a deep reinforcement learning model;
[0022] The clarity calculation unit is configured to obtain the image clarity of the current image and the acquisition parameters when the image acquisition unit acquires the current image; wherein the state space includes the image clarity and the acquisition parameters; the action space includes the acquisition parameters; the acquisition parameters include focal length and / or aperture size; the reward function is a function obtained according to the change amount of the acquisition parameters in two adjacent acquisitions of the current image and the image clarity;
[0023] An optimal strategy output unit, configured for the deep reinforcement learning model to output an optimal autofocus strategy based on the image clarity and the acquisition parameters;
[0024] The image acquisition unit is configured to perform auto-focusing according to the optimal auto-focusing strategy.
[0025] In one embodiment, the reward function is expressed as:
[0026] R = α·C-β·|P|+γ·G;
[0027] Among them, C represents the image clarity; P represents the above-mentioned change, |P| represents the sum of the absolute values of the above-mentioned change; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0.
[0028] In one embodiment, the reward function is expressed as:
[0029] R=α·C-β·w(C,|P|)·|P|+γ·G;
[0030] Among them, C represents the image clarity; P represents the above-mentioned change amount, |P| represents the sum of the absolute values of the above-mentioned change amounts; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0; w(C,|P|) represents a dynamic adjustment function, and the value of w(C,|P|) decreases when the C and the |P| increase.
[0031] According to a third aspect, an embodiment provides a computer-readable storage medium, wherein the computer-readable storage medium includes a program, wherein the program can be executed by a processor to implement a method as described in any embodiment of the present invention.
[0032] According to a fourth aspect, in one embodiment, a computer program product is provided, comprising a computer program and / or instructions, wherein when the computer program and / or instructions are executed by a processor, the method described in any one of the embodiments herein is implemented.
[0033] The beneficial effects of this application are:
[0034] This autofocus method constructs a deep reinforcement learning model, uses the image clarity and acquisition parameters of the current image as the state space, and adjusts the focal length and aperture size of the image acquisition unit as the action space, and the reward function is a function obtained according to the change amount of the above acquisition parameters in two adjacent acquisitions of the current image and the image clarity; after obtaining the image clarity of the current image and the acquisition parameters when the image acquisition unit acquires the current image, the deep reinforcement learning model outputs the optimal autofocus strategy based on the image clarity and the acquisition parameters, that is, realizes the optimization of the focus strategy, thereby improving the performance and robustness of the autofocus. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of a flow chart of an automatic focusing method according to an embodiment;
[0036] Figure 2 A schematic diagram of a module of an autofocus device according to an embodiment. DETAILED DESCRIPTION
[0037] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.
[0038] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.
[0039] The serial numbers of the components in this document, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings).
[0040] In recent years, deep reinforcement learning, as an emerging adaptive control method, has been widely used in the field of autofocus. Deep reinforcement learning is a method that combines deep learning and reinforcement learning. It can improve the focusing performance and robustness by learning and optimizing the autofocus strategy. The basic idea of deep reinforcement learning is to enable the intelligent agent (such as a robot) to learn how to choose the best action in different states to maximize the cumulative reward by constantly trying different actions in the environment.
[0041] The technical concept of this application is: by reconstructing the state space, action space and reward function of the deep reinforcement learning model, and then continuously learning and adjusting the focus strategy during the training process of the deep reinforcement learning model, so as to improve the focus accuracy and response speed of the deep reinforcement learning model, while also being able to adapt to different environments and scenarios.
[0042] The technical solution of the present application will be described in detail below in conjunction with embodiments.
[0043] Please refer to Figure 1 , the present application provides an automatic focusing method. The automatic focusing method comprises:
[0044] Step S100: Determine a deep reinforcement learning model;
[0045] Step S200: Obtaining image clarity and acquisition parameters;
[0046] Step S300: The deep reinforcement learning model outputs the optimal auto-focus strategy.
[0047] Specifically, step S100 includes: determining the state space, action space and reward function of the deep reinforcement learning model; wherein the state space includes the image clarity of the current image and the acquisition parameters when the image acquisition unit acquires the current image; the action space includes the above acquisition parameters; the acquisition parameters include the focal length and / or aperture size; the reward function is a function obtained based on the change amount of the above acquisition parameters in two adjacent acquisitions of the current image and the image clarity. For example, a deep reinforcement learning model can be directly constructed based on the above state space and action space.
[0048] In some embodiments, the state space may also include depth information of the scene (such as the depth information of the current image). The depth information may be obtained by capturing images of the scene using an RGBD camera. An RGBD camera is a camera that can capture color images and depth information at the same time. The depth information may also be obtained by analyzing the current image using a binocular stereo matching algorithm (such as an existing RAFT-Stereo matching algorithm). The RAFT-Stereo algorithm is an algorithm for stereo matching that uses multi-layer cyclic field transforms to accurately locate corresponding points in the left and right images. The acquisition parameters contained in the state space may be directly used to determine the parameters at the current image clarity, i.e., to record the camera parameters at the current image clarity.
[0049] Specifically, step S200 includes: acquiring the image clarity of the current image and acquisition parameters when the image acquisition unit acquires the current image.
[0050] Specifically, step S300 includes: the deep reinforcement learning model outputs an optimal autofocus strategy based on image clarity and acquisition parameters.
[0051] In some embodiments, step S100 further includes: performing image acquisition by an image acquisition unit to obtain a current image.
[0052] It should be noted that the deep reinforcement learning model in step 100 can directly adopt the existing deep reinforcement learning algorithm / network in the field. For example, a deep Q network (DQN) algorithm can be used. The above-mentioned deep Q network algorithm is a reinforcement learning algorithm that combines deep learning and Q learning. Q-learning is a reinforcement learning method based on estimating a state-action value function, which is used to learn the optimal action selection strategy by trial and error in an unknown environment. The core of Q learning is to guide decision-making by estimating a state-action value function (Q function), and to learn the optimal action selection strategy by constantly trying and updating the Q value of the state-action pair according to the feedback reward. The basic principle of the deep Q network algorithm is to learn a strategy by constantly interacting with the environment to maximize the cumulative reward in each state. The characteristics of the deep Q network algorithm include using experience replay technology to break the correlation between data and improve the stability of learning.
[0053] In some embodiments, in step S100, the deep reinforcement learning model includes two networks: one is a performance network, which is responsible for interacting with the virtual camera environment, selecting the action to be performed at the next moment, and obtaining interaction samples; the other is a target network, which is responsible for calculating the target value. The structures of the two networks are the same. Since the specific structures and data processing processes of the above two networks belong to the prior art in this field, they will not be repeated here.
[0054] In step S100, those skilled in the art may determine the acquisition parameters by themselves. For example, the acquisition parameters may be focal length and aperture size; the acquisition parameters may also be one of the focal length and aperture size.
[0055] In some embodiments, in step S100, the reward function mainly considers two factors: image clarity and the adjustment range of acquisition parameters. The reward function is used to guide the intelligent agent (such as a deep reinforcement learning model) to adopt a more reasonable focus strategy. For example, the expression of the reward function is:
[0056] R = α·C-β·|P|;
[0057] Wherein, C represents image clarity; |P| represents the sum of changes in the above acquisition parameters in two adjacent acquisitions of the current image; α represents the first weight coefficient, α>0; β represents the second weight coefficient, β>0.
[0058] From the expression of the reward function, it can be seen that: when the value of C is larger, that is, the image clarity of the current image is higher, the value of the reward function is larger; when the value of |P| is smaller, that is, the absolute value of the above sum is smaller, the value of the reward function is larger. The above |P| is determined according to the adjustment range of the camera parameters (such as the above acquisition parameters).
[0059] In some embodiments, in step S100, the reward function mainly considers three factors: image clarity, the adjustment range of the acquisition parameters, and whether the image clarity reaches a preset image clarity threshold. For example, the expression of the reward function is:
[0060] R = α·C-β·|P|+γ·G;
[0061] Where C represents the image clarity; |P| represents the sum of the absolute values of the above changes; G is equal to 1 or 0, 1 means that the image clarity reaches the preset image clarity threshold C goal , 0 means the image clarity does not reach the preset image clarity threshold C goal ; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0. It can be understood that the above γ·G represents the deep reinforcement learning model because the image clarity reaches the preset image clarity threshold C goal The extra reward obtained. Usually γ is a large positive number. Preferably, γ>>α>β. Those skilled in the art can determine α, β, γ and C by themselves. goal For example, α = 10, β = 0.1, γ = 100, C goal=0.8. It can be seen from the expression of the reward function that: when the value of C is larger, that is, the image clarity of the current image is higher, the value of the reward function is larger; when the value of |P| is smaller, that is, the absolute value of the above sum is smaller, the value of the reward function is larger; when the above image clarity reaches the preset image clarity threshold, the value of the reward function is larger. In other words, the above α·C can be regarded as a reward for image clarity, that is, a positive reward based on image clarity; the above -β·|P| can be regarded as a parameter penalty term, that is, in order to avoid jitter caused by frequent adjustment of acquisition parameters, a negative reward is given to the adjustment amplitude of the acquisition parameters; the above γ·G can be regarded as a goal achievement reward, that is, when the image clarity reaches the preset image clarity threshold, an additional positive reward is given.
[0062] In some embodiments, in step S100, in order to avoid the reward function giving too much punishment to actions with too large adjustment amplitude (such as adjusting focal length or adjusting aperture size), which may cause the agent (such as deep reinforcement learning model) to avoid some necessary large adjustments, thereby failing to achieve the ideal image clarity and only learning a suboptimal autofocus strategy, the present application designs a mechanism for dynamically adjusting weights for the reward function, so that when the agent approaches the preset image clarity threshold, the punishment for actions with too large adjustment amplitude is reduced, and the weight of the positive reward brought by image clarity is increased. The expression of the reward function is:
[0063] R=α·C-β·w(C,|P|)·|P|+γ·G;
[0064] Wherein, C represents the image clarity; |P| represents the sum of the absolute values of the above-mentioned changes; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0; w(C,|P|) represents a dynamic adjustment function, and the value of w(C,|P|) decreases when C and |P| gradually increase. The dynamic adjustment function is obtained based on the image clarity and the sum of the above-mentioned changes. The role of the above-mentioned dynamic adjustment function w(C) is to constrain the reward function of the intelligent agent (such as a deep reinforcement learning model) to avoid the occurrence of a local optimal situation, that is, to prevent the deep reinforcement learning model from only learning a suboptimal autofocus strategy.
[0065] It is understandable that when designing the above reward function, the most important thing is to consider the trade-offs between different factors and ensure that the reward function can correctly guide the agent (such as the deep reinforcement learning model) to learn the desired image clarity. If the deep reinforcement learning model needs to significantly adjust the above acquisition parameters to obtain the optimal image clarity, then the penalty term should be adjusted appropriately to ensure that the agent can effectively achieve the goal while improving the accuracy and response speed of focus.
[0066] In some embodiments, in step S100, the expression of w(C,|P|) is:
[0067]
[0068] Wherein, the above b and k are both preset hyperparameters. For example, when the acquisition parameters include focal length f and aperture size a, P = f+a; when the acquisition parameters include focal length f, P = f; When the acquisition parameters include aperture size a, P = a. Those skilled in the art can determine the specific values of b and k according to actual scenario requirements.
[0069] In some embodiments, in step S200, the image acquisition unit may be a camera or a webcam, etc. The specific composition of the image acquisition unit is not limited herein. The image acquisition unit may be disposed on a robot for fast movement.
[0070] In some embodiments, in step S200, a convolutional neural network can be used to obtain image clarity from the current image. The convolutional neural network here can extract features (such as edges, textures, shapes, associated features of the image, and abstract features, etc.) from the current image, and calculate the image clarity based on the extracted features. The above-mentioned convolutional neural network is mainly composed of convolution kernels, activation functions, pooling layers, etc. The above-mentioned convolutional neural network can also be obtained by pre-training the backbone network of the current large model (such as Dinov2). The above-mentioned Dinov2 is a computer vision self-supervisory model that can achieve the current highest level of performance in tasks such as depth estimation, semantic segmentation, and image similarity comparison. The convolutional neural network can be integrated into a deep reinforcement learning model. In other words, the deep reinforcement learning model can use the convolutional neural network to further extract rich feature information from the current image and learn complex nonlinear mapping relationships. The deep reinforcement learning model can also introduce an attention mechanism to enhance the attention to the target area, thereby making the deep reinforcement learning model have better generalization ability.
[0071] In some embodiments, the acquisition parameters of the image acquisition unit when acquiring the current image can be fused with the current image, and the fused result can be input into the above-mentioned convolutional neural network so that the convolutional neural network can extract the required features.
[0072] In some embodiments, in step S200, those skilled in the art may also adopt other existing technologies to obtain the image clarity of the current image according to actual needs. For example, the Brenner gradient method (an algorithm based on a gradient operator, which mainly uses the difference of pixel points to calculate edges), the Tenegrad gradient method (a gradient method used for image processing, which evaluates the clarity or edge information of the image by calculating the gradient changes of each pixel point in the image in the horizontal and vertical directions), the Laplace gradient method (a method for measuring the brightness change of an image, used to detect edges and contours in an image), the variance method, the energy gradient method, etc. may be used to obtain the image clarity of the current image.
[0073] In some embodiments, in step S200, computer vision technology may be used to select a focus target area from the current image, and then the image clarity and acquisition parameters of the focus target area may be calculated.
[0074] It should be noted that, in step S200, the specific process of obtaining the acquisition parameters when the image acquisition unit acquires the current image belongs to the prior art / common knowledge in the art, so it will not be described in detail here.
[0075] The following is a specific example to illustrate the process of the deep reinforcement learning model taking actions based on the current state and obtaining rewards. Assume that the state space currently observed by the deep reinforcement learning model is: the image clarity C = 0.6 of the current image (assuming that the full score of C is 1.0); the current focal length f = 50mm; the current aperture size a = 2.8; at the same time, assume that the autofocus strategy predicted by the deep reinforcement learning model is to increase the focal length (such as Δf = 5mm) and reduce the aperture size (such as Δa = 0.2). Afterwards, the image acquisition unit executes the above autofocus strategy, that is, updates the focal length of the image acquisition unit: f′ = f + Δf = 50 + 5 = 55mm, and updates the aperture size of the image acquisition unit: a′ = a-Δa = 2.8-0.2 = 2.6. Afterwards, the reward function after executing the current action is calculated, where the image clarity of the current image recaptured after executing the current action is C′, and the adjustment range of the acquisition parameters (such as |P| above) is: |f′-f|+|a′-a|=|55-50|+|2.6-2.8|=5+0.2=5.2. If the image clarity of the recaptured current image is C′=0.85, C′ exceeds the preset image clarity threshold (assuming that the preset image clarity threshold Cgoal=0.8), that is, the reward function obtains the goal achievement reward γ·G. Afterwards, a new reward function is calculated.
[0076] It should be noted that the deep reinforcement learning model in step S300 is obtained through training. The specific training process of the deep reinforcement learning model belongs to the prior art in this field, so it will not be described here.
[0077] After step S300, the image acquisition unit may perform auto-focusing according to the optimal auto-focusing strategy.
[0078] It can be seen that in some embodiments, the auto-focus method, by constructing a deep reinforcement learning model, uses the image clarity and camera parameters (such as the above-mentioned acquisition parameters) of the current image as the state space, adjusts the focal length and aperture size of the image acquisition unit as the action space, and optimizes the focus strategy by defining a reward function and training a deep reinforcement learning model, thereby improving the performance and robustness of the auto-focus. In actual applications, the image acquisition unit automatically adopts the optimal focus strategy according to the current image data to obtain the best image clarity.
[0079] It can be seen that in some embodiments, the deep reinforcement learning model of the present autofocus method can select the optimal action according to the current state during the training process, and provide feedback and adjust the action space according to the reward function to gradually optimize the autofocus strategy (state-action strategy). The present autofocus method combines the decision-making process of reinforcement learning (such as adjusting the action space according to the reward function) and the visual feedback mechanism, and can achieve adaptive focusing in continuous interaction. At the same time, the present autofocus method has good robustness and practicality. The above-mentioned visual feedback mechanism refers to the learning and extraction of the intrinsic feature information of the image data (such as the above-mentioned current image) and the acquisition parameters through the convolutional neural network of this article, and uses it as feedback in the action space.
[0080] It can be seen that in some embodiments, the deep reinforcement learning model of the present autofocus method can output the optimal autofocus strategy (such as the optimal focusing action, etc.) by obtaining the state information of the current image, thereby achieving autofocus.
[0081] The above is some explanation about the auto focus method. Figure 2 In some embodiments of the present application, an automatic focusing device is also disclosed, including:
[0082] The model building unit 100 is configured to determine the state space, action space and reward function of the deep reinforcement learning model;
[0083] The clarity calculation unit 200 is configured to obtain the image clarity of the current image and the acquisition parameters when the image acquisition unit acquires the current image;
[0084] The state space includes image clarity and acquisition parameters; the action space includes acquisition parameters; the acquisition parameters include focal length and / or aperture size; the reward function is a function obtained based on the change in the acquisition parameters between two consecutive acquisitions of the current image and the image clarity;
[0085] The optimal strategy output unit 300 is configured to output the optimal autofocus strategy based on the image clarity and acquisition parameters by the deep reinforcement learning model;
[0086] The image acquisition unit 400 is configured to perform auto-focusing according to an optimal auto-focusing strategy.
[0087] In some embodiments, the reward function is expressed as:
[0088] R = α·C-β·|P|+γ·G;
[0089] Among them, C represents image clarity; |P| represents the sum of the absolute values of the above-mentioned changes; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0.
[0090] In some embodiments, the reward function is expressed as:
[0091] R=α·C-β·w(C,|P|)·|P|+γ·G;
[0092] Among them, C represents image clarity; |P| represents the sum of the absolute values of the above-mentioned changes; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0; w(C,|P|) represents a dynamic adjustment function, and the value of w(C,|P|) decreases when C and |P| gradually increase.
[0093] It should be noted that the specific process and corresponding technical effects of focusing of the present autofocus device are basically the same as the specific process and corresponding technical effects of the above-mentioned autofocus method, so they will not be described in detail here.
[0094] The above is some description about the auto-focus device. In some embodiments of the present application, a computer-readable storage medium is also disclosed, including a program, which can be executed by a processor to implement a method as in any embodiment of the present invention.
[0095] In some embodiments of the present application, a computer program product is also disclosed, including a computer program and / or instructions, and when the computer program and / or instructions are executed by a processor, a method as described in any embodiment of the present invention is implemented.
[0096] This document is described with reference to various exemplary embodiments. However, those skilled in the art will recognize that changes and modifications may be made to the exemplary embodiments without departing from the scope of this document. For example, various operating steps and components for performing the operating steps may be implemented in different ways (e.g., one or more steps may be deleted, modified, or incorporated into other steps) depending on the specific application or considering any number of cost functions associated with the operation of the system.
[0097] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. In addition, as understood by those skilled in the art, the principles of this article can be reflected in a computer program product on a computer-readable storage medium, which is pre-installed with a computer-readable program code. Any tangible, non-temporary computer-readable storage medium can be used, including magnetic storage devices (hard disks, floppy disks, etc.), optical storage devices (CD to ROM, DVD, Blu Ray disks, etc.), flash memory and / or the like. These computer program instructions can be loaded onto a general-purpose computer, a special-purpose computer or other programmable data processing device to form a machine, so that these instructions executed on a computer or other programmable data processing device can generate a device that implements a specified function. These computer program instructions can also be stored in a computer-readable memory, which can instruct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory can form a manufactured product, including an implementation device that implements a specified function. Computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operating steps are performed on a computer or other programmable device to generate a computer-implemented process, so that the instructions executed on a computer or other programmable device can provide steps for implementing a specified function.
[0098] Although the principles of this invention have been shown in various embodiments, many modifications of structures, arrangements, proportions, elements, materials and components particularly suitable for specific environments and operational requirements can be used without departing from the principles and scope of this invention. The above modifications and other changes or amendments will be included in the scope of this invention.
[0099] The foregoing specific description has been described with reference to various embodiments. However, those skilled in the art will recognize that various modifications and changes can be made without departing from the scope of the present disclosure. Therefore, the consideration of the present disclosure will be illustrative rather than restrictive, and all these modifications will be included in its scope. Similarly, the advantages, other advantages and solutions to the problems of various embodiments have been described above. However, the benefits, advantages, solutions to the problems and any elements that can produce these, or make them more clear, should not be interpreted as critical, necessary or necessary. The term "include" and any other variants used in this article are all non-exclusive inclusions, so that the process, method, article or device including the list of elements not only includes these elements, but also includes other elements that are not explicitly listed or do not belong to the process, method, system, article or device. In addition, the term "coupled" and any other variants used in this article refer to physical connections, electrical connections, magnetic connections, optical connections, communication connections, functional connections and / or any other connections.
[0100] Those skilled in the art will appreciate that many changes may be made to the details of the above-described embodiments without departing from the basic principles of the invention. Therefore, the scope of the present invention should be determined solely by the claims.
Claims
1. An automatic focusing method, characterized in that: include: Determine the state space, action space, and reward function of the deep reinforcement learning model; Acquire acquisition parameters when the image acquisition unit acquires the current image and the image clarity of the current image; wherein the state space includes the image clarity and the acquisition parameters; the action space includes the acquisition parameters; the acquisition parameters include focal length and / or aperture size; the reward function is a function obtained according to the change amount of the acquisition parameters in two adjacent acquisitions of the current image and the image clarity; The deep reinforcement learning model outputs an optimal autofocus strategy based on the image clarity and the acquisition parameters.
2. The method according to claim 1, characterized in that The expression of the reward function is: R = α·C-β·|P|; Among them, C represents the image clarity; P represents the above-mentioned change amount, |P| represents the sum of the absolute values of the above-mentioned change amounts; α represents the first weight coefficient, α>0; β represents the second weight coefficient, β>0.
3. The method according to claim 1, characterized in that The expression of the reward function is: R = α·C-β·|P|+γ·G; Among them, C represents the image clarity; P represents the above-mentioned change, |P| represents the sum of the absolute values of the above-mentioned change; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0.
4. The method according to claim 1, characterized in that The expression of the reward function is: R=α·C-β·w(C,|P|)·|P|+γ·G; Among them, C represents the image clarity; P represents the above-mentioned change amount, |P| represents the sum of the absolute values of the above-mentioned change amounts; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0; w(C,|P|) represents a dynamic adjustment function, and the value of w(C,|P|) decreases when the C and the |P| increase.
5. The method according to claim 4, characterized in that The expression of w(C,|P|) is: Among them, the above b and k are both preset hyperparameters.
6. An automatic focusing device, characterized in that: include: A model building unit, configured to determine a state space, an action space, and a reward function of a deep reinforcement learning model; The clarity calculation unit is configured to obtain the image clarity of the current image and the acquisition parameters when the image acquisition unit acquires the current image; wherein the state space includes the image clarity and the acquisition parameters; the action space includes the acquisition parameters; the acquisition parameters include focal length and / or aperture size; the reward function is a function obtained according to the change amount of the acquisition parameters in two adjacent acquisitions of the current image and the image clarity; An optimal strategy output unit, configured for the deep reinforcement learning model to output an optimal autofocus strategy based on the image clarity and the acquisition parameters; The image acquisition unit is configured to perform auto-focusing according to the optimal auto-focusing strategy.
7. The automatic focusing device according to claim 6, wherein: The expression of the reward function is: R = α·C-β·|P|+γ·G; Among them, C represents the image clarity; P represents the above-mentioned change, |P| represents the sum of the absolute values of the above-mentioned change; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0.
8. The automatic focusing device according to claim 6, wherein: The expression of the reward function is: R=α·C-β·w(C,|P|)·|P|+γ·G; Among them, C represents the image clarity; P represents the above-mentioned change amount, |P| represents the sum of the absolute values of the above-mentioned change amounts; G is equal to 1 or 0, 1 represents that the image clarity reaches the preset image clarity threshold, and 0 represents that the image clarity does not reach the preset image clarity threshold; α represents the first weight coefficient; β represents the second weight coefficient; γ represents the third weight coefficient, γ>α>β>0; w(C,|P|) represents a dynamic adjustment function, and the value of w(C,|P|) decreases when the C and the |P| increase.
9. A computer-readable storage medium, characterized in that: The method comprises a program which can be executed by a processor to implement the method according to any one of claims 1 to 5.
10. A computer program product comprising a computer program and / or instructions, characterized in that: When the computer program and / or the instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.