Time-dependent webcam control
For taking still images with a webcam looking outside my sleeping room window, I’ve attached a Logitech C510 to my RasPi. At first, I used the fswebcam program to acquire still images, which can be easily configured using a fswebcam.conf file as follows:
quiet device v4l2:/dev/video0 input 0 skip 50 palette MJPEG background resolution 1600x1200 set "White Balance Temperature, Auto"=1 set "Exposure, Auto"=3 set "Backlight Compensation"=1 #set "sharpness"=100 #set "gain"=0% #set "exposure"=1 #set "brightness"=35% #set "contrast"=10% #set "saturation"=60 #set hue=10 #top-banner #font /usr/share/fonts/truetype/msttcorefonts/arial.ttf title "RasPi-Cam" timestamp "%d-%m-%Y %H:%M:%S (%Z)" jpeg 50 save /var/www/data/snaps/snap.jpg
Some settings required careful tweaking, since most webcams are optimized for indoor use. Although the settings above resulted in pictures of reasonable quality, I noticed that they were pretty much overexposed on bright sunny days. And they were far too dark at night. It turned out that the auto exposure function of my webcam is unable to deal with changing light conditions.
Therefore I did some research on how to change the settings dynamically, depending on time of day. It turned out to be a simple task using some python scripting.