bauersimon / ScreenToArtNet

Capture screen colors and send them over ArtNet.
MIT License
7 stars 1 forks source link

Delay from screen change to artnet update #20

Open LoneWalkerWolf opened 2 years ago

LoneWalkerWolf commented 2 years ago

Is there any way to either use multithreading / or just simply improve the update time for each update? I'm currently getting around 11.32 updates/secc and I was wondering if there is any way you could push this to around 30?

bauersimon commented 2 years ago

Hi, thanks for opening an issue. Was not expecting this any time soon (or at all). These are basically all the optimization issues in this repo especially #13 and maybe #4 would definitely boost this.

I'm happy to provide some guidance or maybe implement a quick and dirty version of either of those. Though I currently don't have an artnet interface anymore so I cannot test things. Of course you could also have a look yourself @LoneWalkerWolf.

LoneWalkerWolf commented 2 years ago

Hi there, thanks for the response! I work as a lighting designer, and I stumbled across this when a client of mine asked if they could have some lights react to a presentation video. I can definitely test some things for you if necessary!

I looked at those issues, but they don't really provide any information about "how" you / I could go about fixing it. If you have any suggestions for me to try here, I would be very open to testing those.

bauersimon commented 2 years ago

Did you try the spacing parameter yet? This looks at every second (for 1), third (for 2), fourth (for 3), etc. pixel only when computing the screen color. That should definitely improve performance. At some point the colors might not be picked up correctly though. As for implementing. The most impact would be #13 but I'm not sure if you're familiar with Go goroutines and channels.

LoneWalkerWolf commented 2 years ago

Just had a chance to test. The spacing parameter did indeed help. 2 gave me an update rate of around 22.48 updates/secc. There is still a significant delay between the image on the screen flashing, and the lights responding. I do believe that goroutines might fix this, but I do not have any experience using the Go language. My primary experience is in C#, Java and Python.

I'm using this video to test: https://www.youtube.com/watch?v=JeQuelXsUYA&ab

I will upload a video of what I am talking about either tomorrow or later next week depending on when I next have time in the theatre.

bauersimon commented 2 years ago

Nice that the spacing did improve the rate!

I must say I tested it locally one year ago and had no issues with latency at all! 🤔 So you say the time delay from the screen to artnet is too high? Interesting. Does it start properly and the delay grows? Or does it have the delay right from the start? I will adapt the issue title if that's fine with you!

bauersimon commented 2 years ago

@LoneWalkerWolf I'd recommend first implementing a time-tracker that checks how much time passes from the screen update to the artnet update. This way we can be sure that this is indeed the problem.