I have a Ubuntu server setup with an inexpensive (well actually it was free) generic USB 2 “eyeball” camera setup as a security door camera, using the motion image capture program.
The system works great except for one thing, the camera exposure.
Here is a picture of what it’s monitoring
This is how I obtained the image:
root@beachserver:~# service motion stop
root@beachserver:~# v4l2-ctl -d /dev/video0 --set-ctrl=exposure_absolute=100
root@beachserver:~# fswebcam -d /dev/video0 -F 100 -r 640x480 image.jpg
— Opening /dev/video0…
Trying source module v4l2…
No input was specified, using the first.
— Capturing 100 frames…
Captured 100 frames in 3.38 seconds. (29 fps)
— Processing captured image…
Writing JPEG image to ‘image.jpg’.
root@beachserver:~# service motion start
Here is how the camera is currently setup
root@beachserver:~# v4l2-ctl -d /dev/video0 --list-ctrls
brightness 0x00980900 (int) : min=-127 max=127 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=127 step=1 default=64 value=64
saturation 0x00980902 (int) : min=0 max=255 step=1 default=64 value=64
hue 0x00980903 (int) : min=-16000 max=16000 step=1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool) : default=1 value=0
gamma 0x00980910 (int) : min=16 max=500 step=1 default=100 value=100
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=5200 value=6500
sharpness 0x0098091b (int) : min=0 max=10 step=1 default=6 value=6
exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=1
exposure_absolute 0x009a0902 (int) : min=1 max=2500 step=1 default=625 value=100
exposure_auto_priority 0x009a0903 (bool) : default=0 value=1
What I have found with trial an error experience is that if I try using the internal light meter/automatic exposure logic in the camera the camera sets the shutter speed way too slow and as a result the picture comes out completely overexposed.
If the camera is used to shoot an interior shot then it is basically OK if I set the camera on automatic.
The camera is shooting through a window and the camera is about a foot back from the window on a shelf. I can set the camera on the window sill right next to the glass so that more of the field of view is taken up by the outside but that does not help the light meter it is still overexposed.
Obviously this is a cheap “skype type” camera that is intended to sit on a desk 2 feet from the operator and shoot their face, and I’m pushing it way beyond what it’s designers intended for it. But, this is a security application it is not necessary to be able to see the individual legs of the spiders walking around on each blade of grass out in the yard. And if your answer is to buy better hardware then you don’t really get the point of photography software I think. I already know that is an answer and from what I’ve read lots of people who have dropped $100 on a “better” camera end up with the same thing I have now since the usb “web cameras” out there just vary a little bit in their suckitude.
The problem with controlling the camera shutter speed/exposure manually in this setup is that picture quality suffers. From around 9:30am to about 6:00pm in the summer the optimal exposure time is 20 maybe 20, that is cranked way way down. At night optimal exposure is 2500 the max the camera will go and even then you won’t see anything unless someone is standing at the door. In the winter with the sun’s rays more of an angle optimal exposure is around 100 during the day. Of course if it’s raining or cloudy or whatever, exposure time has to be increased.
Not only is the exposure bad the gamma is also terrible in that if you let the camera control those parameters the picture comes out blue. That’s why I hard coded those settings too.
Since I can’t depend on the camera’s automatic circuitry, and I can’t constantly be reconfiguring the camera manually, has anyone written software that can automatically set up a camera exposure/gamma/brightness based on the video feed from the camera?