B4i Library iTesseract- Simple OCR

JanPRO

Well-Known Member
Licensed User
Name: iTesseract

Version: 1.02

Description: iTesseract is a wrapper of the Tesseract IOS Framework and allows you to recognize text from images (OCR- optical character recognition).

License:
Notes/Tips:
Download from Dropbox:
Please let me know if you need more features and feel free to ask questions ;)
 
Last edited:

joilts

Member
Licensed User
Thanks, it looks great.
One rookie question... I´m trying to run the example you posted on my iPad. This is the error code:

B4X:
Error copying file: Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x1577e470 {NSFilePath=/private/var/mobile/Containers/Data/Application/
91E112BB-83AE-4EF1-9C99-EC6613C81F66/tmp/virtual_assets/deu-frak.traineddata,
NSUnderlyingError=0x1577e3e0 "The operation couldn’t be completed. No such file or directory"}
Can you help me with this one? Do I have to copy files ? I saw your notes/tips but didn´t get what to do.

Thanks in advance,
 
Last edited:

JanPRO

Well-Known Member
Licensed User
No,
I don't know why, but deu-frak.traineddata was renamed to deu_frak.traineddata. So just replace

B4X:
Dim DataList As List = Array As String("deu.traineddata","deu-frak.traineddata","osd.traineddata")
with

B4X:
Dim DataList As List = Array As String("deu.traineddata","deu_frak.traineddata","osd.traineddata")
And it will work :)
 
Last edited:

joilts

Member
Licensed User
Hi to all,

Have a new problem here, see if any of you can help.
I'm using this lib and it works very well in debug mode.
If a generate a "clean" release mode app, I get an error, about missing file or directory:
B4X:
Available EngineModes for your language:
Error copying file: Error Domain=NSCocoaErrorDomain Code=260 "The file ?pla.trai
neddata? couldn?t be opened because there is no such file." UserInfo={NSFilePath
=/private/var/mobile/Containers/Data/Application/4EC62672-4723-49FB-98D4-FFC7DE7
3516C/tmp/virtual_assets/pla.traineddata, NSUnderlyingError=0x17f2a860 {Error Do
main=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Stack Trace: (
  CoreFoundation       <redacted> + 150
  libobjc.A.dylib      objc_exception_throw + 38
  CoreFoundation       <redacted> + 0
  SITCARGA             -[B4IFile Copy::::] + 716
  SITCARGA             -[iTesseract Initilize::::::] + 1212
  SITCARGA             -[b4i_anpr _initialize:::] + 648
  SITCARGA             -[b4i_associate_screen _lookforphoto:] + 1452
  SITCARGA             -[b4i_associate_screen _returnfromcrop:] + 198
  SITCARGA             -[b4i_crop_plate_screen _btassociar_click] + 1320
  CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 292
SITCARGA             +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] +
By "clean" I mean to uninstall the "debug mode app" and then install "release mode" app. If I do "release mode" installation without removing the "debug mode first", everything work fine. I don´t know if it´s related or just a coincidence.
I saw this thread "Directory in Special folder" and I think it´s related to this problem. I use remote host to compile my app as I do not have a Mac to do so. It may be a problem using this lib? Is there a way to solve this?
My concern is if this can happens to my app after upload to Apple Store.

Thank you all for your time.
 
Last edited:

hanyelmehy

Active Member
Licensed User
Hi,
when try to BUILD i get this error message
B4X:
Error: ** BUILD FAILED **


The following build commands failed:
    Lex eng.cube.lm
(1 failure)
 

JanPRO

Well-Known Member
Licensed User

hanyelmehy

Active Member
Licensed User
Hi,
be sure, you have put all english tesseract files in to the Files folder:


Jan
i include all files
please check
B4X:
Dim DataList As List = Array As String("eng.cube.bigrams","eng.cube.fold","eng.cube.lm","eng.cube.nn","eng.cube.params","eng.cube.size","eng.cube.word-freq","eng.tesseract_cube.nn","eng.traineddata","osd.traineddata")
        iOCR.Initilize(True,"iOCR",DataList,File.DirDocuments,"eng")
        iOCR.MaximumRecognitionTime = 60
        iOCR.EngineMode=iOCR.EngineModeTesseractOnly
 

hanyelmehy

Active Member
Licensed User
Mmhh, the DataList looks good.
Are you using the HostedBuilder?
Although it seems that your project is fine, please upload it (with the tesseract files) or a example which demonstrates the issue.

Jan
i use local builder
project with tesseract files well be big (i use same files in Original Tesseract project)
Note project work in debug mode ,error show when try to BUILD only
Thank you
 

JanPRO

Well-Known Member
Licensed User
Update v. 1.01

Changes:
  • the method Initilize was renamed to Initialize
  • bug fix (thanks to hanyelmehy)
Very important: please rename ".lm" file extensions to ".yy", for example: eng.cube.lm ---> eng.cube.yy

You can find the new version in the start post.

Jan
 
Last edited:
Top