【发布时间】:2015-08-04 11:27:49
【问题描述】:
【问题讨论】:
-
您的问题得到答案了吗?
-
不,但我解决了,因为我所有的图像都一样(模板化,例如 KYC 表格)。由于我的是一个 Web 应用程序,我使用 Jquery Crop 获取图像的 X、Y、高度和宽度坐标,然后使用 tesseract 仅扫描基于 x、y、高度和宽度坐标的部分。
【问题讨论】:
当然,这完全取决于您使用的是哪个 Tesseract SDK。我将开源 G8Tesseract iOS SDK 用于一个与您正在尝试做的事情类似的项目。如果您正在使用该框架,这可能会有所帮助。我推荐的是,当您创建G8RecognitionOperation 时,您可以调用一个方法来检索数据,称为recognitionCompleteBlock。在此方法的完成块中,获取操作的结果并遍历并解析您想要的数据。由于您知道您想要的信息就在“姓名”之后/“社会保障”之前,我会在此之前和之后分割所有不需要的文本,然后从那里进行剖析。像这样的:
G8RecognitionOperation *operation = [[G8RecognitionOperation alloc] initWithLanguage:@"eng"];
// Set up operation...
operation.recognitionCompleteBlock = ^(G8Tesseract *tesseract) {
// Fetch the recognized text
NSString *recognizedText = tesseract.recognizedText;
NSLog(@"%@", recognizedText);
// GET NAME
// Split the result into two strings / Index 0 is trash because it is before Name
NSArray *slice1 = [recognizedText componentsSeparatedByString:@"Name"];
NSString *slice1String = slice1[1];
// What comes before "Social" should be the name you are looking for
NSArray *slice2 = [slice1String componentsSeparatedByString:@"Social"];
NSString *name = slice2[0];
//GET CITY (do the same thing here)
// Split the rest of the result and get the desired data
NSArray *slice3 = [slice2[1] componentsSeparatedByString:@"City"];
NSString *slice3String = slice3[1];
// What comes before "State" should be the city you are looking for
NSArray *slice4 = [slice3String componentsSeparatedByString:@"State"];
NSString *city = slice4[0];
NSLog(@"Applicant Name: %@ | City: %@",name, city);
};
【讨论】: