Add tesseract config file support

This commit is contained in:
warmuptill
2025-05-13 08:59:21 +02:00
committed by WarmUpTill
parent 5490fabf92
commit 0e5f56b562
15 changed files with 384 additions and 284 deletions

View File

@@ -202,14 +202,15 @@ cv::Mat PreprocessForOCR(const QImage &image, const QColor &textColor,
return result;
}
std::string RunOCR(tesseract::TessBaseAPI *ocr, const QImage &image,
const QColor &color, double colorDiff)
std::optional<std::string> RunOCR(tesseract::TessBaseAPI *ocr,
const QImage &image, const QColor &color,
double colorDiff)
{
(void)ocr;
(void)color;
(void)colorDiff;
if (image.isNull()) {
return "";
return {};
}
#ifdef OCR_SUPPORT
@@ -221,12 +222,12 @@ std::string RunOCR(tesseract::TessBaseAPI *ocr, const QImage &image,
std::unique_ptr<char[]> detectedText(ocr->GetUTF8Text());
if (!detectedText) {
return "";
return {};
}
return detectedText.get();
#else
return "";
return {};
#endif
}