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

Tesseract1.doOCR method doesn't take into account the stride of the image #257

Open
kpentaris opened this issue Jan 5, 2024 · 6 comments

Comments

@kpentaris
Copy link

kpentaris commented Jan 5, 2024

Hello,

We recently integrated Tesseract and Tess4J and noticed that the APIs do not take into account the stride of the image which can potentially differ from the width or xsize of the image. I thought that maybe the setImage method would calculate this using the ByteBuffer.capacity() or something but checking the implementation it just assumes that the stride will be a multiple of the width and the bytes per pixel which is not always case e.g. when storing color images using 32bits but the bit depth still is 24. Is there something I'm missing or is this something to be fixed?

@nguyenq
Copy link
Owner

nguyenq commented Jan 25, 2024

@kpentaris The stride may be used internally by Tesseract OCR engine, but its public C API does not use or expose it, so Tess4J does not need to consider it.

@kpentaris
Copy link
Author

kpentaris commented Jan 26, 2024

@nguyenq the C API has the TessBaseAPISetImage call which takes the bytes_per_line argument. The tess4j wrapper in Tesseract1.setImage method (which calls TessBaseAPISetImage) generates the bytes per line assuming that there is no padding (which is what the stride denotes). I'm guessing this is why it's bytes per line and not pixels per line.

@nguyenq nguyenq closed this as completed Mar 2, 2024
@kpentaris
Copy link
Author

@nguyenq hello. Is there a commit number where this issue is fixed (since it was marked as completed)?
Thanks!

@nguyenq
Copy link
Owner

nguyenq commented Mar 8, 2024

@kpentaris Sorry, it was meant to close as not planned since it's not an issue. Tesseract engine does not consider image stride.

@nguyenq nguyenq closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2024
@kpentaris
Copy link
Author

@nguyenq I'm confused, in my previous comment I showed exactly where it considers it in the TessBaseAPISetImage function.

@nguyenq nguyenq reopened this Mar 9, 2024
@nguyenq
Copy link
Owner

nguyenq commented Mar 9, 2024

@kpentaris I misunderstood your statement. Please submit a PR.

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