nguyenq / tess4j

Java JNA wrapper for Tesseract OCR API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

kpentaris opened this issue · comments

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?

@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.

@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 hello. Is there a commit number where this issue is fixed (since it was marked as completed)?
Thanks!

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

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

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