pub struct TextRegion {
pub bounding_box: BoundingBox,
pub dt_poly: Option<BoundingBox>,
pub rec_poly: Option<BoundingBox>,
pub text: Option<Arc<str>>,
pub confidence: Option<f32>,
pub orientation_angle: Option<f32>,
pub word_boxes: Option<Vec<BoundingBox>>,
}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, orientation angle, and optional word-level boxes for fine-grained text localization. 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.
dt_poly: Option<BoundingBox>Detection polygon (dt_polys in overall OCR).
When available, this preserves the original detection polygon before any
layout-guided refinement. Defaults to the same as bounding_box.
rec_poly: Option<BoundingBox>Recognition polygon (rec_polys in overall OCR).
After layout-guided refinement, this may differ from dt_poly.
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.
word_boxes: Option<Vec<BoundingBox>>Word-level bounding boxes within this text region (optional). Only populated when word-level detection is enabled. Each box corresponds to a word or character in the recognized text.
Implementations§
Source§impl TextRegion
impl TextRegion
Sourcepub fn new(bounding_box: BoundingBox) -> TextRegion
pub fn new(bounding_box: BoundingBox) -> TextRegion
Creates a new TextRegion with the given bounding box.
The text, confidence, orientation_angle, and word_boxes are initially set to None.
Sourcepub fn with_recognition(
bounding_box: BoundingBox,
text: Option<Arc<str>>,
confidence: Option<f32>,
) -> TextRegion
pub fn with_recognition( bounding_box: BoundingBox, text: Option<Arc<str>>, confidence: Option<f32>, ) -> TextRegion
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>,
) -> TextRegion
pub fn with_all( bounding_box: BoundingBox, text: Option<Arc<str>>, confidence: Option<f32>, orientation_angle: Option<f32>, ) -> TextRegion
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 has_word_boxes(&self) -> bool
pub fn has_word_boxes(&self) -> bool
Returns true if this text region has word-level boxes.
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 moreSource§impl Debug for TextRegion
impl Debug for TextRegion
Source§impl<'de> Deserialize<'de> for TextRegion
impl<'de> Deserialize<'de> for TextRegion
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextRegion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextRegion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for TextRegion
impl Serialize for TextRegion
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto 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.