My goal for a project is to send some Python data live to Unity 3D.
More detailled: I'm processing a livestream webcam image for some values with OpenCV and Numpy and (ideally) want to send those calculated values continuously to Unity3D while the webcam and Python script is running. According to those sent values, a GameObject in Unity is then being live-transformed.
I got this to work only statically so far by using a localhost Python socket and C# System.Net.Sockets: When pressing a key while my Python script is running, the socket will open and send data. To receive, I then have to press a GUI button in Unity and afterwards the socket closes.
My problem: Using the socket in my Python while-loop while streaming the webcam makes my Python script freeze (found a workaround in my static idea for this freeze by sending random data back from Unity to Python), and I obviously also don't want to have to press a button in Unity everytime I want to receive anything.
My question: What method seems fit for my task to continuously send data from OpenCV (Python) to Unity? I don't really know what I should look into to be honest, and haven't found any similar issue on here so far. I heard about something like Python UDP/TCP sockets or C# Thread, is this something to go after? Or are sockets the thing to stick to and try to fix?