LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 06-19-2019, 12:44 AM   #1
tmittelstaedt
LQ Newbie
 
Registered: Jun 2019
Posts: 11

Rep: Reputation: Disabled
Webcam exposure issues - white screen


I have a Ubuntu 18 desktop system I am using (among other things) as a front door camera DVR

The camera I am using is a cheap USB 2.0 device made out of plastic that I forget where it came from (probably out of a cereal box or something) it shows up as the following:

root@beachserver:~# lsusb
Bus 001 Device 002: ID 1e4e:0102 Cubeternet GL-UPC822 UVC WebCam
root@beachserver:~#

In googling that I come up with "Etron Technology, Inc." as the actual chip maker (Cubeternet is, of course, nothing more than a Chinese company that buys camera chips and sticks them in a case)
Code:
 
root@beachserver:~# v4l2-ctl -D -d /dev/video0
Driver Info (not using libv4l2):
        Driver name   : uvcvideo
        Card type     : USB2.0 Camera: USB2.0 Camera
        Bus info      : usb-0000:00:1a.7-1
        Driver version: 4.18.20
        Capabilities  : 0x84A00001
                Video Capture
                Metadata Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps   : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
root@beachserver:~#

root@beachserver:~# v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 352x288
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 176x144
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 160x120
                        Interval: Discrete 0.033s (30.000 fps)

root@beachserver:~#
In short, I have a "generic USB 2.0 camera" that can do 640x480 at 30fps

I am using this with the "motion" program to watch the door. That program works quite well.

The problem I'm having is with the auto-exposure of the camera. If I just leave it set to auto then during the day the picture is way overexposed to the point that the screen is basically just white.

The auto exposure on the camera sets it to around 625. If I run the command:

v4l2-ctl -d /dev/video0 --set-ctrl=exposure_absolute=20

Then the picture during the day is correct. The problem though is that at dusk (between 7:30-9:30 roughly) and dawn (430-630am roughly) the picture is now underexposed - setting it to 2500 then sets the exposure properly and I get a decent picture.

Of course I could do a cron job to set this but is there any software out there which would do this automatically? Or is there a better camera. I've done much googling on this and I found tons of complaints about this with all makes of cameras plus a ton of corn-pone solutions (like taking a bunch of pictures really fast) that purport to "fix" the problem. My conclusion is 99% of the camera chips out there are garbage and only really work properly when shooting indoors. Does anyone who has had some experience with this have anything to add?
 
Old 06-21-2019, 02:23 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
You could check the time once an hour. And reset the exposure however you wish.

Simple example:
Code:
while :; do
    time=$(date +"%H")

    if [[ "$time -gt 4 && "$time" -lt 20 ]]; then
        v4l2-ctl -d /dev/video0 --set-ctrl=exposure_absolute=20
    else
        v4l2-ctl -d /dev/video0 --set-ctrl=exposure_absolute=2500
    fi
    sleep 3600
done
 
Old 06-22-2019, 10:48 AM   #3
tmittelstaedt
LQ Newbie
 
Registered: Jun 2019
Posts: 11

Original Poster
Rep: Reputation: Disabled
The problem with this is that the time of year also dictates the exposure level needed - during the winter it gets darker earlier in the evening and lighter later in the morning. And of course, if it's raining and darker because of clouds or whatever then the exposure needs to be changed. That's why you really need to determine this setting programmatically.

The root of the problem is that this camera's internal automatic exposure level setting is broken. In bright light it should set the exposure level down to 20 or so in dim light it should set the exposure up near 2500. The camera can take a correct picture in either light levels IF the exposure is set properly so that part of the camera chip isn't faulty. What's faulty is that the exposure level the camera is using in dim light is maybe not above 1500 while the exposure level in bright light is not below 600.

I have used $5000 security cameras that can focus on a blade of grass a quarter mile away and they don't have problems like this. So I know the digital camera industry knows how to manufacture cameras that have proper light sensors and can set exposure properly. What most people don't understand is that the most expensive part of the camera is the optics - in a super expensive camera (like the military-grade stuff in the DoD's spy satellites) you are dealing with glass optics that are ground absolutely perfectly. The actual CCD in the camera isn't the expensive part.

In the cheap desktop cams, they have tiny lenses because those are cheaper to grind. Those lenses are also not perfectly ground either. As a result they cannot focus sharply on something far away. That part of the cost-benefit tradeoff I don't mind. What I don't know, though, is if it's worth digging through a bucket of old cameras down at the computer junk store and buying a handful then trying them all out. If they are all like this no matter who the manufacturer then I'll abandon the effort and just set the exposure at a compromise that will give an overexposed but still resolvable picture in sunny weather and an underexposed but still resolvable picture in cloudy weather. I don't need high resolution in a security camera that's going to be focused on something 4 feet away.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
turn off auto exposure on a uvc webcam zoran119 Slackware 7 10-22-2009 06:27 AM
moved: for the exposure it deserves -giggle titanium_geek General 5 09-18-2004 01:29 PM
Webcam auto exposure sevi Linux - Newbie 0 09-11-2004 03:47 PM
Bangkok ICT expo, lots of Linux exposure slackist General 1 08-20-2004 11:53 AM
USB Flash drive stopped working after Windows exposure oot Linux - General 1 03-31-2004 09:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration