pub struct OcrEngine { /* private fields */ }
Expand description
The OcrEngine
struct represents the OneOcr processing engine.
Implementations§
Source§impl OcrEngine
impl OcrEngine
Sourcepub fn new_with_options(ocr_options: OcrOptions) -> Result<Self, OneOcrError>
pub fn new_with_options(ocr_options: OcrOptions) -> Result<Self, OneOcrError>
Creates a new instance of the OCR engine with specified options. This function loads the necessary library and initializes the OCR pipeline with the provided options.
Sourcepub fn new() -> Result<Self, OneOcrError>
pub fn new() -> Result<Self, OneOcrError>
Creates a new instance of the OCR engine with default options. This function loads the necessary library and initializes the OCR pipeline.
Sourcepub fn get_max_recognition_line_count(&self) -> Result<i32, OneOcrError>
pub fn get_max_recognition_line_count(&self) -> Result<i32, OneOcrError>
Retrieves the maximum number of lines that can be recognized. Default is 100.
Sourcepub fn set_max_recognition_line_count(
&self,
count: i32,
) -> Result<(), OneOcrError>
pub fn set_max_recognition_line_count( &self, count: i32, ) -> Result<(), OneOcrError>
Sets the maximum number of lines that can be recognized. Default is 100, range is 0-1000.
Sourcepub fn get_resize_resolution(&self) -> Result<(i64, i64), OneOcrError>
pub fn get_resize_resolution(&self) -> Result<(i64, i64), OneOcrError>
Retrieves the maximum internal resize resolution.
The resize resolution
defines the maximum dimensions to which an image will be automatically scaled internally before OCR processing.
It’s a performance and accuracy trade-off rather than a restriction on the original image’s resolution.
Default is 1152*768.
Sourcepub fn set_resize_resolution(
&self,
width: i32,
height: i32,
) -> Result<(), OneOcrError>
pub fn set_resize_resolution( &self, width: i32, height: i32, ) -> Result<(), OneOcrError>
Sets the maximum internal resize resolution.
The resize resolution
defines the maximum dimensions to which an image will be automatically scaled internally before OCR processing.
It’s a performance and accuracy trade-off rather than a restriction on the original image’s resolution.
The maximum resolution is 1152*768.
Sourcepub fn run(&self, input: ImageInput) -> Result<OcrResult, OneOcrError>
pub fn run(&self, input: ImageInput) -> Result<OcrResult, OneOcrError>
Run OCR processing on an image.
This method accepts various input types through the ImageInput
enum
and allows configuration through OcrOptions
.
§Arguments
input
- The image input source (file path, image buffer, or dynamic image)
§Returns
Returns an OcrResult
containing the recognized text and associated metadata,
or an error if the OCR processing fails.
§Examples
use oneocr_rs::{OcrEngine, OcrOptions, ImageInput};
use std::path::Path;
let engine = OcrEngine::new().unwrap();
// Process from file path
let result = engine.run(Path::new("image.jpg").into()).unwrap();
// Process from in-memory image buffer
let img_buffer: ImageBuffer<Rgba<u8>, Vec<u8>> = capture_screenshot(); // Your screenshot function
let result = engine.run(img_buffer.into()).unwrap();
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OcrEngine
impl RefUnwindSafe for OcrEngine
impl !Send for OcrEngine
impl !Sync for OcrEngine
impl Unpin for OcrEngine
impl UnwindSafe for OcrEngine
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> 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 more