Search code examples
c#dllimportemgucv

Where does EmguCV use tesseract from?


In the Emgu.CV.OCR sample project, there is a class Tesseract, which is a wrapper for the Tesseract-OCR engine. In Tesseract.cs, there are declarations like:

[DllImport(CvInvoke.EXTERN_LIBRARY, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern IntPtr TessBaseAPICreate();

CvInvoke.EXTERN_LIBRARY points to cvextern.dll.

I opened cvextern.dll in DependencyWalker, and there aren't any Tesseract functions anywhere, only OpenCV functions.

I'm sure I'm missing something obvious, but where are the actual function definitions that are being used here?


Solution

  • If I open up cvextern.dll in DependencyWalker and click on CVEXTERN.DLL in the left-hand pane I can see the Tesseract functions in the list. You will have to scroll most of the way down that list, but I could find:

    TessBaseAPICreate
    TessBaseAPIExtractResult
    TessBaseAPIGetUTF8Text
    TessBaseAPIInit
    TessBaseAPIRecognizeImage
    TessBaseAPIRelease
    TessBaseAPISetVariable
    

    For further proof, I downloaded the source of Emgu (instructions here) and the Tesseract library was contained at \Emgu.CV.Extern\tesseract.

    The implementations of the above methods are in \Emgu.CV.Extern\tesseract\tesseract.cpp. Essentially they use the EmguTesseract class, which inherits from tesseract::TessBaseAPI.