s6.utils.camera_identifier_aruco

Camera ID identifier using ArUco marker presence within rectangular regions.

This module provides CameraIDIdentifierAruco, a drop-in alternative to the intensity-ROI based s6.utils.camera_identifier.CameraIDIdentifier.

Instead of thresholding brightness, it detects ArUco markers from the cv2.aruco.DICT_4X4_50 dictionary and decides camera IDs by checking whether detected marker positions fall inside user-configured rectangular regions. Each configured rectangular region can be positive (must contain at least one detected ArUco center) or negative (must contain none) via negate. Cameras without any defined regions are treated as fallbacks and are assigned after region-constrained cameras are matched (useful when only some views contain ArUco markers).

The expected input frames are 8-bit single-channel images (H, W). The interface mirrors CameraIDIdentifier: from_json, load_default and order. It also provides identify for stabilizing an ID-to-index mapping across multiple frames.

class s6.utils.camera_identifier_aruco.CameraIDIdentifierAruco(rule_config: Dict[Any, List[Dict[str, Any]]], dictionary_id: int | None = None)

Bases: object

Identify camera IDs using ArUco detections within configured regions.

Parameters:
  • rule_config (dict[str | int, list[dict]]) – Mapping from camera ID (e.g., “R”, “B”, “L” or integer) to a list of rectangular region specs of the form {“type”: “rect”, “bbox”: (x1, y1, x2, y2), “negate”: bool}.

  • dictionary_id (int, default cv2.aruco.DICT_4X4_50) – ArUco dictionary used for detection.

static load_default() CameraIDIdentifierAruco

Load default config from configs/camera_ident.config.json.

Reuses the same ROI config file as the intensity-based identifier. The threshold entry is ignored.

static from_json(config_path: str = 'configs/camera_ident.config.json', dictionary_id: int | None = None) CameraIDIdentifierAruco

Create an identifier from a JSON configuration file.

The JSON is expected to contain a top-level rule_config mapping camera IDs to ROI specs (see class docstring). Any threshold value present in the file is ignored.

marker_count(image: ndarray) int

Return number of detected ArUco markers in an image.

has_aruco(image: ndarray) bool

Return True if at least one ArUco marker is detected.

identify(images: List[ndarray], stabilize_frames: int) Dict[Any, int]

Identify camera IDs and return mapping of ID -> image index.

Once stabilize_frames observations are collected, the most frequent mapping is fixed and reused for subsequent calls to identify and order.

order(images: List[ndarray]) Dict[Any, ndarray]

Identify camera IDs for images and return mapping id -> image.

If a fixed ID-to-index mapping has been established, it is used directly. Otherwise cameras with defined rectangular regions are matched first, and remaining images are assigned to cameras without defined regions (fallbacks).