Expand description
Utility functions for the OCR pipeline.
This module re-exports utilities from oar-ocr-core.
Modules§
- bbox_
crop - Bounding box based image cropping utilities.
- cow
- Copy-on-Write utilities for efficient image handling.
- crop
- Image cropping functionality with different modes.
- dict
- Dictionary and tokenizer loading utilities.
- image
- Utility functions for image processing.
- tensor
- Tensor utility functions for converting between vectors and tensors.
- topk
- Top-k classification result processing.
- transform
- Image transformation utilities for OCR processing.
- validation
- Reusable validation components for OCR tasks.
Structs§
- BBox
Crop - Bounding box based image cropping utilities.
- Crop
- A processor for cropping images with different positioning modes.
- OCRResize
PadConfig - Configuration for OCR-style resize-and-pad operations with width constraints.
- Resize
PadConfig - Configuration for resize-and-pad operations.
- Score
Validator - A reusable validator for score ranges.
- Topk
- A processor for extracting top-k results from classification outputs.
- Topk
Result - Result structure for top-k classification processing.
Enums§
- Padding
Strategy - Padding strategy for resize-and-pad operations.
Functions§
- calculate_
center_ crop_ coords - Calculates centered crop coordinates for a target size.
- check_
image_ size - Checks if the given image size is valid (non-zero dimensions).
- create_
rgb_ image - Creates an RgbImage from raw pixel data.
- dynamic_
to_ gray - Converts a DynamicImage to a GrayImage.
- dynamic_
to_ rgb - Converts a DynamicImage to an RgbImage.
- get_
rotate_ crop_ image - Extracts a rotated and cropped image from a source image based on bounding box points.
- load_
image - Loads an image from a file path and converts it to RgbImage.
- load_
images - Loads a batch of images from file paths.
- load_
images_ batch_ with_ policy - Load multiple images from file paths using centralized parallel policy.
- load_
images_ batch_ with_ threshold - Loads a batch of images from file paths with a custom parallel threshold.
- mask_
region - Masks a rectangular region in an RGB image with a solid color.
- mask_
regions - Masks multiple bounding box regions in an RGB image.
- ocr_
resize_ and_ pad - Resize an image for OCR processing with width constraints and padding.
- pad_
image - Pads an image to the specified dimensions with a fill color.
- read_
character_ dict - Reads a character dictionary file and returns a vector of strings.
- read_
dict_ content - Reads a character dictionary file and returns the raw content string.
- require_
path - Validates that a required path option is present and returns the path.
- resize_
and_ pad - Resize an image to fit within target dimensions while maintaining aspect ratio, then pad to exact target dimensions.
- resize_
gray_ image - Resizes a grayscale image to the target dimensions using Lanczos3 filtering.
- resize_
image - Resizes an RGB image to the target dimensions using Lanczos3 filtering.
- resize_
images_ batch - Resizes a batch of images to the specified dimensions.
- resize_
images_ batch_ to_ dynamic - Resizes a batch of images and converts them to DynamicImage format.
- rgb_
to_ grayscale - Converts an RGB image to grayscale.
- slice_
gray_ image - Extracts a rectangular region from a grayscale image.
- slice_
image - Extracts a rectangular region from an RGB image.
- stack_
tensor2d - Stacks a slice of 2D tensors into a single 3D tensor.
- stack_
tensor3d - Stacks a slice of 3D tensors into a single 4D tensor.
- tensor1d_
to_ vec - Converts a 1D tensor into a 1D vector of f32 values.
- tensor2d_
to_ vec - Converts a 2D tensor into a 2D vector of f32 values.
- tensor3d_
slice - Extracts a 2D slice from a 3D tensor at the specified index.
- tensor3d_
to_ vec - Converts a 3D tensor into a 3D vector of f32 values.
- tensor4d_
slice - Extracts a 3D slice from a 4D tensor at the specified index.
- tensor4d_
to_ vec - Converts a 4D tensor into a 4D vector of f32 values.
- validate_
crop_ bounds - Validates that crop coordinates stay within image bounds.
- validate_
length_ match - Validates that a vector’s length matches an expected size.
- validate_
max_ value - Validates that a value doesn’t exceed a maximum.
- validate_
positive_ dimensions - Validates that dimensions are positive (non-zero).
- vec_
to_ tensor1d - Converts a 1D vector of f32 values into a 1D tensor with the specified shape.
- vec_
to_ tensor2d - Converts a 2D vector of f32 values into a 2D tensor.
- vec_
to_ tensor3d - Converts a 3D vector of f32 values into a 3D tensor.
- vec_
to_ tensor4d - Converts a 4D vector of f32 values into a 4D tensor.