pub struct LayoutElement {
pub bbox: Rect<f32>,
pub element_type: String,
pub confidence: f32,
pub source: String,
pub text: Option<String>,
}
Expand description
A detected element in a document’s layout.
Fields§
§bbox: Rect<f32>
Bounding box of the element.
element_type: String
Type of element. This value depends on the labels of the model used to detect this element.
confidence: f32
§source: String
Source of the detection (the name of module which detected this element).
text: Option<String>
Text within this element. This field is filled after OCR.
Implementations§
Source§impl LayoutElement
impl LayoutElement
Sourcepub fn new(
x1: f32,
y1: f32,
x2: f32,
y2: f32,
element_type: &str,
confidence: f32,
source: &str,
) -> Self
pub fn new( x1: f32, y1: f32, x2: f32, y2: f32, element_type: &str, confidence: f32, source: &str, ) -> Self
Constructs a LayoutElement
instance.
Sourcepub fn new_with_text(
x1: f32,
y1: f32,
x2: f32,
y2: f32,
element_type: &str,
text: String,
confidence: f32,
source: &str,
) -> Self
pub fn new_with_text( x1: f32, y1: f32, x2: f32, y2: f32, element_type: &str, text: String, confidence: f32, source: &str, ) -> Self
Constructs a LayoutElement
instance with text.
Sourcepub fn pad(&mut self, padding: f32)
pub fn pad(&mut self, padding: f32)
Pads the bounding box of a LayoutElement
. Useful for OCRing the element.
Sourcepub fn crop_from_image(&self, img: &DynamicImage) -> DynamicImage
pub fn crop_from_image(&self, img: &DynamicImage) -> DynamicImage
Crop the section of the image according to the LayoutElement
’s bounding box.
Trait Implementations§
Source§impl Clone for LayoutElement
impl Clone for LayoutElement
Source§fn clone(&self) -> LayoutElement
fn clone(&self) -> LayoutElement
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for LayoutElement
impl RefUnwindSafe for LayoutElement
impl Send for LayoutElement
impl Sync for LayoutElement
impl Unpin for LayoutElement
impl UnwindSafe for LayoutElement
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
Mutably borrows from an owned value. Read more
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>
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 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>
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