Communicate between Godot game and other software

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Skipperro

Hi,

I’ve created face detection app in python that looks at webcam input and can tell where the face is located (bounding box). I want to somehow pass those coordinates to my Godot game to adjust a camera position and create something like a VR-effect on a flat display.

Is there some way to inform Godot about those coordinates other than making it via networking protocols like a Python-Godot multiplayer or REST API? Some shared memory or other way existing in Godot to communicate with other software?

:bust_in_silhouette: Reply From: klaas

Hi,
godot has no integrated function to open a pipe to another process. Currently OS.execute() can be used to start a process and wait for the return on stdin or start a process non-blocking but does not return the output.

You can use the network protocol, this isnt too uncommen. Using the internal loopback address 127.0.0.1 should prevent the packets to go through the whole network stack. Therefor this should be quite fast and lag free.

And there is allways the possibility to write a GDNative script but this requires advanced skills in c or c++ and compiling.

Done it by writing Flask API in python and using normal HTTPRequest node in Godot to spam the API with requests every frame. It works:
https://youtu.be/ZdJurSbJopY

Skipperro | 2020-07-23 18:34

nice work!!!

klaas | 2020-07-23 18:40

:bust_in_silhouette: Reply From: JimArtificer

The other poster provided a fairly comprehensive answer. I will add some direct links to help other people that find this question via a search for ‘REST API’.

OS function calls:

HTTP calls:

Not strictly related to your question, but something that is fairly common: you can combine these to open a link in a web browser.
OS.ShellOpen("https://www.example.com/"); (C#)
OS.shell_open("https://www.example.com/") (GDScript)

REST APIs are generally unsuited to real-time applications due to HTTP protocol’s overhead. Direct TCP communication can be much faster.

Calinou | 2020-07-23 07:53

Direct TCP communication can be much faster.

Any ideas how to implement it? Where to look or what part of the manual? My knowledge of networks and multiplayer is zero. I would also like to connect godot with another app in c ++.

estebanmolca | 2020-07-23 13:40