Skip to content

Import Service

app.application.services.tracking.import_service

View source code

Tracking layer import service — loads bounding-box data into layers C or D.

See Also

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

TrackingImportService

Bases: QObject

Loads persisted bounding-box data into tracking layers C or D.

Responsibilities
  • Read a JSON or CSV file produced by TrackingExportService (or any exporter that uses the shared wire format).
  • Apply the chosen ImportMode merge strategy.
  • Return the total number of boxes written.
Note

This service satisfies the IDataImporter interface Protocol via structural subtyping.

Layers C/D are the tracking layers. Writing detection-source boxes (BoxSource.DETECTION) into layer C is technically allowed by the data store but semantically unusual — the dialog restricts this by scoping the layer combo to C/D only.

Consider future improvement: after a successful import into layer C, automatically trigger Application.sync_tracking_cache() so that any downstream view model caches are refreshed without requiring the user to manually re-run tracking.

PARAMETER DESCRIPTION
app

Application used to resolve the destination session and replace imported tracking-layer data.

TYPE: Application

__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 tracking layer.

PARAMETER DESCRIPTION
s_id

Target session.

TYPE: SessionId

layer

Target layer — should be C or D (or their string equivalents).

TYPE: VideoDataLayer | str

file_path

Absolute path to a .json or .csv file.

TYPE: str

mode

Merge strategy (enum or string).

TYPE: ImportMode | 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.