#tesseract #ocr #image #leptonica

leptess

Productive Rust binding for Tesseract and Leptonica

27 unstable releases

Uses old Rust 2015

0.14.0 Feb 21, 2023
0.13.4 Sep 26, 2022
0.13.2 Dec 9, 2021
0.13.1 Aug 31, 2021
0.6.0 Jul 6, 2019

#187 in Images

Download history 65/week @ 2023-11-20 69/week @ 2023-11-27 42/week @ 2023-12-04 55/week @ 2023-12-11 83/week @ 2023-12-18 56/week @ 2023-12-25 46/week @ 2024-01-01 93/week @ 2024-01-08 87/week @ 2024-01-15 105/week @ 2024-01-22 79/week @ 2024-01-29 35/week @ 2024-02-05 100/week @ 2024-02-12 111/week @ 2024-02-19 175/week @ 2024-02-26 144/week @ 2024-03-04

536 downloads per month
Used in 3 crates

MIT license

2MB
2K SLoC

Leptess

Test Crates.io Docs

Productive and safe Rust bindings/wrappers for Tesseract and Leptonica.

Build dependencies

Make sure you have clang, Leptonica and Tesseract installed.

Tesseract should be version 4.0.0 or above.

Ubuntu

sudo apt-get install libleptonica-dev libtesseract-dev clang

You will also need to install tesseract language data based on your OCR needs:

sudo apt-get install tesseract-ocr-eng

Mac

brew install tesseract leptonica

Windows

On Windows, this library uses Microsoft's vcpkg to provide tesseract.

Please install vcpkg and set up user wide integration or vcpkg crate won't be able to find the library.

To install tesseract:

REM from the vcpkg directory

REM 32 bit
.\vcpkg install tesseract:x86-windows

REM 64 bit
.\vcpkg install tesseract:x64-windows

To run the tests configure vcpkg-crate to find the tesseract library:

SET VCPKGRS_DYNAMIC=true
cargo test

Usage

let mut lt = leptess::LepTess::new(None, "eng").unwrap();
lt.set_image("path/to/page.bmp");
println!("{}", lt.get_utf8_text().unwrap());

For more examples, see docs and examples directory.

To run demos in examples directory, try:

cargo run --example low_level_ocr_full_page

Development

To run tests, you will need at Tesseract 4.x or 5.x to match what we have in tests/tessdata/eng.traineddata. See GitHub config actions to see how to replicate the setup.

Dependencies