A Python-based Mac application that creates dynamic ambient lighting by syncing your Philips Hue lights with colors detected from your camera input. Perfect for creating an immersive viewing experience when watching TV or movies.
- Real-time Color Detection: Analyzes video input from your Mac's camera
- Multiple Detection Methods:
- Center Area: Focuses on the center of the frame
- Full Screen: Averages colors across the entire frame
- Grid Average: Divides frame into grid and averages colors
- Dominant Color: Uses k-means clustering to find the most prominent color
- Color Smoothing: Reduces flickering with temporal smoothing
- Adjustable Settings:
- Brightness control (0-254)
- Saturation control (0-254)
- Update rate (1-30 fps)
- Camera selection
- User-Friendly GUI: Built with PyQt5 for easy control
- macOS
- Python 3.8 or higher
- Philips Hue Bridge and compatible lights
- Camera (built-in or external)
- Clone or download this repository:
cd /Users/meher.gara/work/hue-ambient- Create a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txtYou need to find your Hue Bridge's IP address. There are several ways to do this:
Method 1: Philips Hue App
- Open the Philips Hue app on your phone
- Go to Settings > Hue Bridges > (i) icon
- Note the IP address shown
Method 2: Router Admin Panel
- Log into your router's admin panel
- Look for connected devices
- Find the device named "Philips Hue"
Method 3: Discovery URL Visit: https://discovery.meethue.com/ This will show all Hue bridges on your network.
When connecting to your Hue Bridge for the first time:
- Enter your Bridge IP address in the app
- Click "Connect to Bridge"
- Press the physical button on top of your Hue Bridge
- Wait for the connection to complete
The app will save the connection credentials for future use.
- Start the application:
python3 main.py-
Configure the Hue Bridge:
- Enter your Bridge IP address
- Click "Connect to Bridge"
- Press the button on your Hue Bridge if prompted
-
Configure Camera:
- Select your camera from the dropdown
- The default is usually Camera 0 (built-in camera)
-
Adjust Settings:
- Choose a detection method
- Set your preferred update rate (higher = more responsive, more CPU usage)
- Adjust brightness and saturation to your liking
- Enable/disable color smoothing
-
Start Ambient Lighting:
- Click "Start Ambient Lighting"
- Your Hue lights will now sync with the colors detected by your camera
-
Stop when done:
- Click "Stop Ambient Lighting"
-
Camera Positioning: Point your camera at your TV screen for best results
- Position the camera to capture the TV without reflections
- Adjust distance to minimize dark borders in the frame
-
Detection Method:
- Use "Center Area" for focused content (ideal for TVs)
- Use "Dominant Color" for more accurate color representation
- Use "Grid Average" for balanced ambient lighting
-
Update Rate:
- 10-15 fps provides good balance between responsiveness and CPU usage
- Lower rates (5-10 fps) for subtle ambient effects
- Higher rates (20-30 fps) for fast-paced content
-
Smoothing:
- Keep enabled to reduce flickering during scene changes
- Disable for more immediate color changes
-
Brightness & Saturation:
- Lower brightness for subtle ambient effects
- Increase saturation for more vibrant colors
- Adjust based on room lighting conditions
hue-ambient/
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── README.md # This file
├── camera/
│ ├── __init__.py
│ └── capture.py # Camera capture functionality
├── color/
│ ├── __init__.py
│ └── analyzer.py # Color detection and analysis
├── gui/
│ ├── __init__.py
│ └── main_window.py # Main application window
└── hue/
├── __init__.py
└── controller.py # Philips Hue bridge controller
- Camera not working: Check camera permissions in System Preferences > Security & Privacy > Camera
- No video feed: Try selecting a different camera index in the dropdown
- Poor quality: Ensure adequate lighting in the room
- Can't connect: Verify Bridge IP address is correct
- Connection timeout: Ensure your Mac and Bridge are on the same network
- Lights not responding: Check that lights are on and reachable in the Hue app
- High CPU usage: Lower the update rate
- Laggy response: Reduce camera resolution or use a simpler detection method
- Flickering lights: Enable color smoothing
You can modify the following parameters in the code:
color/analyzer.py: Adjust color detection algorithmshue/controller.py: Modify XY color space conversioncamera/capture.py: Change camera resolution and FPS
- Requires camera to be pointed at the screen (screen capture would be more accurate but requires additional permissions)
- Color accuracy depends on camera quality and lighting conditions
- Network latency may affect responsiveness with wireless Hue bulbs
Potential features to add:
- Screen capture mode (instead of camera)
- Multi-zone lighting for entertainment areas
- Scene presets and profiles
- Scheduling and automation
- Music visualization mode
- Integration with other smart home platforms
This project is for personal use. Philips Hue is a trademark of Signify Holding.
Built with:
- OpenCV for computer vision
- PyQt5 for GUI
- phue for Philips Hue integration
- NumPy for numerical operations
For issues or questions:
- Check the Troubleshooting section above
- Verify your Hue Bridge and lights are working with the official Hue app
- Ensure all dependencies are properly installed
Enjoy your ambient lighting experience!