I'm implementing Tesseract OCR in my iOS application using real time camera
update method
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
I am passing the input image as
UIImage *image = [GMVUtility sampleBufferTo32RGBA:sampleBuffer];
[self recognizeImageWithTesseract:image];
-(void)recognizeImageWithTesseract:(UIImage *)image {
operationQueue = [[NSOperationQueue alloc] init];
// Create a new `G8RecognitionOperation` to perform the OCR
asynchronously
// It is assumed that there is a .traineddata file for the language
pack
// you want Tesseract to use in the "tessdata" folder in the root
of the
// project AND that the "tessdata" folder is a referenced folder
and NOT
// a symbolic group in your project
G8RecognitionOperation *operation = [[G8RecognitionOperation alloc]
initWithLanguage:@"eng+ita"];
operation.tesseract.engineMode = G8OCREngineModeTesseractOnly;
// Let Tesseract automatically segment the page into blocks of text
// based on its analysis (see G8Constants.h) for other page
segmentation
// mode options
operation.tesseract.pageSegmentationMode =
G8PageSegmentationModeAutoOnly;
operation.tesseract.maximumRecognitionTime = 6.0;
operation.delegate = self;
operation.tesseract.charWhitelist =
@"01234567890/qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
operation.tesseract.image = image;
[operation.tesseract recognize];
operation.recognitionCompleteBlock = ^(G8Tesseract *tesseract) {
NSString *recognizedText = tesseract.recognizedText;
NSLog(@"%@", recognizedText);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"OCR
Result"
message:recognizedText
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
};
self.takePictureButton.imageView.image =
operation.tesseract.thresholdedImage;
[operationQueue addOperation:operation];
}
NSString *recognizedText = tesseract.recognizedText;
The recognizedText shows random alphabets and numbers even on simple image.
Can anyone please help me out whats wrong?
PS: attached my tessdata
<https://lh3.googleusercontent.com/-vZvvh5YRaGE/WcOZzcyTbjI/AAAAAAAAAAM/KUSYhIhKdnYvO1xAcjjeR9HNEmOR7SScACLcBGAs/s1600/Screen%2BShot%2B2017-09-19%2Bat%2B7.53.29%2BPM.png>
Please refer to this stackoverflow link:
https://stackoverflow.com/questions/46303707/tesseract-ocr-shows-random-alphabets-only
--
You received this message because you are subscribed to the Google Groups
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tesseract-ocr/0c05c2a2-a661-4bea-b8c9-e0a18cf5d252%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.