Depends on the driver and/or video backend used by cv::VideoCapture.
You can try setting the focus directly with v4l2-ctl: https://www.christitus.com/logitech-c920-linux-driver/
There are two values we need to change to get the best performance from our webcam.
Here is the command syntax:
v4l2-ctl -d /dev/video6 --set-ctrl=exposure_auto=1
v4l2-ctl -d /dev/video6 --set-ctrl=focus_auto=0
ref
https://stackoverflow.com/questions/58207901/set-webcamera-focus-with-opencv-in-raspberry-pi