Skip to content

Detection Engine Adapter

app.infrastructure.adapters.detection_engine_adapter

View source code

Explicit adapter wrapping DetectionEngine to DetectionEngineInterface.

See Also

Layer: Infrastructure. Context: Implements concrete processing and I/O behind application-facing contracts.

DetectionEngineAdapter

Bases: DetectionEngineInterface

Explicit adapter that wraps a concrete DetectionEngine instance and exposes the DetectionEngineInterface contract.

In normal usage the concrete DetectionEngine already satisfies DetectionEngineInterface via structural subtyping (Protocol), so this adapter is not required for runtime correctness. It exists to:

  • Provide an explicit, named boundary at the infrastructure/application seam.
  • Enable test doubles that replace the real model without subclassing DetectionEngine.
  • Act as the canonical reference implementation of the interface.
PARAMETER DESCRIPTION
engine

Concrete detection engine delegated to by this adapter.

TYPE: DetectionEngine

model_name: str property

Return the configured detection model name.

RETURNS DESCRIPTION
str

Name of the model currently loaded by the wrapped engine.

__init__(engine: DetectionEngine) -> None

detect(frame: np.ndarray) -> list[DetectionResult]

Run detection on the supplied frame.

PARAMETER DESCRIPTION
frame

RGB image array to pass to the wrapped engine.

TYPE: ndarray

RETURNS DESCRIPTION
list[DetectionResult]

Detection results produced by the wrapped engine.

set_model(model_name: str) -> None

Load and select a different detection model.

PARAMETER DESCRIPTION
model_name

Registered name of the model to load.

TYPE: str