pub struct OcrUtils;Implementations§
Source§impl OcrUtils
impl OcrUtils
pub fn substract_mean_normalize( img_src: &RgbImage, mean_vals: &[f32], norm_vals: &[f32], ) -> Array4<f32>
pub fn make_padding( img_src: &RgbImage, padding: u32, ) -> Result<RgbImage, OcrError>
pub fn get_part_images( img_src: &RgbImage, text_boxes: &[TextBox], ) -> Vec<RgbImage> ⓘ
pub fn get_rotate_crop_image( img_src: &RgbImage, box_points: &[Point], ) -> RgbImage
pub fn mat_rotate_clock_wise_180(src: &mut RgbImage)
pub fn calculate_mean_with_mask( img: &ImageBuffer<Luma<f32>, Vec<f32>>, mask: &ImageBuffer<Luma<u8>, Vec<u8>>, ) -> f32
Sourcepub fn polygon_centroid(points: &[Point]) -> (u32, u32)
pub fn polygon_centroid(points: &[Point]) -> (u32, u32)
Centroide (x, y) di un poligono. Usato per associare text-block a
layout-box (containment via centroid + nearest-neighbor su orphan).
Ritorna (0, 0) se il poligono è vuoto.
Sourcepub fn inverse_warp_quad(
line_polygon: &[Point; 4],
crop_size: (u32, u32),
quad_in_crop: &[(f32, f32); 4],
) -> Option<[Point; 4]>
pub fn inverse_warp_quad( line_polygon: &[Point; 4], crop_size: (u32, u32), quad_in_crop: &[(f32, f32); 4], ) -> Option<[Point; 4]>
Inversa della trasformazione applicata da get_rotate_crop_image:
dato il polygon DBNet della linea (4 corner nello spazio
dell’immagine originale) e un rettangolo (crop_w, crop_h) (il
rettangolo target del crop+warp), trasforma 4 punti dal CROP-SPACE
(rettangolo) all’IMAGE-SPACE (polygon).
Usato per riportare i word-box dal CRNN-cropped-line space allo spazio dell’immagine originale.
quad_in_crop è array di 4 (x, y) in [0..crop_w] × [0..crop_h].
Ritorna 4 Point clampati a u32. Se la Projection::invert()
fallisce (raro: polygon degenerato), ritorna None.
Nota: questa funzione NON gestisce la rotazione 90° applicata
quando crop_h >= crop_w * 3/2 (vedi get_rotate_crop_image).
Per quelle linee, il chiamante deve saltare il word-level (testo
verticale, edge case non supportato).
Auto Trait Implementations§
impl Freeze for OcrUtils
impl RefUnwindSafe for OcrUtils
impl Send for OcrUtils
impl Sync for OcrUtils
impl Unpin for OcrUtils
impl UnsafeUnpin for OcrUtils
impl UnwindSafe for OcrUtils
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.