cv2ext.tracking.trackers package

Module contents

Contains trackers implemented outside of OpenCV.

Classes

KLTTracker

A class for tracking objects in videos using the KLT algorithm.

KLTMultiTracker

A class for tracking multi objects in videos using the KLT algorithm.

class cv2ext.tracking.trackers.KLTMultiTracker(num_features: int = 750, window_size: tuple[int, int] = (15, 15), max_level: int = 2, criteria: tuple[int, int, float] = (3, 10, 0.03))[source]

Bases: AbstractMultiTracker

Class for tracking objects with the KLT algorithm.

init(image: np.ndarray, bboxes: list[tuple[int, int, int, int]]) None[source]

Initialize the tracker.

Parameters:
  • image (np.ndarray) – The image to track the object in.

  • bboxes (list[tuple[int, int, int, int]]) – The bounding boxes of the objects to track. In format: (x1, y1, x2, y2)

update(image: np.ndarray) list[tuple[bool, tuple[int, int, int, int]]][source]

Update the tracker.

Parameters:

image (np.ndarray) – The image to track the object in.

Returns:

A list of outputs of bool, tuple[int, int, int, int] Whether or not the track was successful and the bounding box bbox is format: (x1, y1, x2, y2)

Return type:

list[tuple[bool, tuple[int, int, int, int]]]

class cv2ext.tracking.trackers.KLTTracker(num_features: int = 500, window_size: tuple[int, int] = (15, 15), max_level: int = 2, criteria: tuple[int, int, float] = (3, 10, 0.03))[source]

Bases: AbstractTracker

Class for tracking objects with the KLT algorithm.

init(image: np.ndarray, bbox: tuple[int, int, int, int]) None[source]

Initialize the tracker.

Parameters:
  • image (np.ndarray) – The image to track the object in.

  • bbox (tuple[int, int, int, int]) – The bounding box of the object to track. In format: (x1, y1, x2, y2)

update(image: np.ndarray) tuple[bool, tuple[int, int, int, int]][source]

Update the tracker.

Parameters:

image (np.ndarray) – The image to track the object in.

Returns:

  • bool – Whether the update was successful.

  • tuple[int, int, int, int] – The bounding box of the object. In format: (x1, y1, x2, y2)