Thanks for reaching out.
In CameraX (and the underlying Camera2 API), this method is generally treated as an active trigger—it forces the camera to initiate a new AF scan to find the best focus right now, which causes the "breathing" effect as the lens hunts for focus repeatedly.
To achieve a "continuous focus on a zone" similar to native camera apps, you usually need a combination of your custom object tracking and strategic use of CameraX APIs.
Here are some recommendations:
1. For a Static Zone (preventing timeout) If the zone doesn't move much, ensure you call startFocusAndMetering only once, but disable the timeout. By default, CameraX resets focus to the center after 5 seconds.
Once this is set, the camera should use its own internal Continuous Auto-Focus (CAF) to keep that specific region sharp without further calls from your app.
2. For a Moving Zone (Object Tracking) CameraX does not currently have built-in high-level object tracking that automatically updates AF regions without triggering new scans. Native camera apps often utilize specialized vendor hardware or complex ML pipelines to achieve smooth tracking.
Since you already have image analysis determining the zone, you can implement tracking, but you must avoid calling startFocusAndMetering on every single frame.
Implement a threshold: Only call startFocusAndMetering (with the new coordinates) if your tracked object has moved significantly (e.g., more than X% of the screen width). Small movements should be ignored to let the camera's internal CAF handle minor adjustments.
Debounce calls: Ensure you don't trigger a new focus action while one is already in progress or explicitly recently finished.
Hopefully, this helps you find the right balance for your application.