strunker / GoveeSync

This code will allow you to use Govee internal UDP api to control your device as well as sync what is on the screen.
31 stars 3 forks source link

Major refactor that adds pydantic, numpy and pillow #4

Open StevenKauwe opened 6 months ago

StevenKauwe commented 6 months ago

Was really grateful to find your repo. I was able to understand the commands and interaction much better because of it. I did a bunch of updates to make my life a bit easier and I thought I'd share in case you found it useful.

I'm not necessarily suggesting you merge this. Especially because I deleted all your stuff... hahah I'm just sharing with you in case you find some parts useful.

strunker commented 6 months ago

So, first off, wow. This is a ton of work on your end, and your documentation with the color columns does a better job explaining.

Im not 100% clear on where numpy and pydantic come into play. And I saw you are using imagegrab. I had tested and imagegrab was FAR slower than GDI at captures at least for games. And some implementations of imagegrab dont store the bitmap in ram, they write to disk, which further impacts performance.

When you are in a high FPS game and you want to mirror colors as fast as possible, especially if you have multiple devices, GDI and which I assume underneath is probably using directx or some type of windows driver to read the pixels, seemed faster. Sending UDP is obviously pretty quick due to the nature of the protocol, but when there are multiple devices at work I think a further expansion on all this code would implement threads to deal with many devices. I have an internal build that does so, but the code out here on GIT omits it for simplicity purposes.

I have zero issue with the merge here, and my hope was always that this code would simply serve as a reference. There are a ton of others ways to implement all this, including building a class for it as well. I think what you did certainly serves as an improvement/alternative, and I tried to add you on LinkedIn. My initials are LB, I just omit for privacy on here. I will merge once I have a little more time to review the numpy work.

TY

StevenKauwe commented 3 months ago

Hi there! Just seeing this comment now. I mostly opened this PR as a way of saying thank you! Please feel no obligation to merge. I wanted to use pydantic to make the required parameters explicit. And numpy to do fast math pixel values so that the displayed colors are more "appealing". Regarding GDI, I suspect that is a better answer. I was just familiar with Pillow (and I think it works on all OS's). I might revisit and refactor to use GDI. I get about 30 fps on the lighting updates on my hardware, and I have a damn good computer. It does bother me a bit with the delay, so that would be a good thing for me to revisit!

I'm not sure if I saw your LinkedIn invite (or maybe I ignored it at the time) but please send it again and we can chat!

strunker commented 3 months ago

Last name is barone. It states still pending on LinkedIn. So imagine it is somewhere lol. If i withdraw it then i wont be able to re-add you. Would like to dive into the numpy piece over chat if you are willing, simpler than back and forth on here. The color averaging is the most difficult piece of this, if you get it wrong or simply mirror what is on screen the effect can be rather jarring. Thanks Steven :)