gradedcatfood
gradedcatfood

Reputation: 171

Tesseract OCR "WARNING: Image has not size!"

Hello I am trying to use Tesseract OCR (iOS) but whenever i select an image from a photo that i have have taken or an image that i have selected from my local photos i get this:

WARNING: Image has not size!

Please call SetImage before attempting recognition.2014-06-14 20:44:07.613 Do Math[431:60b] inside calculate

Please call SetImage before attempting recognition.2014-06-14 20:44:07.614 Do Math[431:60b] No recognized text. Check that -[Tesseract setImage:] is passed an image bigger than 0x0.

My method "calculate" is the following below:

- (void)calculate
{
Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng+ita"];
tesseract.delegate = self;

[tesseract setVariableValue:@"abcdefghijklmnopqrstuvwxyz" forKey:@"tessedit_char_whitelist"];
[tesseract setImage:_image];
[tesseract recognize];

NSLog(@"%@", [tesseract recognizedText]);

tesseract = nil; //deallocate and free all memory

}

Regarding

[tesseract setImage:_image];

_image is an instance variable i have started as:

UIImage *_image;

And gets assigned after someone either takes a photo, or selects a photo via:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;

chosenImage = _image;

[picker dismissViewControllerAnimated:YES completion:NULL];

}

I downloaded this via cocoapods: https://github.com/gali8/Tesseract-OCR-iOS

What am i doing wrong? _image is a UIImage and that is what setImage is expecting!

Upvotes: 0

Views: 723

Answers (1)

user2683871
user2683871

Reputation: 46

Use _image = chosenImage instead of chosenImage = _image.

Might work.

Upvotes: 1

Related Questions