This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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?

in Engine by (207 points)

2 Answers

+3 votes
Best answer

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.

by (4,088 points)
selected by

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

nice work!!!

+1 vote

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:
https://docs.godotengine.org/en/stable/classes/class_os.html?#methods

HTTP calls:
https://docs.godotengine.org/en/stable/classes/class_httprequest.html

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)

by (868 points)

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

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 ++.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.