Skip to main content

Early collision warning Network Application for Transportation use case

Project description

CollisionWarningService

The algorithm detects and tracks objects in video using SORT algorithm. For all objects, their projection to road plane is calculated (i.e. camera calibration is necessary). Location of objects on the road plane is filtered by Kalman Filter - which gives us the ability to predict future movement of objects. If the future path of an object strikes warning zone, alarm event is emitted. The event contains detailed description of the offensive behaviour, like location on screen and in the world, relative speed and direction of object, and time of entering the warning zone.

Example

Requirements

There are few basic requirements for the algorithm itself

  • numpy
  • pyyaml
  • opencv-python or py-opencv if you use conda
  • pillow
  • shapely
  • filterpy
  • pytorch

Additional packages are required if you want to use the service as a Network Application within 5G-Era framework/

  • era_5g_interface
  • era_5g_client
  • simple-websocket
  • python-socketio
  • flask

Installation

Getting started - standalone example

As an example, we use the video posted by u/Big-Replacement-7684 in r/IdiotsInCars showing typical dangerous situation that might result in car crash.

# This will load configurations for video3.mp4 and show visualization.
> python fcw_example.py

Relevant configurations are in videos/video3.yaml - camera config, and config/config.yaml algorithm settings.

Running with your videos

Calibrate camera

Setup algorithm parameters

Run the example

Network Application for 5G-ERA

Run FCW service/NetApp

Docker

The FCW service can be started in docker, e.g.The FCL service can be run in docker (docker/fcw_service.Dockerfile), for example in this way, where the GPU of the host computer is used and TCP port 5897 is mapped to the host network.

docker build -f fcw_service.Dockerfile -t but5gera/fcw_service:0.1.0 . \
  && docker run -p 5897:5897 --network host --gpus all but5gera/fcw_service:0.1.0 

Local startup

The FCW Service can also be run locally using fcw/service/interface.py, but all necessary dependencies must be installed in the used python environment and the NETAPP_PORT environment variable should be set (default is 5896):

set NETAPP_PORT=5897

or on Linux:

export NETAPP_PORT=5897

Requirements:

  • git
  • python3.8 or later
  • ffmpeg
  • CUDA
  • poetry

At now, FCW Service package collision-warning-service contains both server and client (examples) parts. This package depends on

  • era-5g-interface>=0.4.1
  • era-5g-client>=0.4.1

Clone this repository somewhere first:

git clone https://github.com/5G-ERA/CollisionWarningService.git
cd CollisionWarningService

Installation of collision-warning-service:

cd ..
poetry install

Run FCW service:

poetry run fcw_service

For CUDA accelerated version, on Windows may be needed e.g.:

pip3 install --upgrade --force-reinstall torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118

It depends on the version of CUDA on the system https://pytorch.org/get-started/locally/.

Run client

Set NETAPP_PORT environment variable (default is http://localhost:5896):

set NETAPP_ADDRESS=http://localhost:5897

or on Linux:

export NETAPP_ADDRESS=http://localhost:5897

Run FCW python simple client example:

poetry run fcw_client_python_simple -c config/config.yaml --camera videos/video3.yaml videos/video3.mp4

or run simple client with rtsp stream (yaml files are not compatible with tshi rtsp stream, it is for example only):

poetry run fcw_client_python_simple -c config/config.yaml --camera videos/video3.yaml rtsp://root:upgm_c4m3r4@upgm-ipkam5.fit.vutbr.cz/axis-media/media.amp

or run advanced client:

poetry run fcw_client_python -c config/config.yaml --camera videos/video3.yaml videos/video3.mp4

Notes

We use slightly modified version of SORT tracker from abewley gitub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collision_warning_service-0.4.1.tar.gz (31.5 kB view hashes)

Uploaded Source

Built Distribution

collision_warning_service-0.4.1-py3-none-any.whl (40.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page