Git Product home page Git Product logo

byte-track-eigen's Introduction

ByteTrack-Eigen

Introduction

ByteTrack-Eigen is a C++ implementation of the ByteTrack object tracking method, leveraging the Eigen library for high-performance matrix and vector operations. This library is designed for tracking objects in video frames using Kalman Filters and the Hungarian algorithm.

Demo Video

yolox-byte-track-demo.mp4

Source Video by RDNE Stock project from Pexels: (link)

Features

  • Object tracking using Kalman Filters and Hungarian algorithm.
  • Handling of occlusions and re-identifying lost objects.
  • Utilization of the Eigen library for optimized matrix and vector operations.

Components

  • BaseTrack: Foundational class for object tracking.
  • BoundingBoxTrackUtils: Utility functions for track operations.
  • BYTETracker: Main class for the BYTE tracking algorithm.
  • HungarianAlgorithmEigen: Hungarian Algorithm implementation with Eigen.
  • KalmanBBoxTrack: Kalman filter-based bounding box tracking.
  • KalmanFilter: Kalman filter implementation for tracking bounding boxes in image space.
  • LinearAssignment: Solves linear assignment problems using the Hungarian Algorithm.
  • BoundingBoxIoUMatching: Utility functions for bounding box operations.

Requirements

  • CMake 3.20 or higher.
  • C++17 or higher.
  • Eigen library (automatically downloaded by CMake).

Building the Library

  1. Clone the repository:
    git clone https://github.com/cj-mills/byte-track-eigen.git
  2. Navigate to the project directory:
    cd byte-track-eigen
  3. Build the project using CMake:
    mkdir build && cd build
    cmake ..

Usage

Here is an example of how to use ByteTrack-Eigen in your project:

// Example usage of ByteTrack-Eigen
#include "BYTETracker.h"

int main() {
    float track_thresh = 0.23f;
    int track_buffer = 30;
    float match_thresh = 0.8;
    int frame_rate = 30;
    BYTETracker tracker(track_thresh, track_buffer, match_thresh, frame_rate);
}

Demo Projects

  • yolox-bytetrack-onnx-demo: A Visual Studio project demonstrating how to perform object tracking across video frames with YOLOX, ONNX Runtime, and the ByteTrack-Eigen library.
  • unity-bytetrack-plugin: A simple native plugin for the Unity game engine, built in Visual Studio, that leverages the ByteTrack-Eigen library to perform real-time object tracking.

License

This project is licensed under the MIT License.

Acknowledgments

Special thanks to the Eigen library team and authors of the ByteTrack algorithm.

byte-track-eigen's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

byte-track-eigen's Issues

Platform Compatibility

Thank you for your open-source contribution. I think we can modify include/Export.h like this to enable cross-platform compilation.

#ifdef BUILDING_BYTE_TRACK_EIGEN
    #ifdef _WIN32
        #define BYTE_TRACK_EIGEN_API __declspec(dllexport)
    #else
        #define BYTE_TRACK_EIGEN_API __attribute__((visibility("default")))
    #endif
#else
    #ifdef _WIN32
        #define BYTE_TRACK_EIGEN_API __declspec(dllimport)
    #else
        #define BYTE_TRACK_EIGEN_API
    #endif
#endif

Memory Bug

The member variable removed_tracks defined in the class BYTETracker is not properly cleaned up, which can lead to memory growth and decreased code execution speed.

I suggest adding the following line at the end of the member function void BYTETracker::handle_lost_and_removed_tracks:

this->removed_tracks.clear();

A bug has been encountered in the Debug mode.

OS: ubuntu20.04
After setting the CMake option: -DCMAKE_BUILD_TYPE=Debug, and compiling the code, when running the executable program, the following error is reported:

bytetrack-test: /home/zfy/projects/bytetrack_zfy/eigen/Eigen/src/Core/PlainObjectBase.h:273: void Eigen::PlainObjectBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived = Eigen::Matrix<double, 4, 1>; Eigen::Index = long int]: Assertion `(!(RowsAtCompileTime!=Dynamic) || (rows==RowsAtCompileTime)) && (!(ColsAtCompileTime!=Dynamic) || (cols==ColsAtCompileTime)) && (!(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic) || (rows<=MaxRowsAtCompileTime)) && (!(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic) || (cols<=MaxColsAtCompileTime)) && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array."' failed.
./run.sh: line 1: 81013 Aborted                 (core dumped) ./build/bytetrack-test data/sample.mp4 data/txt_result

when setting the CMake option: -DCMAKE_BUILD_TYPE=Release, The above error will not occur.
I think we can optimize the following function to fix this bug.

Eigen::Vector4d KalmanBBoxTrack::tlwh() const {
    if (mean.isZero(0)) { // Checking if 'mean' is uninitialized or zero
        return _tlwh;
    }   

    // Eigen::Vector4d ret = mean;
    Eigen::Vector4d ret = mean.head(4); //modified
    ret[2] *= ret[3];
    ret[0] -= ret[2] / 2.0;
    ret[1] -= ret[3] / 2.0;

    return ret;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.