我使用Tesseract Python Wrapper来获取文本图像的方向。当我使用Tesseract-OCR(而不是API)时,将模式设置为-psm 0可以工作,但我不知道如何在使用包装器时提取该信息。我看过文档,我试图使用方法AnalyseLayout,但我似乎没有找到正确的方法来做到这一点。有什么想法?
谢谢!
下面是如何在Java中做到这一点。我想Python应该也是类似的。
IntBuffer orientation = IntBuffer.allocate(1);
IntBuffer direction = IntBuffer.allocate(1);
IntBuffer order = IntBuffer.allocate(1);
FloatBuffer deskew_angle = FloatBuffer.allocate(1);
int success = api.TessBaseAPIRecognize(handle, null);
if (success == 0) {
TessAPI.TessPageIterator pi = api.TessBaseAPIAnalyseLayout(handle);
api.TessPageIteratorOrientation(pi, orientation, direction, order, deskew_angle);
}