acia.crop_capture#

Persist manual crops as reloadable specs plus training-data captures.

This module supports the “capture-as-you-go flywheel”: each capture saves the full (uncropped) source frame as a normalized 8-bit grayscale PNG together with a sidecar *.json holding a RotatedCropSpec as an oriented (rotated) box label, provenance, and the image shape. Captures are auto-enumerated into a dataset directory (0000.png/0000.json, 0001.*, …). A loader reconstructs the RotatedCropSpec so a parameterized/batch run can re-crop without any widget.

acia.crop_capture.save_crop_capture(source, spec, dataset_dir, *, frame=0, channel=None, clip_percentiles=None, source_ref=None)[source]#

Save a full-frame training image plus a rotated-box crop spec.

The full (uncropped) source frame is rendered, normalized to an 8-bit grayscale PNG, and written next to a JSON sidecar describing the crop as an oriented (rotated) box label with provenance and image shape. Files are auto-enumerated with a 4-digit zero-padded index.

Parameters:
  • source (ImageSequenceSource) – The image sequence source to render the full frame from.

  • spec (RotatedCropSpec) – The rotated crop specification to persist as the label.

  • dataset_dir (str | Path) – Directory the capture is written to (created if missing).

  • frame (int) – Index of the frame to render. Defaults to 0.

  • channel (int | None) – Channel to select for grayscale rendering when the frame is multi-channel. Defaults to channel 0 when None.

  • clip_percentiles (tuple[float, float] | None) – Optional (low, high) percentiles for clipping before normalization.

  • source_ref (str | None) – Explicit provenance string. When None, provenance is auto-detected from source.filename then source.imageId; otherwise stored as null.

Returns:

dict{"index": int, "image": Path, "json": Path} for the capture.

Return type:

dict[str, object]

acia.crop_capture.load_crop_spec(json_path)[source]#

Reconstruct a RotatedCropSpec from a capture’s JSON sidecar.

Parameters:

json_path (str | Path) – Path to a *.json capture sidecar.

Returns:

RotatedCropSpec – The reconstructed crop specification.

Raises:
Return type:

RotatedCropSpec