chalkydri_apriltags

Struct Detector

Source
pub struct Detector {
    pub(crate) bufs: DetectorBufs,
    pub(crate) valid_tags: &'static [usize],
    pub(crate) points_len: AtomicUsize,
    pub(crate) lines: Vec<(usize, usize, usize, usize)>,
    pub(crate) width: usize,
    pub(crate) height: usize,
}
Expand description

An AprilTag detector

This is the main entrypoint.

Fields§

§bufs: DetectorBufs

Raw buffers used by the detector

§valid_tags: &'static [usize]§points_len: AtomicUsize§lines: Vec<(usize, usize, usize, usize)>

Checked edges (x1, y1, x2, y2)

§width: usize

Width of input frames

§height: usize

Height of input frames

Implementations§

Source§

impl Detector

Source

pub fn new(width: usize, height: usize, valid_tags: &'static [usize]) -> Self

Initialize a new detector for the specified dimensions

valid_tags is required for optimization and error resistance.

Source

pub fn calc_otsu(&mut self, input: &[u8])

Calculate otsu value

Otsu’s method is an adaptive thresholding algorithm. In English: it turns a grayscale image into binary (foreground/background, black/white).

We should investigate combining the variations for unbalanced images and triclass thresholding.

Source

pub fn process_frame(&mut self, input: &[u8])

Process an RGB frame

FAST needs a 3x3 circle around each pixel, so we only process pixels within a 3x3 pixel padding.

Source

pub fn detect_corners(&mut self)

Run corner detection

Source

pub unsafe fn thresh(&self, input: &[u8])

Threshold an input RGB buffer

TODO: This needs to use Self::calc_otsu.

§Safety

input is treated as an RGB buffer, even if it isn’t. The caller should check that input is an RGB buffer.

Source

pub(crate) unsafe fn process_pixel(&self, x: usize, y: usize)

Process a pixel

This should have as little overhead as possible, as it must be run hundreds of thousands of times for each frame.

§Safety

(x, y) is assumed to be a valid pixel coord. The caller must make sure of this.

Source

pub(crate) unsafe fn check_edge( &mut self, x1: usize, y1: usize, x2: usize, y2: usize, )

Check a single edge (imaginary line between two corners)

See Self::check_edges.

§Safety

(x1, y1) and (x2, y2) are assumed to be a valid pixel coords. The caller must make sure of this.

Source

pub fn check_edges(&mut self)

Perform edge checking on all detected corners

Source

pub fn draw(&self)

Trait Implementations§

Source§

impl Clone for Detector

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Detector

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.