我已经使用Tesseract OCR iOS扫描文本,我已经使用它来处理项目中包含的照片.
但是当从UIImagePickerController传递一个UIImage时,它不起作用.我设置了这个简单的测试:
Tesseract确实识别出原始中正确的行数,但是作为垃圾(我测试了几个示例测试).保存在Photoshop中后,图像具有良好的识别率.
我简直无法弄清楚Photoshop以某种方式修复的原始UIImage有什么问题.请帮忙!
这是图像:
将图像输送到tesseract的代码:
- (void)recognizeWithImage:(UIImage *)image {
G8RecognitionOperation *operation = [[G8RecognitionOperation alloc] initWithLanguage:@"dan"];
operation.tesseract.image = image;
self.imageView.image = image;
operation.recognitionCompleteBlock = ^(G8Tesseract *recognizedTesseract) {
NSLog(@"Result:\n%@", [recognizedTesseract recognizedText]);
};
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[queue addOperation:operation];
}Run Code Online (Sandbox Code Playgroud)
以下是从相机获取图像的代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissViewControllerAnimated:YES completion:nil];
UIImage *originalImage = info[UIImagePickerControllerOriginalImage];
NSData *dataForJPEGFile = UIImageJPEGRepresentation(originalImage, 1.0);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = …Run Code Online (Sandbox Code Playgroud)