Beispiel für Einbindung von tesseract



  • Hey,

    ich versuche tesseract-ocr in ein Projekt einzubinden und scheitere beim Initialisieren der API.

    Ich habe mir von hier https://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-3.02.02-win32-lib-include-dirs.zip&can=2&q=
    dll/lib/header heruntergeladen und in mein Testprojekt eingebunden.
    Das gleiche mit der leptonica Bibliothek. Die Language-Datei für Deutsch befindet sich unter c:/temp

    Das Projekt ist ein MFC Dialogbasiertes Projekt in der VS 2013 Community Edition. Es lässt sich übersetzen und starten.

    Beim Initialisieren der Bibliothek scheitert es aber:

    Quellcode:

    #include "include\tesseract\baseapi.h"
    #include "include\leptonica\allheaders.h"
    //...
    tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
    if (api->Init("C:/temp/", "deu"))
    {
    	AfxMessageBox(_T("api init failed"));
    	return;
    }
    //...
    

    Hat jemand ein funktionierendes Beispiel?



  • Im Netz gibts viele Vorschläge, habs aber selbst nichts ausprobiert.

    https://code.google.com/p/tesseract-ocr/wiki/APIExample

    http://zdenop.github.io/tesseract-doc/classtesseract_1_1_tess_base_a_p_i.html

    The datapath must be the name of the parent directory of tessdata and
    must end in / . Any name after the last / will be stripped. The language
    is (usually) an ISO 639-3 string or <code>null</code> will default to eng.
    It is entirely safe (and eventually will be efficient too) to call Init
    multiple times on the same instance to change language, or just to reset
    the classifier.

    If you have a rare need to set a Variable that controls initialization
    for a second call to Init you should explicitly call End() and then use
    SetVariable before Init. This is only a very rare use case, since there
    are very few uses that require any parameters to be set before Init.



  • Problem gelöst. Grund unbekannt 😃

    Ich habe alle Bibliotheken unter VS 2013 Community neu übersetzt (lt. Anleitung von http://vorba.ch/2014/tesseract-3.03-vs2013.html)

    Mein Testprogramm kam allerdings immer noch nicht über Init() hinaus. Nachdem ich die MBCS-Erweiterung installiert habe ging es dann. (Projekt steht weiterhin auf UNICODE).

    Vielleicht hilfts auch jemand anderem ...


Anmelden zum Antworten