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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file collision_warning_service-0.4.1.tar.gz.

File metadata

  • Download URL: collision_warning_service-0.4.1.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.2 Windows/10

File hashes

Hashes for collision_warning_service-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d3d931bc9338a251da03adaac67c5b441e33f1b4bf0f748e46bd1496867d5816
MD5 5502448c248a535bf0a22931ec9f0c12
BLAKE2b-256 9a473ad5a2268efdbb11ab2f46078cbe5b7fa95c73960a9cb12e6a88248741c4

See more details on using hashes here.

File details

Details for the file collision_warning_service-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for collision_warning_service-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94cb0e41da50ce696818092445ac8fc272d518c0b772f769c33e3638a146fbb1
MD5 08a5901965dcae962583ee3b3cc5ba84
BLAKE2b-256 b2a03ba5387ce67ad68fe039a76639702cb607b295a63e9ff7d08812800ebe10

See more details on using hashes here.

Supported by

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