pub struct BoardLayout {
pub name: String,
pub pitch_mm: f32,
pub rows: usize,
pub long_row_cols: usize,
pub marker_outer_radius_mm: f32,
pub marker_inner_radius_mm: f32,
pub marker_ring_width_mm: f32,
/* private fields */
}Expand description
Runtime board layout used by the detector.
Describes the physical hex-lattice arrangement of ring markers: their
positions in millimeters, ring radii, ring width, and lattice parameters.
Load from a JSON file conforming to ringgrid.target.v4 schema, or use the
built-in default via BoardLayout::default().
§Example
use ringgrid::BoardLayout;
use std::path::Path;
let board = BoardLayout::from_json_file(Path::new("target.json")).unwrap();
println!("{} markers, pitch={} mm", board.n_markers(), board.pitch_mm);Fields§
§name: String§pitch_mm: f32§rows: usize§long_row_cols: usize§marker_outer_radius_mm: f32§marker_inner_radius_mm: f32§marker_ring_width_mm: f32Implementations§
Source§impl BoardLayout
impl BoardLayout
Sourcepub fn new(
pitch_mm: f32,
rows: usize,
long_row_cols: usize,
marker_outer_radius_mm: f32,
marker_inner_radius_mm: f32,
marker_ring_width_mm: f32,
) -> Result<Self, BoardLayoutValidationError>
pub fn new( pitch_mm: f32, rows: usize, long_row_cols: usize, marker_outer_radius_mm: f32, marker_inner_radius_mm: f32, marker_ring_width_mm: f32, ) -> Result<Self, BoardLayoutValidationError>
Construct a board layout from direct geometry arguments.
Uses a deterministic geometry-derived name so the layout can round-trip
through the canonical ringgrid.target.v4 JSON schema without requiring
the caller to supply a name up front.
Sourcepub fn with_name<S: Into<String>>(
name: S,
pitch_mm: f32,
rows: usize,
long_row_cols: usize,
marker_outer_radius_mm: f32,
marker_inner_radius_mm: f32,
marker_ring_width_mm: f32,
) -> Result<Self, BoardLayoutValidationError>
pub fn with_name<S: Into<String>>( name: S, pitch_mm: f32, rows: usize, long_row_cols: usize, marker_outer_radius_mm: f32, marker_inner_radius_mm: f32, marker_ring_width_mm: f32, ) -> Result<Self, BoardLayoutValidationError>
Construct a named board layout from direct geometry arguments.
Sourcepub fn xy_mm(&self, id: usize) -> Option<[f32; 2]>
pub fn xy_mm(&self, id: usize) -> Option<[f32; 2]>
Look up board coordinates (x, y) in mm for a given marker ID.
Sourcepub fn marker(&self, id: usize) -> Option<&BoardMarker>
pub fn marker(&self, id: usize) -> Option<&BoardMarker>
Look up a marker by ID.
Sourcepub fn markers(&self) -> &[BoardMarker]
pub fn markers(&self) -> &[BoardMarker]
Borrow all markers as a read-only slice.
Sourcepub fn marker_by_index(&self, index: usize) -> Option<&BoardMarker>
pub fn marker_by_index(&self, index: usize) -> Option<&BoardMarker>
Look up a marker by storage index.
Sourcepub fn marker_outer_radius_mm(&self) -> f32
pub fn marker_outer_radius_mm(&self) -> f32
Marker outer radius in board units (mm).
Sourcepub fn marker_inner_radius_mm(&self) -> f32
pub fn marker_inner_radius_mm(&self) -> f32
Marker inner radius in board units (mm).
Sourcepub fn marker_ring_width_mm(&self) -> f32
pub fn marker_ring_width_mm(&self) -> f32
Marker ring width in board units (mm).
Sourcepub fn marker_ids(&self) -> impl Iterator<Item = usize> + '_
pub fn marker_ids(&self) -> impl Iterator<Item = usize> + '_
Iterator over all marker IDs present on the board.
Sourcepub fn max_marker_id(&self) -> usize
pub fn max_marker_id(&self) -> usize
Maximum marker ID present on the board.
Sourcepub fn marker_bounds_mm(&self) -> Option<([f32; 2], [f32; 2])>
pub fn marker_bounds_mm(&self) -> Option<([f32; 2], [f32; 2])>
Axis-aligned marker bounds in board mm.
Returns (min_xy, max_xy) over marker centers.
Sourcepub fn marker_span_mm(&self) -> Option<[f32; 2]>
pub fn marker_span_mm(&self) -> Option<[f32; 2]>
Axis-aligned marker span in board mm ([width, height]).
Sourcepub fn from_json_file(path: &Path) -> Result<Self, BoardLayoutLoadError>
pub fn from_json_file(path: &Path) -> Result<Self, BoardLayoutLoadError>
Load a board layout from a JSON file.
Sourcepub fn from_json_str(data: &str) -> Result<Self, BoardLayoutLoadError>
pub fn from_json_str(data: &str) -> Result<Self, BoardLayoutLoadError>
Load a board layout from a JSON string.
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Serialize the layout as canonical ringgrid.target.v4 JSON.
Source§impl BoardLayout
impl BoardLayout
Sourcepub fn render_target_svg(
&self,
options: &SvgTargetOptions,
) -> Result<String, TargetGenerationError>
pub fn render_target_svg( &self, options: &SvgTargetOptions, ) -> Result<String, TargetGenerationError>
Render a printable SVG target.
Input marker centers stay in normalized board millimeters with marker
id=0 anchored at [0, 0]. The returned SVG translates those markers
into a square page in millimeters with top-left origin and +y
increasing downward.
Sourcepub fn write_target_svg(
&self,
path: &Path,
options: &SvgTargetOptions,
) -> Result<(), TargetGenerationError>
pub fn write_target_svg( &self, path: &Path, options: &SvgTargetOptions, ) -> Result<(), TargetGenerationError>
Write a printable SVG target to disk.
Sourcepub fn render_target_png(
&self,
options: &PngTargetOptions,
) -> Result<GrayImage, TargetGenerationError>
pub fn render_target_png( &self, options: &PngTargetOptions, ) -> Result<GrayImage, TargetGenerationError>
Render a printable PNG target.
The raster uses integer pixel centers, matching the existing Python target generator’s sampling convention.
Sourcepub fn write_target_png(
&self,
path: &Path,
options: &PngTargetOptions,
) -> Result<(), TargetGenerationError>
pub fn write_target_png( &self, path: &Path, options: &PngTargetOptions, ) -> Result<(), TargetGenerationError>
Write a printable PNG target to disk.
This always writes PNG bytes and embeds the requested dpi as PNG
physical pixel dimensions (pHYs) so the output preserves print scale.
Trait Implementations§
Source§impl Clone for BoardLayout
impl Clone for BoardLayout
Source§fn clone(&self) -> BoardLayout
fn clone(&self) -> BoardLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoardLayout
impl Debug for BoardLayout
Auto Trait Implementations§
impl Freeze for BoardLayout
impl RefUnwindSafe for BoardLayout
impl Send for BoardLayout
impl Sync for BoardLayout
impl Unpin for BoardLayout
impl UnsafeUnpin for BoardLayout
impl UnwindSafe for BoardLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.