How luizfelm/unity-python works
Based on our analysis of the file tree and the README, the project is a hybrid system that integrates a Python application (using OpenCV for real‑time face detection) with a Unity application (rendering and moving a cube based on received data). In essence, it is a full-stack interactive application where communication occurs over a TCP connection between the two separate systems.
Main components
• Python Server:
• Contains scripts such as ia.py (for face detection) and Server.py (handling TCP communication).
• Uses OpenCV to capture webcam input, detect face coordinates, and send these coordinates.
• Acts as the data producer by continuously sending face detection data.
• Unity Client:
• The Unity project (found in directories like Unity-Python and the nested Unity-Python-Project) includes the TCPClient.cs script.
• Receives data via TCP and updates the cube’s position in the Unity scene.
• Has standard Unity configuration, scenes, assets, and scripts that manage rendering and input.
• TCP Communication Channel:
• The Python server and Unity client connect over a TCP socket (using localhost IP 127.0.0.1 on port 5005 per the README).
• Represents the data flow path between the face-detection module and the cube movement controller.
Relationships and interactions
• The Python Server initiates the connection, processes the webcam feed, and sends data (face coordinates).
• The Unity Client listens on the designated port, receives the coordinates, and translates them into a movement update for the cube.
Architectural patterns and design principles
• Separation of Concerns:
• The face detection logic (Python) is separated from the rendering and interaction logic (Unity).
• Client-Server Model:
• The system leverages a simple client-server paradigm over TCP for inter-process communication.
• Real-Time Data Flow:
• Real-time data from the Python process drives the updates in the Unity scene.
Relevant technologies and frameworks
• Python uses OpenCV for computer vision and a TCP socket library for communication.
• Unity, typically with C# (as shown by TCPClient.cs), provides the scene and rendering engine.
• Supporting tools like Git configuration, Visual Studio settings, and Unity packages (e.g., WebSocketSharpFork for potential alternative communications) are also present.
Specific elements
• Configuration files or deployment elements (e.g., the TCP port setup) if deemed important for clarity.