pub struct ImageProcessor;Expand description
Image processing utilities for the OAROCR pipeline.
Implementations§
Source§impl ImageProcessor
impl ImageProcessor
Sourcepub fn crop_bounding_box(
image: &RgbImage,
bbox: &BoundingBox,
) -> Result<RgbImage, OCRError>
pub fn crop_bounding_box( image: &RgbImage, bbox: &BoundingBox, ) -> Result<RgbImage, OCRError>
Crops an image based on a bounding box.
This function calculates the bounding rectangle of a polygonal bounding box and crops the image to that region. It handles edge cases like empty bounding boxes and ensures the crop region is within the image boundaries.
§Arguments
image- The source imagebbox- The bounding box defining the crop region
§Returns
A Result containing the cropped image or an OCRError
Sourcepub fn batch_crop_bounding_boxes(
image: &RgbImage,
bboxes: &[BoundingBox],
) -> Vec<Result<RgbImage, OCRError>>
pub fn batch_crop_bounding_boxes( image: &RgbImage, bboxes: &[BoundingBox], ) -> Vec<Result<RgbImage, OCRError>>
Efficiently crops multiple bounding boxes from the same source image.
This function is optimized for batch cropping operations, such as extracting multiple text regions from a document image. It processes all bounding boxes in a single pass and uses efficient cropping operations.
§Arguments
image- The source imagebboxes- A slice of bounding boxes to crop
§Returns
A vector of Results, each containing either a cropped image or an OCRError. The order corresponds to the input bounding boxes.
Sourcepub fn batch_crop_rotated_bounding_boxes(
image: &RgbImage,
bboxes: &[BoundingBox],
) -> Vec<Result<RgbImage, OCRError>>
pub fn batch_crop_rotated_bounding_boxes( image: &RgbImage, bboxes: &[BoundingBox], ) -> Vec<Result<RgbImage, OCRError>>
Efficiently crops multiple rotated bounding boxes from the same source image.
This function is optimized for batch cropping operations with perspective correction.
§Arguments
image- The source imagebboxes- A slice of bounding boxes to crop with rotation
§Returns
A vector of Results, each containing either a cropped image or an OCRError. The order corresponds to the input bounding boxes.
Sourcepub fn crop_rotated_bounding_box(
image: &RgbImage,
bbox: &BoundingBox,
) -> Result<RgbImage, OCRError>
pub fn crop_rotated_bounding_box( image: &RgbImage, bbox: &BoundingBox, ) -> Result<RgbImage, OCRError>
Crops and rectifies an image region using rotated crop with perspective transformation.
This function implements the same functionality as OpenCV’s GetRotateCropImage. It takes a bounding box (quadrilateral) and applies perspective transformation to rectify it into a rectangular image. This is particularly useful for text regions that may be rotated or have perspective distortion.
§Arguments
image- The source imagebbox- The bounding box defining the quadrilateral region
§Returns
A Result containing the rotated and cropped image or an OCRError
Auto Trait Implementations§
impl Freeze for ImageProcessor
impl RefUnwindSafe for ImageProcessor
impl Send for ImageProcessor
impl Sync for ImageProcessor
impl Unpin for ImageProcessor
impl UnwindSafe for ImageProcessor
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> 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.