Tesseract以外的其他语言iOS
问题描述:
我正在尝试使用Tesseract开放源代码来查看我是否可以编译和识别iPhone上的英文字符。我能够这样做。现在,我尝试包括“ita.traineddata”内tessdata和改变Tesseract以外的其他语言iOS
tess->Init([dataPath cStringUsingEncoding:NSUTF8StringEncoding], // Path to tessdata-no ending /.
"eng"); // ISO 639-3 string or NULL.
到
tess->Init([dataPath cStringUsingEncoding:NSUTF8StringEncoding], // Path to tessdata-no ending /.
"ita"); // ISO 639-3 string or NULL.
,但我得到这个错误: Error openning data file /var/mobile/Applications/A37DB8B7-2272-4F80-9836-0034CEB56CC5/Documents/tessdata/ita.traineddata
我缺少什么,如何会这样如何处理?
答
首先将tessdata添加到您的项目/项目名称文件夹中,然后(重要)转到目标/构建阶段/复制束资源并将tessdata文件夹添加为REFERENCE!
,然后初始化的正方体是这样的:
// Set up the tessdata path. This is included in the application bundle
// but is copied to the Documents directory on the first run.
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = ([documentPaths count] > 0) ? [documentPaths objectAtIndex:0] : nil;
NSString *dataPath = [documentPath stringByAppendingPathComponent:@"tessdata"];
NSFileManager *fileManager = [NSFileManager defaultManager];
// If the expected store doesn't exist, copy the default store.
if (![fileManager fileExistsAtPath:dataPath]) {
// get the path to the app bundle (with the tessdata dir)
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *tessdataPath = [bundlePath stringByAppendingPathComponent:@"tessdata"];
if (tessdataPath) {
[fileManager copyItemAtPath:tessdataPath toPath:dataPath error:NULL];
}
}
setenv("TESSDATA_PREFIX", [[documentPath stringByAppendingString:@"/"] UTF8String], 1);
// init the tesseract engine.
tesseract = new tesseract::TessBaseAPI();
tesseract->Init([dataPath cStringUsingEncoding:NSUTF8StringEncoding], "ita");
注:正方体初始化自己与英语为默认值,一旦我删除整个文件夹tessdata,它仍然没有eng.traineddata文件的工作,这就是为什么它适用于英语但不适用于意大利语培训数据,您的tessdata文件夹未正确初始化。
+0
尝试过,但这不工作,你能指导我一点。 – 2014-01-29 12:27:34
该文件是否存在? – 2011-06-01 01:21:20
是的,我确实有这个文件。 – renderman47 2011-06-01 21:34:40
如果你有答复plz分享 – 2014-01-29 12:26:25