Center Focus Depth Of Field Add-On
Videotutorial: https://youtu.be/3LwCu9MWUyQ
Once you've installed and enabled the add-on (or the extension), you can enable or disable its options in the dedicated panel inside the Camera's Object Data tab.
Simply enable the automatic option, and the Focus Distance field will always stay synchronized with whatever is in front of the active camera, in real time.
A Smooth Transition option is also available, allowing the Focus Distance parameter to change more gradually, helping to create less abrupt transitions.