Harmonize Project lets you sync HDMI video with Philips Hue lights using a Raspberry Pi!
Harmonize Project connects Philips Hue lights and lightstrips to your TV screen content, creating an amazing ambient lighting effect! This application utilizes a low-latency video and color analysis built with Python 3.
Check out our Reddit thread here and watch the demo below! Electromaker explains how our application works at a high level in his podcast here!
Harmonize Project (formerly known as Harmonize Hue) has no affiliation with Signify or Philips Hue. Hue and Philips Hue are trademarks of Signify.
Thank you to all those who have contributed to this project. Please keep your pull requests coming!
Lights:
Minimum Hardware:
Example Hardware configuration (tested successfully unless otherwise noted below):
Software Setup:
Ubuntu Desktop 22.04 LTS 64-bit with Python v3.10.4 (most recent version tested)
Install OS from Raspberry Pi Imager software onto SD card (see https://www.raspberrypi.org/software/). Install SD card and boot.
Install all dependencies via the following commands. Be sure to watch for errors!
sudo apt-get install python3-pip
pip3 install http-parser numpy zeroconf termcolor
sudo apt install snapd
sudo snap install avahi
sudo apt install screen
sudo apt-get install cmake
sudo apt-get install gcc g++
sudo apt-get install python3-dev python3-numpy libpython3-all-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install git
git clone https://github.com/opencv/opencv.git
mkdir opencv/build
cd opencv/build
cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_java=OFF -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_CUDA=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF ..
make -j4
sudo make install
cd ../..
git clone https://github.com/MCPCapital/HarmonizeProject.git
Legacy Software Setup (currently unsupported and not maintained):
Download the latest scripts and install all dependencies via the following commands. Be sure to watch for errors! You will need about 1GB of free space. The script can run for up to an hour.
git clone https://github.com/MCPCapital/HarmonizeProject.git
cd HarmonizeProject
sudo ./setup.sh
Hardware Setup Example A:
Hardware Setup Example B (for A/V receivers with 2 or more HDMI outputs):
Entertainment Area Configuration:
First-Time Run Instructions:
To start the program:
screen
cd HarmonizeProject
./harmonize.py
screen -r
Command line arguments:
-v
Display verbose output-g #
Use specific Entertainment area group number (#)-b <id>
Use specified bridge ID-i <ip>
Use specified bridge IP address-s
Enable latency optimization for single light source centered behind display-w #
Sets the video device wait time to the specified value, in seconds. Defaults to 0.75.-f <file/url>
Use the specified file or URL video stream instead of a video device.-l [0-255]
Decrease brightness from 0 to 255 (0 is maximum brightness, default is 30).Configurable values within the script: (Advanced users only)
breadth
- determines the % from the edges of the screen to use in calculations. Default is 15%. Lower values can result in less lag time, but less color accuracy.time.sleep(0.015)
- Determines how frequently messages are sent to the bridge. Keep in mind the rest of the function takes some time to run in addition to this sleep command. Bridge requests are capped by Philips at a rate of 60/s (1 per ~16.6ms) and the excess are dropped.nice
command to give Harmonize higher priority over other CPU tasks.python3 ./videotest.py
to see if your device (via OpenCV) can properly read the video input.-w
argument *This is a known bug (race condition).ls -ltrh /dev/video*
should provide a list of results that includes /dev/video0 when the OS properly detects the video capture card.Pull requests are encouraged and accepted! Whether you have some code changes or enhancements to the readme, feel free to open a pull request. Harmonize Project is licensed under The Creative Commons Attribution-NonCommercial 4.0 International Public License.
Development credits to Matthew C. Pilsbury (MCP Capital LLC), Ares N. Vlahos, and Brad Dworak.