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 #2

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.

frakman1 commented 6 years ago

I plan to incorporate your logic to not throttle requests so as not to spam the bulbs.

Also, if you have any suggestions about standardizing the white space, I will do that. I know it's not ideal as I have edited the code on Mac and Windows and it wasn't properly indented to start with anyway.