Exporting
app.application.services.detection.exportingDetection layer export service — serialises layers A or B to JSON / CSV.
See Also
IDataExporter— defines the export contractserialize_layer_to_json— serializes layer records
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_pathextension). - 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:
|
__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:
|
layer
|
Source layer — should be
TYPE:
|
file_path
|
Absolute destination path with
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of boxes written.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the extension is not |
Note
Accepts both VideoDataLayer enums and string layer names ("a", "A", etc.)
to handle Qt signal/slot type coercion. Internally coerces to enum.