Awesome Open Source
Awesome Open Source

Object Tracking with Line Crossing and Area Intrusion Detection

This program uses an object detection deep learning model and a re-identification model to find and track the objects in a movie. Then, the program will track the trajectory of the objects and check if the objects cross the defined virtual lines or the objects are inside the defined areas. The program uses Intel(r) Distribution of OpenVINO(tm) toolkit for deep learning inferencing.
To track the objects, the program extracts the feature vectors from the objects which consists of 256 FP values with the re-identification DL model. The program can identify which object is most similar to the objects in the previous frame and record the trajectory. The L2 norm (or the distance) of those feature vectores represents the similarity of the objects. This program uses cosine distance to check the similarity between the objects.
The line crossing check and area intrusion check are done by regular (meaning, non deep learning based) arithmetic algorithm.
The latest version playbacks sound when an event such as crossing a line or entering to an area happens.
You can learn how to use line-crossing and area intrusion function from simple test program (

このプログラムはディープラーニングの物体検出モデルと特徴抽出(re-identification)モデルを用いて、ムービーフレーム中のオブジェクトを検出し、追跡するプログラムです。プログラムは見つけたオブジェクトの軌跡を記録し、オブジェクトが定義された仮想ラインを超えたり定義されたエリアに侵入したことを検出します。ディープラーニングの推論にはIntel(r) Distribution of OpenVINO(tm) toolkitを利用しています。

Object Tracking and Line Crossing Demo


Required DL Models to Run This Demo

The demo expects the following models in the Intermediate Representation (IR) format:

  • For person / pedestrian detection and re-identification
    • pedestrian-detection-adas-0002
    • person-reidentification-retail-0031

You can download these models from OpenVINO Open Model Zoo. In the models.lst is the list of appropriate models for this demo that can be obtained via Model downloader. Please see more information about Model downloader here.

How to Run

0. Prerequisites

  • OpenVINO 2021.3
    • If you haven't installed it, go to the OpenVINO web page and follow the Get Started guide to do it.

1. Install dependencies

The demo depends on:

  • opencv-python
  • numpy
  • scipy
  • munkres

To install all the required Python modules you can use:

(Linux) pip3 install -r requirements.txt
(Win10) pip install -r requirements.txt

2. Download DL models from OMZ

Use Model Downloader to download the required models and convert the downloaded model into OpenVINO IR models with Model Converter.

(Linux) python3 $INTEL_OPENVINO_DIR/deployment_tools/tools/model_downloader/ --list models.lst
(Win10) python "%INTEL_OPENVINO_DIR%\deployment_tools\tools\model_downloader\" --list models.lst

3. Run the demo app

(Linux) python3
(Win10) python

Demo Output

The application draws the results on the screen.

Simple test program is a simple test program for line-crossing and area-intrusion detection. You can move mouse cursor to test how it works.

Coordinates checker

You can utilize coordinates-checker to get the coordinates of point of interest to define boundary lines and area polygons. The coordinates-checker is also included in this project as a submodule. See coordinates-checker GitHub repo for details.
python coordinates-checker\ [image.jpg / movie.mp4 / 0 ]

Tested Environment

  • Windows 10 x64 1909 and Ubuntu 18.04 LTS
  • Intel(r) Distribution of OpenVINO(tm) toolkit 2021.3
  • Python 3.6.5 x64

See Also

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (1,140,439
Deep Learning (22,817
Object Detection (2,545
Inference (461
Intel (449
Object Tracking (267
Openvino (225
Surveillance (164
Identification (139
Intrusion Detection (136
Related Projects