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

why can't it read the single character on the picture? #273

Open
umutozgur opened this issue Sep 10, 2021 · 3 comments
Open

why can't it read the single character on the picture? #273

umutozgur opened this issue Sep 10, 2021 · 3 comments

Comments

@umutozgur
Copy link

why can't it read the single character on the picture?

@ivanstepanovftw
Copy link

ivanstepanovftw commented Nov 26, 2023

Try this:

TESSDATA_PREFIX = "/usr/share/tesseract/tessdata"
tesserocr_languages = ["eng", "ara"]
api = PyTessBaseAPI(path=TESSDATA_PREFIX, lang="+".join(tesserocr_languages))

api.SetImageBytes(
    imagedata=pixmap.samples,
    width=pixmap.w,
    height=pixmap.h,
    bytes_per_pixel=bpp,
    bytes_per_line=pixmap.stride,
)
api.SetPageSegMode(tesserocr.PSM.SINGLE_CHAR)  # <- important
api.Recognize()
ocr_text = api.GetUTF8Text()

@zdenop
Copy link
Contributor

zdenop commented Nov 26, 2023

without providing an input image you are alone with your problem...

@ivanstepanovftw
Copy link

ivanstepanovftw commented Mar 21, 2024

Sure!
image

I think this issue should be closed as resolved.

If image contains single character, read this:

Tesseract works best on images which have a DPI of at least 300 dpi, so it may be beneficial to resize images

Here is also plot for you:
image

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

3 participants