Module narya.linker.basetrack

Expand source code
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
from collections import OrderedDict

"""

Cloned from https://github.com/Zhongdao/Towards-Realtime-MOT,

"""


class TrackState(object):
    New = 0
    Tracked = 1
    Lost = 2
    Removed = 3


class BaseTrack(object):
    _count = 0

    track_id = 0
    is_activated = False
    state = TrackState.New

    history = OrderedDict()
    features = []
    curr_feature = None
    score = 0
    start_frame = 0
    frame_id = 0
    time_since_update = 0

    # multi-camera
    location = (np.inf, np.inf)

    @property
    def end_frame(self):
        return self.frame_id

    @staticmethod
    def next_id():
        BaseTrack._count += 1
        return BaseTrack._count

    def activate(self, *args):
        raise NotImplementedError

    def predict(self):
        raise NotImplementedError

    def update(self, *args, **kwargs):
        raise NotImplementedError

    def mark_lost(self):
        self.state = TrackState.Lost

    def mark_removed(self):
        self.state = TrackState.Removed

Classes

class BaseTrack
Expand source code
class BaseTrack(object):
    _count = 0

    track_id = 0
    is_activated = False
    state = TrackState.New

    history = OrderedDict()
    features = []
    curr_feature = None
    score = 0
    start_frame = 0
    frame_id = 0
    time_since_update = 0

    # multi-camera
    location = (np.inf, np.inf)

    @property
    def end_frame(self):
        return self.frame_id

    @staticmethod
    def next_id():
        BaseTrack._count += 1
        return BaseTrack._count

    def activate(self, *args):
        raise NotImplementedError

    def predict(self):
        raise NotImplementedError

    def update(self, *args, **kwargs):
        raise NotImplementedError

    def mark_lost(self):
        self.state = TrackState.Lost

    def mark_removed(self):
        self.state = TrackState.Removed

Subclasses

Class variables

var curr_feature
var features
var frame_id
var history
var is_activated
var location
var score
var start_frame
var state
var time_since_update
var track_id

Static methods

def next_id()
Expand source code
@staticmethod
def next_id():
    BaseTrack._count += 1
    return BaseTrack._count

Instance variables

var end_frame
Expand source code
@property
def end_frame(self):
    return self.frame_id

Methods

def activate(self, *args)
Expand source code
def activate(self, *args):
    raise NotImplementedError
def mark_lost(self)
Expand source code
def mark_lost(self):
    self.state = TrackState.Lost
def mark_removed(self)
Expand source code
def mark_removed(self):
    self.state = TrackState.Removed
def predict(self)
Expand source code
def predict(self):
    raise NotImplementedError
def update(self, *args, **kwargs)
Expand source code
def update(self, *args, **kwargs):
    raise NotImplementedError
class TrackState
Expand source code
class TrackState(object):
    New = 0
    Tracked = 1
    Lost = 2
    Removed = 3

Class variables

var Lost
var New
var Removed
var Tracked