pub struct TextRegion {
pub bounding_box: BoundingBox,
pub text: Option<Arc<str>>,
pub confidence: Option<f32>,
pub orientation_angle: Option<f32>,
}Expand description
A text region containing detection and recognition results.
This struct groups together all the information related to a single detected text region, including the bounding box, recognized text, confidence score, and orientation angle. This design eliminates the need for parallel vectors and provides better ergonomics for iterating over text regions.
Fields§
§bounding_box: BoundingBoxThe bounding box of the detected text region.
text: Option<Arc<str>>The recognized text, if recognition was successful. None indicates that recognition failed or was filtered out due to low confidence.
confidence: Option<f32>The confidence score for the recognized text. None indicates that recognition failed or was filtered out due to low confidence.
orientation_angle: Option<f32>The text line orientation angle, if orientation classification was performed. None indicates that orientation classification was not performed or failed.
Implementations§
Source§impl TextRegion
impl TextRegion
Sourcepub fn new(bounding_box: BoundingBox) -> Self
pub fn new(bounding_box: BoundingBox) -> Self
Creates a new TextRegion with the given bounding box.
The text, confidence, and orientation_angle are initially set to None.
Sourcepub fn with_recognition(
bounding_box: BoundingBox,
text: Option<Arc<str>>,
confidence: Option<f32>,
) -> Self
pub fn with_recognition( bounding_box: BoundingBox, text: Option<Arc<str>>, confidence: Option<f32>, ) -> Self
Creates a new TextRegion with detection and recognition results.
Sourcepub fn with_all(
bounding_box: BoundingBox,
text: Option<Arc<str>>,
confidence: Option<f32>,
orientation_angle: Option<f32>,
) -> Self
pub fn with_all( bounding_box: BoundingBox, text: Option<Arc<str>>, confidence: Option<f32>, orientation_angle: Option<f32>, ) -> Self
Creates a new TextRegion with all fields specified.
Sourcepub fn has_confidence(&self) -> bool
pub fn has_confidence(&self) -> bool
Returns true if this text region has a confidence score.
Sourcepub fn has_orientation(&self) -> bool
pub fn has_orientation(&self) -> bool
Returns true if this text region has an orientation angle.
Sourcepub fn text_with_confidence(&self) -> Option<(&str, f32)>
pub fn text_with_confidence(&self) -> Option<(&str, f32)>
Returns the text and confidence as a tuple if both are available.
Trait Implementations§
Source§impl Clone for TextRegion
impl Clone for TextRegion
Source§fn clone(&self) -> TextRegion
fn clone(&self) -> TextRegion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TextRegion
impl RefUnwindSafe for TextRegion
impl Send for TextRegion
impl Sync for TextRegion
impl Unpin for TextRegion
impl UnwindSafe for TextRegion
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<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.