tracker

package
v0.0.0-...-2c0f3e6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LARGE = 1000000.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BYTETracker

type BYTETracker struct {
	// contains filtered or unexported fields
}

BYTETracker represents the BYTE Tracker

func NewBYTETracker

func NewBYTETracker(frameRate int, trackBuffer int, trackThresh float32,
	highThresh float32, matchThresh float32) *BYTETracker

NewBYTETracker initializes and returns a new BYTETracker

func (*BYTETracker) Reset

func (bt *BYTETracker) Reset()

Reset clears the tracked data and resets everything

func (*BYTETracker) Update

func (bt *BYTETracker) Update(objects []Object) ([]*STrack, error)

Update updates the tracker with new detections

type DetectBox

type DetectBox []float32

DetectBox represents a 1x4 matrix using a slice of float32

type KalmanFilter

type KalmanFilter struct {
	// contains filtered or unexported fields
}

KalmanFilter represents the Kalman filter

func NewKalmanFilter

func NewKalmanFilter(stdWeightPosition, stdWeightVelocity float32) *KalmanFilter

NewKalmanFilter initializes and returns a new KalmanFilter

func (*KalmanFilter) Initiate

func (kf *KalmanFilter) Initiate(mean StateMean, covariance *StateCov,
	measurement DetectBox)

Initiate initializes the state mean and covariance

func (*KalmanFilter) Predict

func (kf *KalmanFilter) Predict(mean StateMean, covariance *StateCov)

Predict predicts the next state mean and covariance

func (*KalmanFilter) Update

func (kf *KalmanFilter) Update(mean StateMean, covariance *StateCov,
	measurement DetectBox) error

Update updates the state mean and covariance

type Object

type Object struct {
	// Rect is the bounding box representation of the detected object
	Rect Rect
	// Label is the class label of the object detected
	Label int
	// Prob is the confidence/probability of the object detected
	Prob float32
	// ID is a unique ID to give this object which can be used to match
	// the input detection object and tracked object
	ID int64
}

Object represents an object detected in ByteTrack

func NewObject

func NewObject(rect Rect, label int, prob float32, id int64) Object

NewObject is a constructor function for the Object struct

type Point

type Point struct {
	X, Y int
}

Point represents the x,y coordinates of the center box of a tracking rect/bounding box results

type Rect

type Rect struct {
	Tlwh Tlwh
}

Rect represents a rectangle with Tlwh (top, left, width, height) format

func GenerateRectByTlbr

func GenerateRectByTlbr(tlbr Tlbr) Rect

GenerateRectByTlbr creates a Rect from Tlbr (top, left, bottom, right) format

func GenerateRectByXyah

func GenerateRectByXyah(xyah Xyah) Rect

GenerateRectByXyah creates a Rect from Xyah (center x, center y, aspect ratio, height) format

func NewRect

func NewRect(x, y, width, height float32) Rect

NewRect creates a new Rect with given coordinates

func (*Rect) BRX

func (r *Rect) BRX() float32

BRX returns the bottom-right x coordinate of the rectangle

func (*Rect) BRY

func (r *Rect) BRY() float32

BRY returns the bottom-right y coordinate of the rectangle

func (*Rect) CalcIoU

func (r *Rect) CalcIoU(other Rect) float32

CalcIoU calculates the Intersection over Union (IoU) with another rectangle

func (*Rect) GetTlbr

func (r *Rect) GetTlbr() Tlbr

GetTlbr converts the rectangle to Tlbr (top, left, bottom, right) format

func (*Rect) GetXyah

func (r *Rect) GetXyah() Xyah

GetXyah converts the rectangle to Xyah (center x, center y, aspect ratio, height) format

func (*Rect) Height

func (r *Rect) Height() float32

Height returns the height of the rectangle

func (*Rect) SetHeight

func (r *Rect) SetHeight(height float32)

SetHeight sets the height of the rectangle

func (*Rect) SetWidth

func (r *Rect) SetWidth(width float32)

SetWidth sets the width of the rectangle

func (*Rect) SetX

func (r *Rect) SetX(x float32)

SetX sets the x coordinate of the rectangle

func (*Rect) SetY

func (r *Rect) SetY(y float32)

SetY sets the y coordinate of the rectangle

func (*Rect) TLX

func (r *Rect) TLX() float32

TLX returns the top-left x coordinate of the rectangle

func (*Rect) TLY

