feat: use Arc & Mutex for LepTess

This commit is contained in:
2023-12-31 22:55:32 +07:00
parent 19dc2963f5
commit 34c52cd9ab
12 changed files with 191 additions and 33 deletions

View File

@ -5,13 +5,11 @@ pub mod constants;
pub mod tesseract;
pub fn setup_logger(level: &str) -> Result<(), fern::InitError> {
// I don't really know how to do it because the unset variable trick doesn't work
// since the types can be
let formatter = fmt::format()
.with_level(true)
.with_target(true)
.with_thread_ids(false)
.with_thread_names(false); // include the name of the current thread.pretty();
.with_thread_names(false);
let filter = EnvFilter::builder()
.from_env()
.unwrap()

View File

@ -1 +1,13 @@
pub use leptess::LepTess;
pub use leptess::{LepTess, Variable};
pub fn init_tesseract() -> Result<LepTess, String> {
let mut lep_tess = match LepTess::new(None, "eng") {
Ok(lep_tess) => lep_tess,
Err(why) => return Err(format!("Failed to initialize Tesseract: {:?}", why)),
};
match lep_tess.set_variable(Variable::TesseditCharWhitelist, "0123456789") {
Ok(_) => (),
Err(why) => return Err(format!("Failed to set whitelist: {:?}", why)),
};
Ok(lep_tess)
}