Conversation
Introduces the ImageInput enum to support multiple image sources (file path, buffer, dynamic image) for OCR processing. Adds OcrOptions struct for configurable OCR behavior, including word-level details and resize resolution. Refactors OcrEngine to use these abstractions, updates examples and benchmarks to the new API, and improves FFI bindings for model delay load.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the OCR library to improve input handling and configuration management by introducing structured options and flexible image input types. The refactoring enhances the API design while maintaining backward compatibility through default implementations.
- Introduces
OcrOptionsstruct for centralized configuration management including max line count, resize resolution, and word-level detail settings - Adds
ImageInputenum to support multiple input sources (file paths, image buffers, and dynamic images) with convenientFromtrait implementations - Refactors the
OcrEngine::runmethod to accept the new input types and use configuration from the options struct
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ocr_options.rs | Defines new OcrOptions and Resolution structs with default implementations |
| src/ocr_engine.rs | Refactors engine to use options-based initialization and flexible image input handling |
| src/lib.rs | Exports new public types for options and image input |
| src/image_input.rs | Implements ImageInput enum with conversion traits for different input types |
| src/ffi.rs | Updates FFI function signature to accept delay load parameter |
| src/errors.rs | Updates comment format from inline to doc comment |
| src/bounding_box.rs | Fixes missing closing bracket in display format string |
| examples/*.rs | Updates examples to use new API with options and input types |
| benches/benchmark.rs | Updates benchmarks to use new API structure |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.