harslanhafeez / matlab-tesseract-ocr

Automatically exported from code.google.com/p/matlab-tesseract-ocr
0 stars 0 forks source link

Tesseract Matlab: Running mex function from compiled GUI #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The tesseract mex function works fine when ran in a GUI from the source code, 
producing a string of OCR output with an input of AVI file frame. However, when 
running from the compiled code, the function doesn't execute/complete. 

Steps:

1. Compile a matlab GUI with tesseract mex function
2. Run the function in the compiled gui
3. function doesn't execute/complete

Operating system: Windows XP, 32 bit.

Is this a known issue or could I be doing something wrong?

Here is the section of code concerned with running the tesseract function:

% run in many frames, change to gray image, change contrast and size, and then 
perform OCR on several rectangular sections of each frame

      for j=1:numFrames    
          grayImage= rgb2gray(mov.frames(j).cdata);
          for m=1:numRect

          cropped = grayImage(AnalysisCoordData(m,2):AnalysisCoordData(m,4),AnalysisCoordData(m,1):AnalysisCoordData(m,3));
          dCropped = double(cropped)/max(max(double(cropped)));

          dBig = imresize(dCropped,4);
          uBig = uint8(dBig*(2^8-1));

          dBW = dBig;
          %im2bw(dBig,0.6);
          uBW = uint8(dBW*(2^8-1));
          resizedAndBWText{j,m}=tesseract(uBW');
          end
      end

% a string array of OCR text is stored in resizedAndBWText.

:: It works fine when ran from source, it simply hangs when ran from compiled 
code.

Thank you if anyone can help.

Peter

Original issue reported on code.google.com by pkenn...@gmail.com on 30 Oct 2013 at 6:01

GoogleCodeExporter commented 9 years ago
This issue arose due to the tesseract mex function not finding the tessdata 
folder in the directories where the compiled program is ran (not the .exe, but 
the TEMP folder in Documents and Settings for Windows). If the tessdata folder 
is an immediate sub folder of the mex-function then all is good.

Thanks.

Original comment by pkenn...@gmail.com on 2 Nov 2013 at 12:36