Detector

class byotrack.api.detector.detector.Detector

Bases: ABC

Base class for detections in videos.

Detect on each frame the objects of interest.

abstractmethod run(video: Sequence[np.ndarray] | np.ndarray) Sequence[byotrack.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[np.ndarray] | np.ndarray) list[byotrack.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]

abstractmethod detect(batch: np.ndarray) Sequence[byotrack.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]

class byotrack.api.detector.detector.DetectionsRefiner

Bases: ABC

Abstract class for method to improve a coarse detection result.

This assumes the refining can be done independently for each frame.

Warning: The class is still experimental and may change in future versions

abstractmethod apply(detections: Detections, frame: ndarray | None = None) Detections

Refines Detections of the given frame.

Parameters:
  • detections (byotrack.Detections) – Detections to refine

  • frame (np.ndarray | None) – The associated frame of the video (optional) Shape: ([D, ]H, W, C) Default: None

Returns:

Refined detections

Return type:

byotrack.Detections

run(detections_sequence: Sequence[byotrack.Detections], video: Sequence[np.ndarray] | np.ndarray | None = None) list[byotrack.Detections]

Run the refiner on a full video / detections sequence.

Parameters:
  • detections_sequence (Sequence[byotrack.Detections]) – Sequence of T detections to refine

  • video (Sequence[np.ndarray] | np.ndarray | None) – Optional corresponding sequence of T frames. Each frame is expected to have a shape ([D, ]H, W, C)

Returns:

Sequence of the T refined detections

Return type:

Sequence[byotrack.Detections]