You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
747 B
27 lines
747 B
extern crate leptess;
|
|
|
|
use leptess::{leptonica, tesseract};
|
|
use std::path::Path;
|
|
|
|
fn main() {
|
|
let mut api = tesseract::TessApi::new(None, "eng").unwrap();
|
|
|
|
let pix = leptonica::pix_read(Path::new("./test.png")).unwrap();
|
|
api.set_image(&pix);
|
|
|
|
// detect bounding boxes for words
|
|
let boxes = api
|
|
.get_component_images(leptess::capi::TessPageIteratorLevel_RIL_WORD, true)
|
|
.unwrap();
|
|
|
|
println!("Found {} textline image components.", boxes.get_n());
|
|
|
|
// run OCR on each word bounding box
|
|
for b in &boxes {
|
|
api.set_rectangle(&b);
|
|
let text = api.get_utf8_text().unwrap();
|
|
let confi = api.mean_text_conf();
|
|
println!("{:?}, confidence: {}, text: {}", b, confi, text);
|
|
}
|
|
}
|