Skip to content

Batch Processor

app.application.services.detection.batch_processor

View source code

Batch processing collaborator for worker-produced detection results.

See Also

Layer: Application. Context: Coordinates domain state and infrastructure to complete application use cases.

DetectionBatchProcessReport dataclass

Batch counts; written_boxes counts filtered boxes retained in Layer A.

Layer: Application. Context: Coordinates use-case behavior through domain services and application contracts.

skipped_existing_frames: int instance-attribute

total_frames: int instance-attribute

written_boxes: int instance-attribute

written_frames: int instance-attribute

__init__(total_frames: int, skipped_existing_frames: int, written_frames: int, written_boxes: int) -> None

DetectionBatchProcessor

Store selected detections in Layer A and editable clones in Layer B.

Working principle

session = get_session(s_id)
for frame_index, raw_detections in batch:
    if session.has_boxes(Layer.A, frame_index):
        skip_frame()
        continue
    raw_boxes = map_detections_to_bbox(raw_detections)
    settings = get_session_settings(session)
    filtered_boxes = filter(raw_boxes, new_passes_filter, Layer.B, settings)
    session.add_boxes(Layer.A, frame_index, filtered_boxes)
    session.replace_machine_boxes(Layer.B, frame_index, filtered_boxes)
return DetectionBatchProcessReport(...)

PARAMETER DESCRIPTION
session_repo

Interface used to retrieve a session and write its frame-indexed detections.

TYPE: UIApplicationInterface

__init__(session_repo: UIApplicationInterface) -> None

process_batch(s_id: SessionId, batch: dict[int, list[DetectionResult]]) -> DetectionBatchProcessReport

Process batch.

PARAMETER DESCRIPTION
s_id

Identifier of the session receiving the detection results.

TYPE: SessionId

batch

Detection results keyed by zero-based frame index.

TYPE: dict[int, list[DetectionResult]]

RETURNS DESCRIPTION
DetectionBatchProcessReport

Counts of frames received, frames written, skipped frames, and boxes written.