Skip to content

I/O API

trackers.io.video.frames_from_source(source)

Yield numbered BGR frames from video files, webcams, network streams, or image directories.

Parameters:

Name Type Description Default
source Union[str, Path, int]

Video file path, RTSP/HTTP stream URL, webcam index, or path to a directory containing images (.jpg, .jpeg, .png, .bmp, .tif, .tiff).

required

Returns:

Type Description
Iterator[tuple[int, ndarray]]

Iterator of (frame_id, frame) tuples where frame_id is 1-based and frame

Iterator[tuple[int, ndarray]]

is a np.ndarray in BGR format.

Raises:

Type Description
ValueError

Source cannot be opened or directory contains no supported images.

OSError

Image file exists but cannot be decoded / read.

RuntimeError

Capture read failure after successful open.