简体   繁体   English

在 Android 中使用 Tesseract 的方向和脚本检测 (OSD)

[英]Orientation and script detection (OSD) using Tesseract in Android

I am an android developer and i am integrating Tesseract for OCR scanning.我是一名 android 开发人员,我正在集成 Tesseract 以进行 OCR 扫描。 for my application i have the requirement to detect the OCR from any angle of phone and in any mode (portrait or landscape) mode of phone.对于我的应用程序,我需要从手机的任何角度和手机的任何模式(纵向或横向)模式下检测 OCR。 For this I am trying to get orientation and skew angle of the OCR and based on that i will deskew the image and process the OCR.为此,我正在尝试获取 OCR 的方向和倾斜角度,并基于此我将歪斜图像并处理 OCR。

I have gone though various post to find the way to get the Orientation but was unable to succeed.我已经通过各种帖子找到了获得方向的方法,但无法成功。 As per one of the post it is mentioned to get the orientation and skew angle using the following logic:根据其中一篇文章,提到使用以下逻辑获取方向和倾斜角度:

inputfile = "/usr/src/tesseract-3.02/eurotextUpsideDown.png";
image = pixRead(inputfile);

api->Init("/usr/src/tesseract-3.02/", "eng");
api->SetPageSegMode(tesseract::PSM_AUTO_OSD);
api->SetImage(image);
api->Recognize(0);

tesseract::PageIterator* it =  api->AnalyseLayout();
tesseract::Orientation orientation;
tesseract::WritingDirection direction;
tesseract::TextlineOrder order;
float deskew_angle;

it->Orientation(&orientation, &direction, &order, &deskew_angle);
printf("Orientation: %d;\nWritingDirection: %d\nTextlineOrder: %d\n" \
       "Deskew angle: %.4f\n",
       orientation, direction, order, deskew_angle);

But in android I cannot find the supported method AnalyseLayout() in the TessBaseApi.java class.但在 android 中,我在TessBaseApi.java类中找不到支持的方法AnalyseLayout()

I want to get the logic to process the image in way so that i can deskew the image and process it.我想获得以某种方式处理图像的逻辑,以便我可以歪斜图像并对其进行处理。

any information will be of great help.任何信息都会有很大帮助。

You've kind of answered your own question here.你已经在这里回答了你自己的问题。 The reason the AnalyseLayout method isn't available is because it hasn't been implemented in the Android API (as of today). AnalyseLayout 方法不可用的原因是它尚未在 Android API 中实现(截至今天)。 You would need to implement it yourself.你需要自己实现它。

You might want to take a look at the Leptonica's Skew.findSkew method instead.您可能想看看 Leptonica 的Skew.findSkew方法。 There's an example of its use in the SkewTest class.在 SkewTest 类中有一个使用示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM