|
From: Jay S. <js...@aq...> - 2021-05-31 16:45:21
|
(My apologies for not doing a very thorough search of the list archives; the search interface is _really_ cumbersome! I did check recent hits, though.) I have a Raspberry Pi 4 with a couple of cheap outdoor USB security cameras (this model: https://smile.amazon.com/gp/product/B07C2RL8PB/) connected to it (with active USB repeater cables because of the distance) so we can watch the wildlife and outdoor cats in our yard. Out of the box, the cameras did their own adequate brightnesss control, and I got reasonable (if not great) pictures in all lighting conditions. At some point, they both simultaneously lost that ability -- they both just stayed at constant gain and brightness, resulting in illegible images most of the time. This happened to be right after a power outage, but I don't see how that could have been the cause, given that I'd been randomly plugging and unplugging them from time to time to reroute cables with no ill effects, and that both had the same thing happen at once. I *had* been experimenting a bit with v4l2-ctl, so it's possible I somehow got the cameras in a state I didn't know how to get them out of, but I'd been avoiding anything about automatic brightness adjustment (since it was working) and I didn't notice the change in behavior until after the power outage. Once I noticed the cameras were no longer doing their own brightness adjustment, I experimented more with manually adjusting their settings, and discovered I could get much better quality images by tweaking settings manually. But of course for best quality I had to do that more or less constantly in real time as lighting conditions changed. (I also tried without success to get the cameras to do their own automatic brightness adjustment again.) One oddity I noticed was that the image brightness did not increase monotonically with increases in "exposure_absolute". (I *think* the same thing was true of increases in "brightness", but I don't remember for sure. Most of the time, increasing the value of "exposure_absolute" by 1 would result in a slight increase in the brightness of the image, but here and there there were places where increasing the value of "exposure_absolute" by 1 would noticeably *decrease* the brightness of the image. (And those seemed to be consistent spots along the range.) I tried turning auto_brightness on in the Motion config (and tried the various methods of adjusting it), and what happened would be that I would get videos that would start to brighten or dim and then very quickly would start flashing dramatically from way overexposed to super-dim. It seems like what would happen if both Motion and the camera itself were trying to adjust brightness automatically, but if so that's the only way in months I've gotten the cameras to do that, and it's not helpful. :-) If Motion were trying to slowly increase or decrease the brightness and got to one of those discontinuous spots, I'd expect to see flickering, but not nearly so dramatic changes in exposure. For now I've sort-of worked around the problem by setting up cron jobs to set good-enough-for-most-days parameters in the morning and the evening, but of course that's crummy on overcast or very bright days and the times should really be adjusted by season. (If I remember to check, I tweak things manually.) Also, the cameras turn on their IR illumination based on their own idea of lighting conditions, not based on time, so I can't reliably set appropriate parameters for whether the IR LEDs are on or not. (I've thought about having a cron job check the average brightness of the last few periodic snapshots and try to adjust camera settings as appropriate, but before I put that much effort in for uncertain results, I thought I'd see if I could get some advice about getting the camera or Motion to do it for me.) Anyway, I guess what I'm asking for is: * Does anybody have an idea what's going on here, and why the cameras stopped doing their own automatic exposure adjustment? * Can somebody explain in detail how auto_brightness is supposed to work and how it interacts with vid_control_params? (The documentation is a bit sketchy.) * Is there a good overview of how various configuration settings (especially exposure_auto and the settings it interacts with or conflicts with) work on common USB cameras and how to use them effectively that I could be pointed at? I'm running Motion 4.3.2 on Raspbian Buster. While both cameras are USB 2 devices, I've got one of them in a USB 3 port so they don't compete on the same bus. I'm including below the current settings for one of the cameras, and in case it's of any interest to anybody I'm including the cron job I'm currently using. I'm using v4l2_palette 8 (V4L2_PIX_FMT_MJPEG -- took me a while to figure out the default wasn't working) and a framerate of 9. Ideas appreciated! Thanks, Jay $ v4l2-ctl -d /dev/video0 -l brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0 contrast 0x00980901 (int) : min=0 max=64 step=1 default=32 value=32 saturation 0x00980902 (int) : min=0 max=128 step=1 default=60 value=64 hue 0x00980903 (int) : min=-40 max=40 step=1 default=0 value=0 white_balance_temperature_auto 0x0098090c (bool) : default=1 value=0 gamma 0x00980910 (int) : min=72 max=500 step=1 default=100 value=100 gain 0x00980913 (int) : min=0 max=100 step=1 default=0 value=0 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=4600 value=4600 sharpness 0x0098091b (int) : min=0 max=6 step=1 default=2 value=2 backlight_compensation 0x0098091c (int) : min=0 max=2 step=1 default=1 value=1 exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=1 exposure_absolute 0x009a0902 (int) : min=1 max=5000 step=1 default=157 value=20 exposure_auto_priority 0x009a0903 (bool) : default=0 value=0 $ cat /etc/cron.d/motiongain # at 07:15 each morning: # gain=0 # exposure_absolute=15 # saturation=64 15 7 * * * root v4l2-ctl -d /dev/video0 -c gain=0 15 7 * * * root v4l2-ctl -d /dev/video0 -c exposure_absolute=15 15 7 * * * root v4l2-ctl -d /dev/video0 -c saturation=64 15 7 * * * root v4l2-ctl -d /dev/video2 -c gain=0 15 7 * * * root v4l2-ctl -d /dev/video2 -c exposure_absolute=15 15 7 * * * root v4l2-ctl -d /dev/video2 -c saturation=64 # at 19:31 each evening (front) or 19:01 (back) # gain=100 # exposure_absolute=300 (back) or 415 (front; LEDs are further from ground) # saturation=0 01 19 * * * root v4l2-ctl -d /dev/video0 -c gain=100 01 19 * * * root v4l2-ctl -d /dev/video0 -c exposure_absolute=300 01 19 * * * root v4l2-ctl -d /dev/video0 -c saturation=0 31 19 * * * root v4l2-ctl -d /dev/video2 -c gain=100 31 19 * * * root v4l2-ctl -d /dev/video2 -c exposure_absolute=350 31 19 * * * root v4l2-ctl -d /dev/video2 -c saturation=0 |