Auto Focus on Web Cams with Linux
Posted: Thu Feb 17, 2022 1:50 am
I thought I would let others know, who use Web Cams with ZoneMinder (probably not many).
I have a Logitech C922 Webcam sitting on my window sill, looking outside.
I constantly had issues whereby it would focus on the flyscreen, rather than the 'outside'.
Setting the auto focus off in ZoneMinder configuration of the camera didn't work because ZoneMinder seemed to be unable to control the camera for some reason. (diagnostics in logs).
I found that I needed to create a script, which I run at system start up and USB connect
The script, in my case, is named 'video0.start'
I have a Logitech C922 Webcam sitting on my window sill, looking outside.
I constantly had issues whereby it would focus on the flyscreen, rather than the 'outside'.
Setting the auto focus off in ZoneMinder configuration of the camera didn't work because ZoneMinder seemed to be unable to control the camera for some reason. (diagnostics in logs).
I found that I needed to create a script, which I run at system start up and USB connect
The script, in my case, is named 'video0.start'
Code: Select all
DEV_VIDEO=$(basename $0)
# Discard '.start' suffix and add /dev/ prefix
DEV_VIDEO="/dev/${DEV_VIDEO%%.start}"
if [ -w "${DEV_VIDEO}" ]
then
logger "Setting Auto Focus off for ${DEV_VIDEO} - Logitech C922 WebCam"
v4l2-ctl -d ${DEV_VIDEO} --set-ctrl=focus_absolute=0
v4l2-ctl -d ${DEV_VIDEO} --set-ctrl=focus_auto=0
else
logger "${DEV_VIDEO} does not exist or is not writable - is Logitech C922 WebCam plugged in?"
fi