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
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
impl Detector
Sourcepub fn new(width: usize, height: usize, valid_tags: &'static [usize]) -> Self
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.
Sourcepub fn calc_otsu(&mut self, input: &[u8])
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.
Sourcepub fn process_frame(&mut self, input: &[u8])
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.
Sourcepub fn detect_corners(&mut self)
pub fn detect_corners(&mut self)
Run corner detection
Sourcepub unsafe fn thresh(&self, input: &[u8])
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.
Sourcepub(crate) unsafe fn process_pixel(&self, x: usize, y: usize)
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.
Sourcepub(crate) unsafe fn check_edge(
&mut self,
x1: usize,
y1: usize,
x2: usize,
y2: usize,
)
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.
Sourcepub fn check_edges(&mut self)
pub fn check_edges(&mut self)
Perform edge checking on all detected corners
pub fn draw(&self)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Detector
impl RefUnwindSafe for Detector
impl Send for Detector
impl Sync for Detector
impl Unpin for Detector
impl UnwindSafe for Detector
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> 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 more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.