Skip to content

charles-eyes-ba/video-processing-unit

Repository files navigation

Video Processing Unit - VPU

Unit Tests Python 3.8 Coverage

The Video Processing Unit (A.k.a VPU) is the module that process the image from any video source. The proposal is extract some information from the video and provider those data to another system.

Architecture

Application

This diagram represents a bit of the architecture of how the VPU was built.


The dashed box (Video) represents a video source outside from the system.

  • A.I. Engine: This component is responsible to integrate with some framework that will enable other components to run computer vision algorithms (such as object detection).
  • Video Capture: This component is responsible for integrating with a video source and making sure to always provide the latest frame from the video source.
  • Object Detector or any detector: This kind of component is responsible for running the specific algorithm and provides the result.
  • Tracked Video: This component is responsible to aggregate all the algorithm and its status for a specific video source.
  • Main Unit: This component is responsible to handle all the tracked videos.
  • Websocket: This component is responsible for integrating with the websocket technology. This component will provide all necessary callbacks to communicate with other systems using websocket.
  • Main Unit + Websocket: This component is responsible for creating the integration between the main unit and the websocket.

Folders

> common: All utils methods/class/components
> dependency_injector: The dependency injector component responsible to implements all the components dependencies
> domain
  > components
    > component_name
      - __init__.py: Export the interface for the component (present on interface.py)
      - interface.py: Declarate the interface for the component
      - dependencies.py: Declare (if needs) all the dependencies for the component
      - *_impl.py: Implements the interface declared on interface.py
  > dependencies
    > dependency_name: Contains all the dependencies that is needed to use an external library
      - __init__.py: Export the interface for the dependency
      - interface.py: Declarate the interface for the dependency
> integrations: Implementations for all dependencies in domain > dependencies
> models: All the models used in the project

Setup

Create a .env file following the .env.example file.

Install Dependencies

It is recommended that a virtual environment be used for the project. If you want to use venv, just type:

$ python -m venv .venv

And to start virtual environment:

$ source .venv/bin/activate

To install dependencies:

$ pip install -r requirements.txt

Start

To start the VPU, you can do this with following command (run __main__.py):

$ python .

WebSocket Message

  • Send video feed ids:
[
  {
    "id": "camera_1",
    "detector_status": "RUNNING"
  },
  {
    "id": "camera_2",
    "detector_status": "ERROR"
  },
]
  • Send detections:
{
  "id": "camera_1",
  "objects": [
    "car",
    "car",
    "person"
  ]
}
  • Send error:
{
  "id": "camera_1",
  "error": "Something went wrong"
}
  • Receive new video feed list:
[
  {
    "id": "camera_1",
    "url": "http://camera.1",
    "config": {
      "run_detection": true
    }
  }
]
  • Receive to add video feed:
{
  "id": "camera_1",
  "url": "http://camera.1",
  "config": {
    "run_detection": true
  }
}
  • Receive to remove video feed:
{
  "id": "camera_1"
}
  • Receive a message to update video config:
{
  "id": "camera_1",
  "config": {
    "run_detection": false
  }
}