How airtonmega/sistema-transmissao-imagens works
Project Type and Purpose
• This is a microservices-based inference system designed to detect people in video frames using YOLOv4/V8 models.
• The README indicates that the main role is to receive video frames from two clients (S2 and S3) and process them using FastAPI in S1 – which handles the detection logic using OpenCV – ensuring each person is counted only once.
• The project uses Docker to containerize its services and includes CI/CD workflows (visible in .github/workflows/ci-cd.yml).
File Structure
• Top-level, you have directories for different services: S1, S2, and S3.
• S1 contains the core inference service (FastAPI application) along with configuration (app/config.py), the main script (app/main.py), a detection service (app/services/detection_service.py) likely encapsulating the YOLO usage, and utility functions (app/utils/image_utils.py).
• S2 and S3 each have their own Dockerfile and a simpler structure with a main script under their respective /app directories. They are the clients sending video frames to S1.
• Additional files include docker-compose.yml for multi-container orchestration and CI/CD configuration within the .github directory.
• Configuration files (.env in S1) and requirements.txt files in each service further reveal dependency management and environmental setups.
README for Additional Insights
• The README clearly describes that S1 runs a FastAPI-based inference service using YOLO models, and outlines its key functionalities like processing via CPU, unique person counting, and API-based frame processing.
• It also explains that S2 and S3 are clients sending frames — each with a dedicated tracker ensuring unique person counts.
• Essential technologies include Python (>=3.8), FastAPI, OpenCV, Numpy, Pydantic, and Uvicorn.
a. Main Components:
• Inference Service (S1):
• Core application implementing FastAPI.
• Contains detection service, configuration modules, and image processing utilities.
• Responsible for receiving frames, running YOLO detection, and returning counted results.
• Client Services (S2 and S3):
• Each operates as an independent microservice/component that captures/sends video frame data to S1.
• Contains its own tracker logic to ensure that each detected person is processed only once.
• Orchestration / Containerization:
• Docker is employed for all services (S1, S2, S3) as indicated by the Dockerfiles.
• docker-compose.yml is used to orchestrate the containers, networking them together.
• CI/CD Pipeline:
• Indicated by the .github/workflows folder; ensures continuous integration/deployment for updates and testing.
b. Relationships and Interactions:
• S2 and S3 send video frame data via HTTP requests to S1’s FastAPI endpoints.
• S1 processes each incoming frame using its detection service (leveraging OpenCV and YOLOv4/V8), then sends back the response (person count).
• Docker containers are networked together via docker-compose, ensuring proper inter-service communication.
c. Architectural Patterns and Design Principles:
• Microservices architecture: Different services encapsulate their responsibilities (API service vs. client-side frame sending).
• Containerization: Use of Docker for isolating each service.
• Separation of concerns: S1 is solely responsible for inference and detection logic, while S2 and S3 handle frame acquisition and tracking.
• Use of external libraries and frameworks (FastAPI for service handling, OpenCV for image processing, and YOLO models for detection).
d. Relevant Technologies, Frameworks, and Libraries:
• FastAPI: For the inference service API (S1).
• OpenCV: For image loading and processing.
• YOLOv4/V8: The detection models integrated within S1.
• Docker & Docker Compose: For containerizing and orchestrating the services.
• Python libraries such as Pydantic and Numpy for data validation and processing.
• CI/CD tools integrated via GitHub Actions.