Closed Jnaltuna closed 1 year ago
Tesseract/Tesseract1
classes only employ some of the most commonly used methods from TessAPI
class.
What's your use case? Some code snippets would be helpful in understanding the issue.
This is our current use case:
ITessAPI.TessBaseAPI handle = TessAPI1.TessBaseAPICreate();
TessAPI1.TessBaseAPIInit3(handle, "/usr/share/tesseract-ocr/4.00/tessdata", "osd");
IntBuffer orientDegB = IntBuffer.allocate(1);
FloatBuffer orientConfB = FloatBuffer.allocate(1);
PointerByReference scriptNameB = new PointerByReference();
FloatBuffer scriptConfB = FloatBuffer.allocate(1);
String script_name = null;
float script_conf = 0;
RenderedImage renderedImage = image.getRenderedImage();
int bpp = renderedImage.getColorModel().getPixelSize();
int bytespp = bpp / 8;
int bytespl = (int) Math.ceil(renderedImage.getWidth() * bpp / 8.0);
TessAPI1.TessBaseAPISetImage(handle, ImageIOHelper.getImageByteBuffer(this.image), renderedImage.getWidth(), renderedImage.getHeight(), bytespp, bytespl);
int result1 = TessAPI1.TessBaseAPIDetectOrientationScript(handle, orientDegB, orientConfB, scriptNameB, scriptConfB);
if (result1 == 1) {
script_name = scriptNameB.getValue().getString(0);
script_conf = scriptConfB.get();
}
Note that image
object is of type IIOImage
Because DetectOrientationScript
is not commonly used, it is not included in the high-level API. You will have to call it in the way you have described.
Thanks! Any chance this will get added to the high-level API in the near future?
We don't want to arbitrarily introduce just any method to the API unless they really add values/benefits for the users. Please submit a PR, or list it here, then we'll consider. Thanks.
I'm currently using tess4j and I need to use the OSD mode. I've tried the higher level wrappers but It doesn't seem to work correctly. I've resorted to using an implementation similar to the tests linked below. https://github.com/nguyenq/tess4j/blob/17b70665b3aab94cab9d180fe089033e4da21896/src/test/java/net/sourceforge/tess4j/TessAPI1Test.java#L448
Is it possible to use the
Tesseract/Tesseract1
classes instead of the API directly? Its possible I'm not using it correctly. Also note that I'm currently on tess4j version 4.0.2, just in case changes were already made.If its not currently possible, are there plans to simplify its use?