frakman1 / lifx-lan-gui

LIFX LAN GUI Controller using appJar
MIT License
21 stars 5 forks source link

Sped up average RGB value calculation by an order of magnitude #3

Closed mclarkk closed 6 years ago

mclarkk commented 6 years ago

This PR has a lot of whitespace changes where tabs were automatically replaced by my editor with spaces. I'd understand if the PR is rejected for that.

All of the actual changes are in the followDesktop function. The biggest change is that the average RGB value calculation is done with two lines of numpy array operations, which results in an order of magnitude speedup over the Open CV approach (0.013 seconds vs 0.193 seconds). This doesn't cause that much improvement in the responsiveness of the lights, because that seems to be capped by the ability of the lights themselves to handle messages. Since the new followDesktop function is way faster than what the lights can handle, there is currently a delay built in (approximately the light transition time) to prevent the programming from spamming the lights at max speed.

tl;dr: The lights don't look that different, but the computer can get away with doing fewer calculations and spending its computational power on other tasks.

mclarkk commented 6 years ago

The PR has different goals than the master branch -- it finds the average instead of the dominant color. Between that and the whitespace issues, I'm closing this request.