Skip to content

Exporting

app.application.services.detection.exporting

View source code

Detection layer export service — serialises layers A or B to JSON / CSV.

See Also

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

DetectionExportService

Bases: QObject

Serialises detection layer data (A or B) to a file on disk.

Responsibilities
  • Retrieve all bounding boxes from the requested layer.
  • Write them as JSON or CSV (determined by file_path extension).
  • Return the number of boxes exported for status reporting.
Note

This service satisfies the IDataExporter interface Protocol via structural subtyping.

The output file can be re-imported by DetectionImportService (or even TrackingImportService) — the wire format is layer-agnostic.

Consider future improvement: add an optional frame-range filter (start_frame, end_frame) so users can export only a subset of frames, which is useful for long videos.

PARAMETER DESCRIPTION
app

Application adapted for session lookup and reading detection-layer boxes for export.

TYPE: Application

__init__(app: Application) -> None

export_layer(s_id: SessionId, layer: VideoDataLayer | str, file_path: str) -> int

Export all boxes in layer for s_id to file_path.

PARAMETER DESCRIPTION
s_id

Source session.

TYPE: SessionId

layer

Source layer — should be A or B (or their string equivalents).

TYPE: VideoDataLayer | str

file_path

Absolute destination path with .json or .csv extension.

TYPE: str

RETURNS DESCRIPTION
int

Number of boxes written.

TYPE: int

RAISES DESCRIPTION
ValueError

If the extension is not .json or .csv.

Note

Accepts both VideoDataLayer enums and string layer names ("a", "A", etc.) to handle Qt signal/slot type coercion. Internally coerces to enum.