We're having some trouble with setting focus on the OAK-FFC IMX582 sensor that works consistently across all of the boards we have. These cameras are flashed with a pipeline that uses a script to crop the feed around a detected face. Our current focus logic sets the lens position in the script based on the size of the detected face in the image (similar to the depth-driven focus demo, but using bounding box size instead of depth as we are working with a single sensor). This seems to work for most sensors, however, there are a small number of sensors produce a blurry at the calculated lens position. We can adjust the initial lens position in our equation for these cameras to improve focus, however it would be impractical for us to have to re-flash these cameras until we find the right initial lens position for each camera.
We've tried using autofocus as well, however it seems that once the sensor settles on a lens position, it will not adjust if the person moves closer/further from the camera.
We've also tried triggering the autofocus from the script, but that doesn't seem to do anything. Another thing we tried was to set the auto focus region in the script to be the bounding box of the detected face, but this seems to continually trigger the autofocus, which causes the camera to constantly adjust the lens position and never be in focus.
Are there any suggestions or recommendations on how we can handle focus better on these sensors where the best lens position may vary between sensors?