如何在Tesseract OCR中设置书写方向?

时间:2016-08-19 10:36:18

标签: ios tesseract

我正试图在Tesseract中为我的iOS应用程序设置阿拉伯语,乌尔都语和其他语言的写作方向。当我尝试设置这样的时候

G8RecognitionOperation *tesseract;
tesseract.tesseract.writingDirection = G8WritingDirectionRightToLeft;

它给出错误"分配只读属性"。请用正确的代码回答。 https://github.com/gali8/Tesseract-OCR-iOS/blob/master/TesseractOCR/G8Constants.h

1 个答案:

答案 0 :(得分:3)

writingDirection属性是只读属性,将在识别文本时被检测到。

G8Constants.h中的G8WritingDirection是可能的书写方向。

我试图识别这张图片:

sample image

使用以下代码:

G8RecognitionOperation *operation = [[G8RecognitionOperation alloc] initWithLanguage:@"ara"];
operation.tesseract.language = @"ara";
operation.tesseract.image = [[UIImage imageNamed:@"ara.png"] g8_blackAndWhite];
operation.recognitionCompleteBlock = ^(G8Tesseract *recognizedTesseract) {
    NSLog(@"recognizedText=%@", [recognizedTesseract recognizedText]);
    NSLog(@"writingDirection=%lu", (unsigned long) recognizedTesseract.writingDirection);
};

我得到了输出:

recognizedText=شكر ا جزيلا
writingDirection=1