Importing
app.application.services.detection.importingDetection layer import service — loads bounding-box data into layers A or B.
See Also
IDataImporter— defines the import contractImportMode— selects how imported boxes merge with existing data
Layer: Application. Context: Coordinates domain state and infrastructure to complete application use cases.
DetectionImportService
Bases: QObject
Loads persisted bounding-box data into detection layers A or B.
Responsibilities
- Read a JSON or CSV file produced by
DetectionExportService. - Apply the chosen
ImportModemerge strategy viaapply_import_to_layer. - Return the total number of boxes written for status reporting.
Note
This service satisfies the IDataImporter interface
Protocol via structural subtyping — no explicit inheritance is needed.
Layers A/B are the detection layers. Do not use this service to write
to tracking layers C/D; use TrackingImportService instead.
The file_path extension determines the format:
.json → JSON deserialiser
.csv → CSV deserialiser
Anything else raises ValueError.
Consider future improvement: add progress callbacks for very large files (millions of boxes across thousands of frames), similar to how the detection/export workers report progress today.
| PARAMETER | DESCRIPTION |
|---|---|
app
|
Application adapted for resolving sessions and writing imported detection-layer boxes.
TYPE:
|
__init__(app: Application) -> None
import_layer(s_id: SessionId, layer: VideoDataLayer | str, file_path: str, mode: ImportMode | str) -> int
Import bounding-box data from file_path into layer.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Target session.
TYPE:
|
layer
|
Target layer — should be
TYPE:
|
file_path
|
Absolute path to a
TYPE:
|
mode
|
Merge strategy (enum or string).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of boxes written.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
FileNotFoundError
|
If |
Note
Accepts both VideoDataLayer enums and string layer names to handle
Qt signal/slot type coercion.