Skip to content

Export Service

app.application.services.tracking.export_service

View source code

Tracking layer export service — serialises layers C or D to JSON / CSV.

See Also

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

TrackingExportService

Bases: QObject

Serialises tracking layer data (C or D) to a file on disk.

Responsibilities
  • Retrieve all bounding boxes from the requested tracking 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 is produced using the same shared wire format as DetectionExportService, so files can be cross-imported between detection and tracking layers when the user explicitly chooses to do so via the dialog.

Consider future improvement: add a has_data(s_id, layer) -> bool helper that the handler can call before opening the save-file dialog, surfacing a friendly warning when the user tries to export an empty layer.

PARAMETER DESCRIPTION
app

Application used to resolve sessions and read tracking-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 tracking layer for s_id to file_path.

PARAMETER DESCRIPTION
s_id

Source session.

TYPE: SessionId

layer

Source layer — should be C or D (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

Note

Accepts both VideoDataLayer enums and string layer names to handle Qt signal/slot type coercion.