Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MarkerScalePrior

MarkerScalePrior tells the detector the expected range of marker outer diameters in working-frame pixels. This single prior drives the derivation of proposal search radii, edge sampling extent, ellipse validation bounds, completion ROI size, and projective-center shift gates.

Fields

FieldTypeDefaultDescription
diameter_min_pxf3214.0Minimum expected marker outer diameter in pixels.
diameter_max_pxf3266.0Maximum expected marker outer diameter in pixels.

Constructors

#![allow(unused)]
fn main() {
use ringgrid::MarkerScalePrior;

// Explicit range
let scale = MarkerScalePrior::new(24.0, 48.0);

// Fixed size (min == max)
let scale = MarkerScalePrior::from_nominal_diameter_px(32.0);
}

new(min, max) accepts any order; normalization swaps values if min > max and enforces a hard floor of 4.0 px on both bounds.

from_nominal_diameter_px(d) sets both diameter_min_px and diameter_max_px to d, producing a fixed-size prior. The same 4.0 px floor applies.

Normalization

Every constructor and accessor normalizes the stored range:

  1. Non-finite values are replaced with the corresponding default (14.0 or 66.0).
  2. If min > max, the two are swapped.
  3. min is clamped to at least 4.0 px.
  4. max is clamped to at least min.

The normalized() method returns a normalized copy without mutating the original.

Methods

MethodReturnDescription
diameter_range_px()[f32; 2]Normalized [min, max] diameter in pixels.
nominal_diameter_px()f32Midpoint of the range: 0.5 * (min + max).
nominal_outer_radius_px()f32Half of nominal diameter: 0.25 * (min + max).

Scale-dependent derivation

When a DetectConfig is constructed (or set_marker_scale_prior() is called), the scale prior drives the following parameter derivations. Let r_min = diameter_min_px / 2, r_max = diameter_max_px / 2, r_nom = (r_min + r_max) / 2, and d_nom = r_min + r_max:

Proposal search radii

Derived fieldFormula
proposal.r_minmax(0.4 * r_min, 2.0)
proposal.r_max1.7 * r_max
proposal.nms_radiusmax(0.8 * r_min, 2.0)

Edge sampling range

Derived fieldFormula
edge_sample.r_max2.0 * r_max
edge_sample.r_min1.5 (fixed)

Outer estimation

Derived fieldFormula
outer_estimation.theta_samplesset to edge_sample.n_rays
outer_estimation.search_halfwidth_pxmax(max((r_max - r_min) * 0.5, 2.0), base_default)

Ellipse validation bounds

Derived fieldFormula
min_semi_axismax(0.3 * r_min, 2.0)
max_semi_axismax(2.5 * r_max, min_semi_axis)

Completion ROI

Derived fieldFormula
completion.roi_radius_pxclamp(0.75 * d_nom, 24.0, 80.0)

Projective center shift gate

Derived fieldFormula
projective_center.max_center_shift_pxSome(2.0 * r_nom)

Usage guidance

  • All markers roughly the same size: use from_nominal_diameter_px(d). This sets both bounds equal, producing tight proposal search and validation windows. Measure d as the outer ring diameter in pixels at the typical working distance.

  • Markers vary in apparent size (perspective, varying distance): use new(min, max) with the smallest and largest expected diameters. This widens search and validation windows to accommodate the range. A wider range makes detection more permissive but may increase false positives.

  • Unsure about scale: start with the default (14–66 px) and inspect detection results. Narrow the range once you know the actual marker sizes in your images.

  • Post-construction update: call config.set_marker_scale_prior(new_scale) or config.set_marker_diameter_hint_px(d) to re-derive all coupled parameters without rebuilding the full config.

  • Very wide scale variation: use adaptive multi-scale methods (Detector::detect_adaptive, Detector::detect_adaptive_with_hint, or Detector::detect_multiscale) instead of forcing one very wide prior.

Source

crates/ringgrid/src/detector/config.rs