OCR Tessearct Scanning Chunks of text not left to right iOS

前提是你 提交于 2019-12-08 09:23:49

问题


I have a piece of paper that I want to scan, however the paper is not formatted in a way that scanning from left to right will work. As of now it will scan from left to right even if some text isn't "grouped" together.

How can I make Tesseract recognize text that is grouped and scan the grouped text together instead of left to right?

Image(Can't post images low rep)

http://cdn.designrshub.com/wp-content/uploads/2012/06/alignment.jpg

For example how would I make it recognize that each of those four paragraphs are its own "chunk" and scan them separately? Instead of scanning the first line in both of the top paragraphs then going down from there.


回答1:


In Tesseract you can input the frame in an image which you need to scan. So If you set frame of a paragraph it will scan that that particular area only and will return text in that area. Thus you can separate scan each paragraph.

Go to Tesseract.mm file and add this code there.

- (void)setRect:(CGRect)rect {
     _tesseract->SetRectangle(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
}

Go to Tesseract.h file and define method :

- (void)setRect:(CGRect)rect;

Then you can set frame before calling recognizedText

[tesseract setRect:CGRectMake(0, 0, 100, 100)];
[tesseract recognizedText];


来源:https://stackoverflow.com/questions/21421472/ocr-tessearct-scanning-chunks-of-text-not-left-to-right-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!