import opencv
import opencv.highgui
import time
import commands
def get_image():
image = opencv.highgui.cvQueryFrame(camera)
return opencv.adaptors.Ipl2PIL(image)
camera = opencv.highgui.cvCreateCameraCapture(-1)
while 1:
image = get_image()
image.thumbnail((32, 24, ))
image = tuple(ord(i) for i in image.tostring())
x = int((int((max(image) / 256.0) * 10) + 1) ** 0.5 / 3 * 10)
cmd = ("sudo su -c 'echo " + str(x) +
" > /sys/devices/virtual/backlight/acpi_video0/brightness'")
status, output = commands.getstatusoutput(cmd)
assert status is 0
Two problems with this approach: The display brightness, at least with my webcam, never goes lower than four, because the camera doesn't work well in darkness, and it might skip a bit between four and five. Anyway,
This is how to use it:
sudo apt-get install python-opencv
Save this script somewhere, say ~/test.py
Run it via python test.py
Instead of the average brightness, I'm now getting the maximum brightness of a small tumbnail (this is to avoid dead pixel problems and make it faster). And at least with my combination of lights and camera, it works rather well!
Instructions on installing and how to use are well documented in the website and, depending on your hardware and monitor you can feel your eyes like "refreshed" by the nice effect which is achieved by RedShift.
I also made a C tool for that, using OpenCV. You can find it at https://launchpad.net/brightness (you have to compile it by your own). I hope it will help you.
It uses fswebcam to take pictures, can be configured with systemd to start automatically and detects whether the laptop is discharging (then it kicks in).
I've improved on my previous attempt (python):
Two problems with this approach: The display brightness, at least with my webcam, never goes lower than four, because the camera doesn't work well in darkness, and it might skip a bit between four and five. Anyway,
This is how to use it:
sudo apt-get install python-opencv
~/test.py
python test.py
Instead of the average brightness, I'm now getting the maximum brightness of a small tumbnail (this is to avoid dead pixel problems and make it faster). And at least with my combination of lights and camera, it works rather well!
Give it a try (:
Take a look into the RedShift project, which changes the screen temperature based on your geographic location as F.Lux was formerly doing.
http://jonls.dk/redshift/
Instructions on installing and how to use are well documented in the website and, depending on your hardware and monitor you can feel your eyes like "refreshed" by the nice effect which is achieved by RedShift.
To add the PPA, press Ctrl+Alt+T on keyboard to open the terminal. When it opens, run the command below:
Then install WildGuppy via:
Works on Ubuntu 14.04, Ubuntu 13.10, Ubuntu 13.04, Ubuntu 12.10 and Ubuntu 12.04.
Make WildGuppy running at startup:
Run command to edit the config file.
Type in your password when prompted. Note that terminal will not display your password when typing, just type in mind and hit enter.
When the file opens, paste below content and save it.
I also made a C tool for that, using OpenCV. You can find it at https://launchpad.net/brightness (you have to compile it by your own). I hope it will help you.
You may use https://github.com/Wandersalamander/Dimmer which does exactly what you asked for.
This works for me:
I've developed a C app which does this. See https://github.com/goglecm/AutoBrightnessCam .
It uses
fswebcam
to take pictures, can be configured withsystemd
to start automatically and detects whether the laptop is discharging (then it kicks in).