Godot + Python — Camera Stream
In a previous post I created a way to communicate between Godot and Python. The motivation behind that post was to get the camera stream from a webcam into Godot, as this is not supported in Godot on Linux/Windows, or at least not at the time of writing in Godot 4.2.2. In this post, I will show you how we can send not only text message but also encoded data such as images from Python to Godot.
Recap
I am going to use the project of the last post as a starting point. The project contains two sub folders, one for the Godot project and one for the Python code. The Godot project contains a single scene with a node that start a UDP server, sending a greeting to any client that connects. In Python I implemented a basic UDP client that simply sends a greeting and waits for a single reply message.
NOTE: In the previous project, we could have also used the reliable protocol TCP to send these messages. In fact it would have made more sense to establish a reliable connection and make sure that the greetings are received for that project. However, now we will start sending larger amounts of data (full RGB frame images) and we don’t really care that every single one is received and that they are in order, but rather we have them be received in near real-time. If we were to use TCP and we don’t process the images fast enough, over time a backlog of…