MCPcopy Create free account
hub / github.com/OneMoreGres/ScreenTranslator / init

Method init

src/ocr/tesseract.cpp:218–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216Tesseract::~Tesseract() = default;
217
218void 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
239const QString &Tesseract::error() const
240{

Callers

nothing calls this directly

Calls 2

InitMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected