Abstract
This paper introduces a Deep Reinforcement Learning (DRL) framework designed to eliminate "focus hunting"—the detrimental back-and-forth jitter of a camera lens—during the autofocus process. By training an agent with expert trajectories and shifting the model's objective from predicting absolute positions to relative movements, the researchers achieved faster, more stable focusing that significantly outperforms current state-of-the-art deep learning methods. The approach leverages an Actor-Critic architecture regularized by imitation loss to ensure efficient convergence and high-quality sequential decision-making.
Introduction
Autofocus (AF) is a fundamental challenge in computer vision, requiring a delicate balance between speed and stability. Traditional search-based methods are accurate but inherently slow because they must "hunt" past the point of peak sharpness to confirm the optimal focus. Modern phase-detection (dual-pixel) methods offer increased speed but remain sensitive to noise.
Recent deep learning approaches attempt to predict the in-focus position in a single step. However, when deployed in real-world multi-step scenarios, these models often suffer from focus hunting (FH). Because they treat each step as an isolated event, they ignore the sequential history of the lens, leading to oscillations where the lens moves back and forth. This results in a jittery viewfinder experience and increased latency.
Methodology
The authors frame autofocus as a sequential decision-making problem using an Actor-Critic Deep Reinforcement Learning framework. This perspective allows the system to consider the future impact of its current move, learning that a slightly smaller move now might prevent a massive overshoot later.
Actor-Critic Framework and Regularization
DRL is often difficult to train from scratch due to low sample efficiency. To address this, the authors generated an offline dataset of 6 million "expert" trajectories—ideal paths that reach focus without hunting. They utilized an imitation loss to regularize the actor network, guiding the AI to explore while staying close to high-quality examples.
Relative Movement Prediction
A key innovation is the shift in labels. Instead of asking the network to predict the final focal index (absolute position), the model predicts how much the lens should move from its current position (relative movement). This better reflects the physical relationship between defocus blur and lens displacement, improving exact prediction accuracy by nearly 9% in single-step tests.
Reward Function
The agent is rewarded for reducing the distance to the ground-truth focus and receives a heavy penalty for "hunting" moves—defined as changing direction away from the target. Both the actor and critic networks utilize a lightweight MobileNet-V2 backbone, ensuring the solution is viable for mobile hardware.
Experimental Setup
The models were trained and evaluated using a benchmark public AF dataset featuring 51 scenes captured at 49 different focal depths with Google Pixel 3 dual-pixel sensors. To stabilize training, the authors supplemented this with a massive synthetic dataset of 6,000,000 expert trajectories based on optimal lens movement logic.
Key Results
The proposed DRL method was compared against several baselines, including previous state-of-the-art (SOTA) deep learning models.
- Accuracy: In a 2-step focusing scenario, the DRL model achieved 43.9% exact accuracy, a significant jump from the 27.5% achieved by the previous SOTA.
- Stability: The focus hunting rate was slashed. In 4-step trajectories, the DRL approach reduced hunting occurrences by 18% compared to standard deep learning policies.
- Efficiency: The model reaches higher sharpness in fewer steps, averaging approximately 1.8 steps to stop compared to over 2.2 steps for baselines.
Conclusion and Future Work
By treating autofocus as a control problem rather than a simple vision task, this research demonstrates that DRL can provide the temporal consistency required for professional-grade AF. While the method significantly reduces hunting, limitations remain in textureless scenes or with purely horizontal textures due to the physical orientation of current dual-pixel sensors. Future work may involve using larger image patches or auxiliary depth estimation to handle complex scenes with multiple depths of field.
Summary updated