Turn Hue lights on and off with a laser
- Philipps Hue
- A computer with a camera, python and opencv
- A red laser pointer
- Python 2.7
- OpenCV; I used these instructions
- BeautifulHue
Create a python file secret_keys.py
with the information about your bridge. E.g.,
hue_ip="192.168.1.2"
hue_key="9o33LVASDo9nvARn"
If you don't have this information, follow these instructions to pair your computer with your bridge.
Start the program with python find_laser.py
. This will open two windows; one containing the HSV camera view and one containng the masked camera view which should be completely black and only have a white spot where the laster is detected.
Leave the program with ESC. This closes the window and writes a file frame.png
to disk.
Edit the frame.png
by turning it into a grey-scale image and mark the areas with Hue lights in different colors like in this image, and safe the image as triggers.png
. Now update the trigger_actions
in line 21 of find_laser.py accordingly, and you should be good to go:
Just run python find_laser.py
again and try to touch the regions marked in triggers.png
with the laser.
I didn't spend much time perfecting the image filtering that detects the laser. So, if you have a lot of direct sunlight that reflects in metal objects (e.g., a chrome lamp) this might be detected as laser as well and turn your lights on and off. In that case, use the control image (the one that should be mostly black), and adjust the filtering.