Auto Focus on Web Cams with Linux

Current Development version likely to have breaking changes
Post Reply
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Auto Focus on Web Cams with Linux

Post by lyallp »

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'

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
...Lyall
User avatar
iconnor
Posts: 2949
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Auto Focus on Web Cams with Linux

Post by iconnor »

I think we only control Contrast, Brightness, Saturation.

Tons more v4l controls that we COULD set. In master I added some code to at least list them in the web UI.

A lot of work to be done here. I thought webcams might be kinda done, but I think there has been a revival with pi's and work from home needing better quality.
Post Reply