Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

AutoBrightness

Automatically adjusts a Windows laptop's screen brightness using the webcam.

This small Python utility reads the average brightness from the webcam, maps it to a target screen brightness and applies smooth, stable changes via Windows WMI. It's intended for personal use on Windows laptops where automatic brightness hardware features are limited or unavailable.

Features

  • Real-time ambient light measurement via webcam
  • Smooth transitions and deadzone to avoid flicker
  • Configurable parameters (camera index, smoothing, limits)

Requirements

  • Windows (uses WMI to change brightness)

  • Python 3.8+

  • See requirements.txt for Python packages:

  • opencv-python

  • WMI

  • pywin32

Installation

  1. Create or activate a Python virtual environment (recommended).
  2. Install dependencies:
pip install -r requirements.txt

Usage

Run the script from the project folder:

python auto_brightness.py
  • The script prints camera average, target brightness and current screen brightness to the console.
  • Press Q in the camera window or Ctrl+C in the console to stop.

To enable the on-screen preview window while testing, open auto_brightness.py and set SHOW_CAMERA = True.

Configuration

All runtime options are plain constants at the top of auto_brightness.py:

  • CAMERA_INDEX — index of webcam (0, 1, ...)
  • READ_INTERVAL — seconds between camera reads (default 0.5)
  • SMOOTHING_SAMPLES — how many camera readings to average
  • STABLE_TIME — seconds to wait while lighting is stable before changing
  • MIN_BRIGHTNESS, MAX_BRIGHTNESS — limits applied to the screen value
  • CAMERA_DARK, CAMERA_BRIGHT — camera calibration points mapped to min/max
  • BRIGHTNESS_DEADZONE — minimum change required to trigger adjustment
  • BRIGHTNESS_STEP — how much to change screen brightness per step
  • SHOW_CAMERA — show webcam overlay for debugging

Edit those values directly in the file and re-run the script to change behaviour.

Troubleshooting

  • The script only works on Windows because it uses WMI to set brightness.
  • Some monitors or drivers may not support WmiSetBrightness — if brightness does not change, check your device driver and try running the script as an elevated (administrator) user.
  • If the webcam cannot be opened, try changing CAMERA_INDEX to another value (0, 1, 2, ...). Use other camera apps to confirm the index.
  • If console output looks noisy, increase SMOOTHING_SAMPLES or STABLE_TIME.

Notes

  • This tool is best for laptops where the physical brightness controls are accessible through WMI. It is provided as-is for experimentation.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages