Do not crash if tesseract init fails.

This commit is contained in:
Damiano Galassi committed 2021-12-09 20:10:06 +01:00
1 parent 9732c64bd5
commit 653d077b1f
1 file changed
+10 -2
+10 -2
View File
@@ -25,7 +25,10 @@ public:
path = [[NSBundle bundleForClass:[MP42OCRWrapper class]].bundlePath stringByAppendingString:@"/Versions/A/Resources/tessdata/"].fileSystemRepresentation;
}
tess_base_api.Init(path, lang.UTF8String, mode);
int result = tess_base_api.Init(path, lang.UTF8String, mode);
if (result == -1) {
throw EIO;
}
}
}
@@ -109,7 +112,12 @@ MP42_OBJC_DIRECT_MEMBERS
dataURL = nil;
}
tess_base = new OCRWrapper(lang, dataURL, mode);
try {
tess_base = new OCRWrapper(lang, dataURL, mode);
}
catch(int e) {
tess_base = new OCRWrapper(@"eng", nil, OEM_LSTM_ONLY);
}
}
return self;
}