| 216 | Tesseract::~Tesseract() = default; |
| 217 | |
| 218 | void Tesseract::init(const LanguageId &language, const QString &tessdataPath) |
| 219 | { |
| 220 | SOFT_ASSERT(!api_, return ); |
| 221 | |
| 222 | api_ = std::make_unique<tesseract::TessBaseAPI>(); |
| 223 | LTRACE() << "Created Tesseract api" << api_.get(); |
| 224 | |
| 225 | const auto tesseractName = LanguageCodes::tesseract(language); |
| 226 | auto result = api_->Init(qPrintable(tessdataPath), qPrintable(tesseractName), |
| 227 | tesseract::OcrEngineMode::OEM_DEFAULT); |
| 228 | LTRACE() << "Inited Tesseract api" << result; |
| 229 | if (result == 0) |
| 230 | return; |
| 231 | |
| 232 | api_->SetPageSegMode(tesseract::PageSegMode::PSM_AUTO); |
| 233 | |
| 234 | error_ = QObject::tr("init failed"); |
| 235 | api_.reset(); |
| 236 | LTRACE() << "Cleared Tesseract api"; |
| 237 | } |
| 238 | |
| 239 | const QString &Tesseract::error() const |
| 240 | { |