sort

package module
v0.0.0-...-6c63bcc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2020 License: MIT Imports: 7 Imported by: 0

README

sort-tracking

SORT algorithm for online object tracking in videos with some enhancements.

Highly inpired on https://github.com/abewley/sort/blob/master/sort.py

This was a port to Golang mainly for performance reasons.

// go mod edit -replace github.com/go-chi/chi=./packages/chi

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Area

func Area(bbox []float64) float64

Area calculates area of a bounding box

func AreaMatch

func AreaMatch(bbox1 []float64, bbox2 []float64) float64

AreaMatch computes how close the areas from the two boxes are (0-1). 1-perfect match

func IOU

func IOU(bbox1 []float64, bbox2 []float64) float64

IOU Computes IUO (Intersection Over Union) between two bboxes in the form [x1,y1,x2,y2]

func RatioMatch

func RatioMatch(bbox1 []float64, bbox2 []float64) float64

RatioMatch computes how close the bbox dimensions from the two bboxes are (0-1). 1-perfect match

func ResizeFromCenter

func ResizeFromCenter(bbox []float64, scale float64) []float64

ResizeFromCenter resizes a bounding box by a scale factor from its center

Types

type KalmanBoxTracker

type KalmanBoxTracker struct {
	ID                    int64
	Updates               int
	Predicts              int
	PredictsSinceUpdate   int
	UpdatesWithoutPredict int
	SkipPredicts          int
	LastBBox              []float64
	LastBBoxIOU           []float64
	// history               [][]float64
	LastResiduals []float64
	KalmanFilter  kalman.Filter
	KalmanCtrl    *mat.VecDense
	KalmanCtx     *kalman.Context
}

KalmanBoxTracker This class represents the internel state of individual tracked objects observed as bbox.

func NewKalmanBoxTracker

func NewKalmanBoxTracker(bbox []float64) (KalmanBoxTracker, error)

NewKalmanBoxTracker Initialises a tracker using initial bounding box.

func (*KalmanBoxTracker) CurrentPrediction

func (k *KalmanBoxTracker) CurrentPrediction() []float64

CurrentPrediction get last prediction results

func (*KalmanBoxTracker) CurrentState

func (k *KalmanBoxTracker) CurrentState() []float64

CurrentState Returns the current bounding box estimate.

func (*KalmanBoxTracker) PredictNext

func (k *KalmanBoxTracker) PredictNext() []float64

PredictNext Advances the state vector and returns the predicted bounding box estimate.

func (*KalmanBoxTracker) Update

func (k *KalmanBoxTracker) Update(bbox []float64) ([]float64, error)

Update Updates the state vector with observed bbox Returns the residuals that is the difference between the real value (bbox) and the predicted value

type SORT

type SORT struct {
	Trackers   []*KalmanBoxTracker
	FrameCount int
	// contains filtered or unexported fields
}

SORT Detection tracking

func NewSORT

func NewSORT(maxPredictsWithoutUpdate int, minUpdatesUsePrediction int, iouThreshold float64) SORT

NewSORT initializes a new SORT tracking session

func (*SORT) Update

func (s *SORT) Update(dets [][]float64) error

Update update trackers from detections

Params:
  dets - a numpy array of detections in the format [[x1,y1,x2,y2,score],[x1,y1,x2,y2,score],...]
Requires: this method must be called once for each frame even with empty detections.
Returns the a similar array, where the last column is the object ID.
NOTE: The number of objects returned may differ from the number of detections provided.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL