Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting text from image #19

Open
keplerHaloxx opened this issue May 16, 2024 · 3 comments
Open

Not getting text from image #19

keplerHaloxx opened this issue May 16, 2024 · 3 comments

Comments

@keplerHaloxx
Copy link

This is my code

let img = Image::from_path("C:/Users/{my user}/Downloads/asd.png").unwrap();
let mut my_args = Args::default();
let output = rusty_tesseract::image_to_string(&img, &my_args).unwrap();
println!("The String output is: {:?}", output);

and this is the output

Tesseract Command: tesseract.exe C:/Users/{my user}/Downloads/asd.png stdout -l eng --dpi 150 --psm 3 --oem 3
The String output is: ""

This is the image im using it with
asd

Is it something to do with my image/tesseract args or is it with the crate?

@thomasgruebl
Copy link
Owner

Hi, thanks for your comment.

This is a tesseract issue, or rather, a configuration issue and has nothing to do with the rusty-tesseract crate.

Try using PSM 6 instead of PSM 3, then it works.

You can also try it locally in your terminal by running "tesseract.exe asd.png stdout -l eng --dpi 150 --psm 6 --oem 3"

Hope that helps.

@thomasgruebl
Copy link
Owner

In Rust you can use:

let mut my_args = Args { dpi: Some(150), psm: Some(6), oem: Some(3), ..Args::default() };

instead of let mut my_args = Args::default();

@keplerHaloxx
Copy link
Author

Thank you for answering! You're answer worked for that image but I found that oem: 8 is the best for me as when I tried 6 with another image that's practically the same just different colors it returned a completely wrong output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants