pub async fn read_image(image_path: impl AsRef<Path>) -> Result<String>Expand description
Read text from a single image file
This function initializes a new MonOcr instance with default settings and performs OCR on the given image. The image is automatically segmented into lines, and each line is recognized using the ONNX model.
§Arguments
image_path- Path to the image file (PNG, JPG, BMP, etc.)
§Returns
Returns a Result<String> containing the recognized text, with lines separated by newlines.
§Example
use monocr_onnx::read_image;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let text = read_image("document.png").await?;
println!("Recognized: {}", text);
Ok(())
}