• Stars
    star
    2,006
  • Rank 23,087 (Top 0.5 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multiple Object Tracker, Based on Hungarian algorithm + Kalman filter.

Status CodeQL

Last changes

  • YOLOv8 detector worked with TensorRT! Export pretrained Pytorch models here (ultralytics/ultralytics) to onnx format and run Multitarget-tracker with -e=6 example

  • Some experiments with YOLOv7_mask and results with rotated rectangles: detector works tracker in progress

  • YOLOv7 worked with TensorRT! Export pretrained Pytorch models here (WongKinYiu/yolov7) to onnx format and run Multitarget-tracker with -e=6 example

  • YOLOv6 worked with TensorRT! Download pretrained onnx models here (meituan/YOLOv6) and run Multitarget-tracker with -e=6 example

New videos!

  • YOLOv7 instance segmentation

YOLOv7 instance segmentation:

Fast and small motion:

  • Vehicles speed calculation with YOLO v4

Vehicles speed:

  • First step to ADAS with YOLO v4

Simple ADAS:

Multitarget (multiple objects) tracker

1. Objects detector can be created with function CreateDetector with different values of the detectorType:

1.1. Based on background substraction: built-in Vibe (tracking::Motion_VIBE), SuBSENSE (tracking::Motion_SuBSENSE) and LOBSTER (tracking::Motion_LOBSTER); MOG2 (tracking::Motion_MOG2) from opencv; MOG (tracking::Motion_MOG), GMG (tracking::Motion_GMG) and CNT (tracking::Motion_CNT) from opencv_contrib. For foreground segmentation used contours from OpenCV with result as cv::RotatedRect

1.2. Haar face detector from OpenCV (tracking::Face_HAAR)

1.3. HOG pedestrian detector from OpenCV (tracking::Pedestrian_HOG) and C4 pedestrian detector from sturkmen72 (tracking::Pedestrian_C4)

1.4. Detector based on opencv_dnn (tracking::DNN_OCV) and pretrained models from chuanqi305 and pjreddie

1.5. YOLO detector (tracking::Yolo_Darknet) with darknet inference from AlexeyAB and pretrained models from pjreddie

1.6. YOLO detector (tracking::Yolo_TensorRT) with NVidia TensorRT inference from enazoe and pretrained models from pjreddie

1.7. You can to use custom detector with bounding or rotated rectangle as output.

2. Matching or solve an assignment problem:

2.1. Hungrian algorithm (tracking::MatchHungrian) with cubic time O(N^3) where N is objects count

2.2. Algorithm based on weighted bipartite graphs (tracking::MatchBipart) from rdmpage with time O(M * N^2) where N is objects count and M is connections count between detections on frame and tracking objects. It can be faster than Hungrian algorithm

2.3. Distance from detections and objects: euclidean distance in pixels between centers (tracking::DistCenters), euclidean distance in pixels between rectangles (tracking::DistRects), Jaccard or IoU distance from 0 to 1 (tracking::DistJaccard)

3. Smoothing trajectories and predict missed objects:

3.1. Linear Kalman filter from OpenCV (tracking::KalmanLinear)

3.2. Unscented Kalman filter from OpenCV (tracking::KalmanUnscented) with constant velocity or constant acceleration models

3.3. Kalman goal is only coordinates (tracking::FilterCenter) or coordinates and size (tracking::FilterRect)

3.4. Simple Abandoned detector

3.5. Line intersection counting

4. Advanced visual search for objects if they have not been detected:

4.1. No search (tracking::TrackNone)

4.2. Built-in DAT (tracking::TrackDAT) from foolwood, STAPLE (tracking::TrackSTAPLE) from xuduo35 or LDES (tracking::TrackLDES) from yfji; KCF (tracking::TrackKCF), MIL (tracking::TrackMIL), MedianFlow (tracking::TrackMedianFlow), GOTURN (tracking::TrackGOTURN), MOSSE (tracking::TrackMOSSE) or CSRT (tracking::TrackCSRT) from opencv_contrib

With this option the tracking can work match slower but more accuracy.

5. Pipeline

5.1. Syncronous pipeline - SyncProcess:

  • get frame from capture device;
  • decoding;
  • objects detection (1);
  • tracking (2-4);
  • show result.

This pipeline is good if all algorithms are fast and works faster than time between two frames (40 ms for device with 25 fps). Or it can be used if we have only 1 core for all (no parallelization).

5.2. Pipeline with 2 threads - AsyncProcess:

  • 1th thread takes frame t and makes capture, decoding and objects detection;
  • 2th thread takes frame t-1, results from first thread and makes tracking and results presentation (this is the Main read).

So we have a latency on 1 frame but on two free CPU cores we can increase performance on 2 times.

5.3. Fully acynchronous pipeline can be used if the objects detector works with low fps and we have a free 2 CPU cores. In this case we use 4 threads:

  • 1th main thread is not busy and used for GUI and result presentation;
  • 2th thread makes capture and decoding, puts frames in threadsafe queue;
  • 3th thread is used for objects detection on the newest frame from the queue;
  • 4th thread is used for objects tracking: waits the frame with detection from 3th tread and used advanced visual search (4) in intermediate frames from queue until it ges a frame with detections.

This pipeline can used with slow but accuracy DNN and track objects in intermediate frame in realtime without latency.

Also you can read Wiki in Russian.

Demo Videos

  • Mouse tracking:

Tracking:

  • Motion Detection and tracking:

Motion Detection and tracking:

  • Multiple Faces tracking:

Multiple Faces tracking:

  • Simple Abandoned detector:

Simple Abandoned detector:

Tested Platforms

  1. Ubuntu Linux 18.04 with x86 processors
  2. Ubuntu Linux 18.04 with Nvidia Jetson Nano (YOLO + darknet on GPU works!)
  3. Windows 10 (x64 and x32 builds)

Build

  1. Download project sources
  2. Install CMake
  3. Install OpenCV (https://github.com/opencv/opencv) and OpenCV contrib (https://github.com/opencv/opencv_contrib) repositories
  4. Configure project CmakeLists.txt, set OpenCV_DIR (-DOpenCV_DIR=/path/to/opencv/build).
  5. If opencv_contrib don't installed then disable options USE_OCV_BGFG=OFF, USE_OCV_KCF=OFF and USE_OCV_UKF=OFF
  6. If you want to use native darknet YOLO detector with CUDA + cuDNN then set BUILD_YOLO_LIB=ON (Install first CUDA and cuDNN libraries from Nvidia)
  7. If you want to use YOLO detector with TensorRT then set BUILD_YOLO_TENSORRT=ON (Install first TensorRT library from Nvidia)
  8. For building example with low fps detector (now native darknet YOLO detector) and Tracker worked on each frame: BUILD_ASYNC_DETECTOR=ON
  9. For building example with line crossing detection (cars counting): BUILD_CARS_COUNTING=ON
  10. Go to the build directory and run make

Full build:

       git clone https://github.com/Smorodov/Multitarget-tracker.git
       cd Multitarget-tracker
       mkdir build
       cd build
       cmake . .. -DUSE_OCV_BGFG=ON -DUSE_OCV_KCF=ON -DUSE_OCV_UKF=ON -DBUILD_YOLO_LIB=ON -DBUILD_YOLO_TENSORRT=ON -DBUILD_ASYNC_DETECTOR=ON -DBUILD_CARS_COUNTING=ON
       make -j

How to run cmake on Windows for Visual Studio 15 2017 Win64: example. You need to add directory with cmake.exe to PATH and change build params in cmake.bat

Usage:

       Usage:
         ./MultitargetTracker <path to movie file> [--example]=<number of example 0..7> [--start_frame]=<start a video from this position> [--end_frame]=<play a video to this position> [--end_delay]=<delay in milliseconds after video ending> [--out]=<name of result video file> [--show_logs]=<show logs> [--gpu]=<use OpenCL> [--async]=<async pipeline> [--res]=<csv log file> [--settings]=<ini file> [--batch_size=<number of frames>]
         ./MultitargetTracker ../data/atrium.avi -e=1 -o=../data/atrium_motion.avi
       Press:
       * 'm' key for change mode: play|pause. When video is paused you can press any key for get next frame.
       * Press Esc to exit from video

       Params:
       1. Movie file, for example ../data/atrium.avi
       2. [Optional] Number of example: 0 - MouseTracking, 1 - MotionDetector, 2 - FaceDetector, 3 - PedestrianDetector, 4 - OpenCV dnn objects detector, 5 - Yolo Darknet detector, 6 - YOLO TensorRT Detector, Cars counting
          -e=0 or --example=1
       3. [Optional] Frame number to start a video from this position
          -sf=0 or --start_frame==1500
       4. [Optional] Play a video to this position (if 0 then played to the end of file)
          -ef=0 or --end_frame==200
       5. [Optional] Delay in milliseconds after video ending
          -ed=0 or --end_delay=1000
       6. [Optional] Name of result video file
          -o=out.avi or --out=result.mp4
       7. [Optional] Show Trackers logs in terminal
          -sl=1 or --show_logs=0
       8. [Optional] Use built-in OpenCL
          -g=1 or --gpu=0
       9. [Optional] Use 2 threads for processing pipeline
          -a=1 or --async=0
       10. [Optional] Path to the csv file with tracking result
          -r=res.csv or --res=res.csv
       11. [Optional] Path to the ini file with tracker settings
          -s=settings.ini or --settings=settings.ini
       12. [Optional] Batch size - simultaneous detection on several consecutive frames
          -bs=2 or --batch_size=1

More details here: How to run examples.

Using MT Tracking as a library in your CMake project

Build MTTracking in the usual way, and choose an installation prefix where the library will be installed (see CMake Documentation for the defaults).

In the build directory run

$ cmake --install .

This will generate the CMake files needed to find the MTTracking package with libraries and include files for your project. E.g.

MTTrackingConfig.cmake
MTTrackingConfigVersion.cmake
MTTrackingTargets.cmake

In your CMake project, do the following:

    find_package(MTTracking REQUIRED)
    target_include_directories(MyProjectTarget PUBLIC ${MTTracking_INCLUDE_DIR})
    target_link_libraries(MyProjectTarget PUBLIC MTTracking::mtracking MTTracking::mdetection)

You may need to provide CMake with the location to find the above .cmake files, e.g.

$ cmake -DMTTracking_DIR=<location_of_cmake_files> ..

If CMake succeeds at finding the package, you can use MTTracking in your project e.g.

#include <mtracking/Ctracker.h>
//...
    std::unique_ptr<BaseTracker> m_tracker;

	TrackerSettings settings;
	settings.SetDistance(tracking::DistJaccard);
    m_tracker = BaseTracker::CreateTracker(settings);
//...

And so on.

Thirdparty libraries

License

Apache 2.0: LICENSE text

Project cititations

  1. Jeroen PROVOOST "Camera gebaseerde analysevan de verkeersstromen aaneen kruispunt", 2014 ( https://iiw.kuleuven.be/onderzoek/eavise/mastertheses/provoost.pdf )
  2. Roberto Ciano, Dimitrij Klesev "Autonome Roboterschwarme in geschlossenen Raumen", 2015 ( https://www.hs-furtwangen.de/fileadmin/user_upload/fak_IN/Dokumente/Forschung_InformatikJournal/informatikJournal_2016.pdf#page=18 )
  3. Wenda Qin, Tian Zhang, Junhe Chen "Traffic Monitoring By Video: Vehicles Tracking and Vehicle Data Analysing", 2016 ( http://cs-people.bu.edu/wdqin/FinalProject/CS585%20FinalProjectReport.html )
  4. Ipek BARIS "CLASSIFICATION AND TRACKING OF VEHICLES WITH HYBRID CAMERA SYSTEMS", 2016 ( http://cvrg.iyte.edu.tr/publications/IpekBaris_MScThesis.pdf )
  5. Cheng-Ta Lee, Albert Y. Chen, Cheng-Yi Chang "In-building Coverage of Automated External Defibrillators Considering Pedestrian Flow", 2016 ( http://www.see.eng.osaka-u.ac.jp/seeit/icccbe2016/Proceedings/Full_Papers/092-132.pdf )
  6. Roberto Ciano, Dimitrij Klesev "Autonome Roboterschwarme in geschlossenen Raumen" in "informatikJournal 2016/17", 2017 ( https://docplayer.org/124538994-2016-17-informatikjournal-2016-17-aktuelle-berichte-aus-forschung-und-lehre-der-fakultaet-informatik.html )
  7. Omid Noorshams "Automated systems to assess weights and activity in grouphoused mice", 2017 ( https://pdfs.semanticscholar.org/e5ff/f04b4200c149fb39d56f171ba7056ab798d3.pdf )
  8. RADEK VOPÁLENSKÝ "DETECTION,TRACKING AND CLASSIFICATION OF VEHICLES", 2018 ( https://www.vutbr.cz/www_base/zav_prace_soubor_verejne.php?file_id=181063 )
  9. Márk Rátosi, Gyula Simon "Real-Time Localization and Tracking using Visible Light Communication", 2018 ( https://ieeexplore.ieee.org/abstract/document/8533800 )
  10. Thi Nha Ngo, Kung-Chin Wu, En-Cheng Yang, Ta-Te Lin "A real-time imaging system for multiple honey bee tracking and activity monitoring", 2019 ( https://www.sciencedirect.com/science/article/pii/S0168169919301498 )
  11. Tiago Miguel, Rodrigues de Almeida "Multi-Camera and Multi-Algorithm Architecture for VisualPerception onboard the ATLASCAR2", 2019 ( http://lars.mec.ua.pt/public/LAR%20Projects/Vision/2019_TiagoAlmeida/Thesis_Tiago_AlmeidaVF_26Jul2019.pdf )
  12. ROS, http://docs.ros.org/lunar/api/costmap_converter/html/Ctracker_8cpp_source.html
  13. Sangeeth Kochanthara, Yanja Dajsuren, Loek Cleophas, Mark van den Brand "Painting the Landscape of Automotive Software in GitHub", 2022 ( https://arxiv.org/abs/2203.08936 )

More Repositories

1

Deep-learning-object-detection-links.

Object detectors based on DL (from: https://handong1587.github.io/deep_learning/2015/10/09/object-detection.html )
231
star
2

LogPolarFFTTemplateMatcher

OpenCV Fourier-Mellin algorithm implementation.
C++
151
star
3

TILT-Cpp-port

"TILT: Transform Invariant Low-rank Textures" CPP port.
C++
17
star
4

ellipseDetector

OpenCV ellipse detector.
C++
17
star
5

RotatedRectLib

Small library for working with rotated rectangle shaped image regions.
C++
15
star
6

nano_smpl

C
13
star
7

openvino_pedestrian_tracker

Standalone openvino pedestrian tracking demo project,
C++
11
star
8

nano_bfm

Basel morphable face model mesh and texture generator using GPU.
C
10
star
9

SelfCalibration

SelfCalibration using single image.
C++
9
star
10

PRNet_PyTorch_v2

Fixed version of https://github.com/tomguluson92/PRNet_PyTorch
Python
9
star
11

kaldi_vosk_win_cmake

cmake based kaldi + vosk + microphone speech recognition example
C++
7
star
12

Caffemodel-Parser

Tool for parse caffemodel files, and dump them to binary files.
Protocol Buffer
6
star
13

imgui_canvas

2d 3d plotting application temp;ate
C++
6
star
14

image-size-scanner

Scans image files and extracts image sizes, no image decoding, no dependencies.
C++
6
star
15

imgui_opencv_template

template project for imgui and opencv
C
6
star
16

mixtures_of_trees_FaceDetector_openCV

OpenCV port for mixtures of trees face detector. From site: http://www.ics.uci.edu/~xzhu/face/
C++
5
star
17

imgui_image_viewer

imgui image list
C
5
star
18

SpatialSubspaceRotation

Visual heart rate measure using Spatial Subspace Rotation (2SR) method. Inspired by https://github.com/partofthestars/Spatial-Subspace-Rotation
C++
5
star
19

dashedLineCompiler

Dashed line/polyline compiler, it provides ability to plot dashed lines to any plotting framework which can draw solid lines.
C++
5
star
20

AIML_editor

AIML bot code edidtor/debugger
HTML
4
star
21

SMPLpp

C
4
star
22

aiml_cpp

AIML interpreter C++ implementation with utf-8 support.
C++
3
star
23

TrackerGenerator

Tracker generator tool to configure and generate trackers from a set of components.
C
3
star
24

ImGUI_colorer

ImGui editor with syntax highlighing based on colorer project.
C
3
star
25

SuiteSparse

C
3
star
26

SparseAutoencoder

Разреженный автоэнкодер (visual studio)
MATLAB
3
star
27

optic_cad

Just a simple tandem of Easy3d and goptical libraries.
C++
3
star
28

FontToPNG

Generates PNG images for font glyphs,
C
3
star
29

PiecewiseAffineWarper

Fast OpenCv implementation of piecewise affine warper
C++
2
star
30

gabor_segmentation

C++
2
star
31

TrackerGeneratorProto

Prototype model project for TrackerGenerator project
C++
2
star
32

ImGuiColorTextEdit_rus

ImGuiColorTextEdit with russian support
C++
2
star
33

ScrollingBuffer

Simple scrolling buffer I used for multimodal time series applications.
C++
2
star
34

ImIDE

A chunk of code from my project, to fast start ide like projects.
C
2
star
35

tor_tools

tool for working with tor network (tested on visual studio 2019)
C
2
star
36

FaceRotate

Piecewise affine transform example.
2
star
37

Cmake-Dark-Edition

Cmake with dark theme.
C
2
star
38

slam2d_c_port

Минимальная реализация EKF SLAM 2D
C++
2
star
39

glut_cmake_template

Minimal glut CMake project, all dependencies are fetched from internet.
C++
2
star
40

cvGDI

C++
1
star
41

pytorch.nms

python 3.7, vs2019 version
Cuda
1
star
42

NavarroHumanEyeModel

Optical model of human eye.
C++
1
star
43

CaffeGui

Node Editor for CAFFE.
C++
1
star
44

Dots-RL-AI-gym

C++
1
star
45

GitStarsToMarkDown

Git stars list to single markdown file tool
Python
1
star
46

MATLABtoEigenCheatsheet

MATLAB to Eigen cheatsheet
1
star
47

slogi

Разбивка слов на слоги. (Конечный автомат)
C++
1
star
48

ShowcaseViewNext

Espian's Showcase View adopted to new api (java and kotlin versions included).
Java
1
star
49

NormalsComputerClass

Simaple per-face and per-vertex normals computing class for triangle mesh.
C++
1
star
50

HeadControl

C++
1
star
51

adaptagrams_win_cmake_java

Clone of adaptagrams project, tuned for Visual Studio + swig 4.0.1 for java binding. Build using CMake. Tested for java 17.
C++
1
star
52

copperspice_basic_app

CMake
1
star
53

XYPlot

C++
1
star
54

IIR_Filter_Design

Мои эксперименты с БИХ фильтрами. И библиотекой Iir1.
C++
1
star
55

navec_cpp

Word embedding model, based on navec project.
C
1
star
56

numerals

Функции работы с русскими числительными
C++
1
star
57

ConvNN

GPU accelerated simple convolutional network trainer/classifier.
XML
1
star
58

Optix7TemplateProject

Template Cmake based
C++
1
star
59

evevtBasedStdAppStarter

Starter project for event based multithreaded application. Based on eventpp library, no boost needed. Included spdlog.
C++
1
star