我正在开发一个使用 Abbyy OCR 的 iphone 应用程序。
使用 iphone 的包装类有一个方法:
[ocrManager recognizeImage:[choosenImage image] withCallback:self];
UIImage 作为用于识别字符的参数传递。但是每次我收到异常“缺少所需的数据文件”。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
if(check == 1)
{
return;
}
check = 1;
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[choosenImage setImage:image];
[process setHidden:NO];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"license" ofType:@""];
NSData *license = [[NSData alloc] initWithContentsOfFile:filePath];
CMocrManager *ocrManager = [CMocrManager createManager:license];
NSSet *languages = [[NSSet alloc] initWithArray:[NSArray arrayWithObject:@"English"]];
[ocrManager setLanguages:languages];
[ocrManager setDefaultImageResolution:0];
@try {
[ocrManager recognizeImage:[choosenImage image] withCallback:self];
}
@catch (NSException *exception) {
NSString *ex = exception.reason;
}
CMocrLayout* recognitionResult = [ocrManager copyRecognitionResults];
NSArray* strings = [recognitionResult copyStrings];
}
可以看到图像,UIImageView
但是当我将它传递给recognizeImage
方法时,它会引发异常。
我一直在研究很多,但无法找到解决方案。任何帮助表示赞赏。