Detector

class byotrack.api.detector.detector.Detector

Bases: ABC, ParametrizedObjectMixin

Base class for detections in videos

Detect on each frame the objects of interest.

Each detector can define a set of parameters (See ParametrizedObjectMixin)

abstract run(video: Sequence[ndarray] | ndarray) Sequence[Detections]

Run the detector on a whole video

Parameters:

video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)

Returns:

Detections for each frame (ordered by frames)

Return type:

Sequence[byotrack.Detections]

class byotrack.api.detector.detector.BatchDetector(batch_size=20, add_true_frames=False)

Bases: Detector

Abstract detector that performs detection directly by batch

Usually leads to faster implementation of the detection process when batch size is greater than 1

batch_size

Size of the frame batch Default: 20

Type:

int

add_true_frames

If the input is a Video, it will exploits the VideoReader knowledge to extract the true frame id for each detections. If False, it will register the index of the frame as the frame_id Default: False

Type:

bool

run(video: Sequence[ndarray] | ndarray) List[Detections]

Run the detector on a whole video

Parameters:

video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)

Returns:

Detections for each frame (ordered by frames)

Return type:

Sequence[byotrack.Detections]

abstract detect(batch: ndarray) Sequence[Detections]

Apply the detection on a batch of frames

By default, the frame ids are set from 0 to n-1 with n the size of the batch. The aggregattion of batches and frame ids correction is automatically handled when called the run method.

Parameters:

batch (np.ndarray) – Batch of video frames Shape: (B, [D, ]H, W, C)

Returns:

Detections for each given frame

Return type:

Sequence[byotrack.Detections]