func (r *Rect) TLY() float32

TLY returns the top-left y coordinate of the rectangle

func (*Rect) Width

func (r *Rect) Width() float32

Width returns the width of the rectangle

func (*Rect) X

func (r *Rect) X() float32

X returns the x coordinate of the rectangle

func (*Rect) Y

func (r *Rect) Y() float32

Y returns the y coordinate of the rectangle

type STrack

type STrack struct {
	// contains filtered or unexported fields
}

STrack represents a single track of an object

func NewSTrack

func NewSTrack(rect Rect, score float32, detectionID int64, label int) *STrack

NewSTrack creates a new STrack

func (*STrack) Activate

func (s *STrack) Activate(frameID, trackID int)

Activate initializes the track with the given frame ID and track ID

func (*STrack) GetDetectionID

func (s *STrack) GetDetectionID() int64

GetDetectionID returns the unique ID for the detection

func (*STrack) GetFrameID

func (s *STrack) GetFrameID() int

GetFrameID returns the current frame ID

func (*STrack) GetLabel

func (s *STrack) GetLabel() int

GetLabel returns the object label/class from YOLO inference

func (*STrack) GetRect

func (s *STrack) GetRect() *Rect

GetRect returns the bounding box of the tracked object

func (*STrack) GetSTrackState

func (s *STrack) GetSTrackState() STrackState

GetSTrackState returns the current state of the track

func (*STrack) GetScore

func (s *STrack) GetScore() float32

GetScore returns the detection score

func (*STrack) GetStartFrameID

func (s *STrack) GetStartFrameID() int

GetStartFrameID returns the frame ID when the track started

func (*STrack) GetTrackID

func (s *STrack) GetTrackID() int

GetTrackID returns the unique ID for the track

func (*STrack) GetTrackletLength

func (s *STrack) GetTrackletLength() int

GetTrackletLength returns the length of the tracklet

func (*STrack) IsActivated

func (s *STrack) IsActivated() bool

IsActivated returns whether the track is activated

func (*STrack) MarkAsLost

func (s *STrack) MarkAsLost()

MarkAsLost marks the track as lost

func (*STrack) MarkAsRemoved

func (s *STrack) MarkAsRemoved()

MarkAsRemoved marks the track as removed

func (*STrack) Predict

func (s *STrack) Predict()

Predict predicts the next state of the track

func (*STrack) ReActivate

func (s *STrack) ReActivate(newTrack *STrack, frameID, newTrackID int)

ReActivate reinitializes the track with a new detection

func (*STrack) Update

func (s *STrack) Update(newTrack *STrack, frameID int) error

Update updates the track with a new detection

type STrackState

type STrackState int

STrackState represents the state of a tracked object

const (
	// Object is newly detected
	New STrackState = 0
	// Object is currently being tracked
	Tracked STrackState = 1
	// Object has been lost
	Lost STrackState = 2
	// Object has been removed
	Removed STrackState = 3
)

type StateCov

type StateCov struct {
	*mat.Dense
}

StateCov represents an 8x8 matrix

type StateHCov

type StateHCov struct {
	*mat.SymDense
}

StateHCov represents a 4x4 matrix

type StateHMean

type StateHMean []float32

StateHMean represents a 1x4 matrix using a slice of float32

type StateMean

type StateMean []float32

StateMean represents a 1x8 matrix using a slice of float32

type Tlbr

type Tlbr []float32

Tlbr (top, left, bottom, right) represents a 1x4 matrix

type Tlwh

type Tlwh []float32

Tlwh (top, left, width, height) represents a 1x4 matrix

type Track

type Track struct {
	// contains filtered or unexported fields
}

Track represents a track history

type Trail

type Trail struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Trail is the struct to keep a history of Track results used for drawing a trail

func NewTrail

func NewTrail(size int) *Trail

NewTrail returns a new trail history track instance. Size is the number of most recent trails to keep and specifies the maximum length of the trail to maintain

func (*Trail) Add

func (t *Trail) Add(strack *STrack)

Add a track to the history

func (*Trail) GetPoints

func (t *Trail) GetPoints(id int) []Point

GetPoints gets the point history for a specific track id

func (*Trail) Reset

func (t *Trail) Reset()

Reset clears all history

type Xyah

type Xyah []float32

Xyah (center x, center y, aspect ratio, height) represents a 1x4 matrix

Jump to

Keyboard shortcuts

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