I'm trying to use tesseract in my Mac application. Therefore I compiled leptonica and tesseract, copied all header-files and the .a-files to my project.

Afterwards I renamed the AppDelegate.m file to AppDelegate.mm.

Now I'm trying to use tesseract like this:

#include "baseapi.h"
...
tesseract::TessBaseAPI *tess = new tesseract::TessBaseAPI();
tess->Init([[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"tessdata"], "eng");

Unfortunately at the second line I'm getting the error:

"No matching member function for call to 'Init'"

What am I doing wrong? Did I make a mistake at compiling?

Here is my compiling bash-script: bash-script link

有帮助吗?

解决方案

Looking at some Documentation for your api the best matching signature is

int Init (const char *datapath, const char *language)

In your case you are passing this

[[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"tessdata"]

which returns an NSString *, not a const char ptr

try this instead

tess->Init([[[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"tessdata"] UTF8String], "eng");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top