nolanbrown / Tesseract-iPhone-Demo

Demo iPhone app utilizing the tesseract library for OCR
454 stars 169 forks source link

EXC_BAD_ACCESS #2

Open alexprest opened 13 years ago

alexprest commented 13 years ago

I'm trying to compile your demo using the oldest iOS sdk available nowadays which is 3.2 At runtime, after taking the photograph the program crashes with EXC_BAD_ACCESS during the following call:
char* text = tess->TesseractRect(imageData,(int)bytes_per_pixel,(int)bytes_per_line, 0, 0,(int) imageSize.height,(int) imageSize.width);

Other users are experiencing the same problem, there's a stackoverflow thread about it: http://stackoverflow.com/questions/4560587/business-card-reader-or-ocr-library-for-iphone-sdk

Have you tried running your code with SDK 3.0 or greater? Thanks for your precious work!

leogomes commented 13 years ago

Here is how it worked for me: http://stackoverflow.com/questions/4560587/business-card-reader-or-ocr-library-for-iphone-sdk/5443102#5443102

nekin commented 13 years ago

I did follow your comment at stackoverflow and added [self startTesseract]; to the viewDidLoad() method in OCRDemoViewController but still i am having problem as below.

  1. when i take image from camera and click on USE it crashes and shows EXC_BAD_ACCESS
  2. if i select picture from gallery then it takes picture and then after coming back to screen of app it just shows picture there as it is. i do not have any idea on how to proceed further from there. OR how can i get data extracted from that image ?
leogomes commented 13 years ago

Nolan has already applied the fix I proposed, so it should work if you just take the code from here: https://github.com/nolanbrown/Tesseract-iPhone-Demo

If you still have problems, try to paste some of your code as a gist, so that we can see concretely how you're doing things.

Cheers, Leonardo.

nekin commented 13 years ago

Thanks leogomes for your reply.

Yes i have already downloaded code from link which you provided and also i seen that the fix is there. However when i cross check point of crash into app , below is what i find.

My app opens and the moment i select image from camera or from image picker then it goes to resize it and there it is problem inside resizeimage function i am getting width and height as Zero. I think it should give us the height and width of actual image ..correct ?

I also checked that object coming into resizeimage is not Null.

Waiting for your reply on this.

Thks Nekin

leogomes commented 13 years ago

I remember there was a problem with the height and width but I can't actually tell what and I don't have my mac here right now.

You could give a try to this: http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/

It's more up-to-date and seems to work quite fine from what I've read in the tesseract mailing list.

Cheers, Leo.

primsky83 commented 11 years ago

Guys, in the very first comment of this discussion the code snippet says: char* text = tess->TesseractRect(imageData,(int)bytes_per_pixel,(int)bytes_per_line, 0, 0,(int) imageSize.height,(int) imageSize.width);

But looking at the official documentation at http://tesseract-ocr.repairfaq.org/classTessBaseAPI.html the TesseractRect method is defined as follows:

static char * TesseractRect (const UINT8 *imagedata, int bytes_per_pixel, int bytes_per_line, int left, int top, int width, int height)

...the width and height parameters are swapped.

As for me, it solved my problem.