Prevent crash when OCR traineddata file is missing

This commit is contained in:
WarmUpTill 2026-05-13 18:39:03 +02:00 committed by WarmUpTill
parent f42025c981
commit f4f92b29bf
3 changed files with 6 additions and 3 deletions

View File

@ -231,10 +231,9 @@ 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()) {
if (!ocr || image.isNull()) {
return {};
}

View File

@ -108,7 +108,10 @@ public:
void SetCustomConfigFile(const std::string &);
std::string GetCustomConfigFile() const { return configFile; }
tesseract::PageSegMode GetPageMode() const { return pageSegMode; }
tesseract::TessBaseAPI *GetOCR() const { return ocr.get(); }
tesseract::TessBaseAPI *GetOCR() const
{
return initDone ? ocr.get() : nullptr;
}
StringVariable text = obs_module_text("AdvSceneSwitcher.enterText");
RegexConfig regex = RegexConfig::PartialMatchRegexConfig();

View File

@ -391,6 +391,7 @@ void PreviewImage::MarkOCRMatch(QImage &screenshot,
if (!text) {
emit StatusUpdate(obs_module_text(
"AdvSceneSwitcher.condition.video.ocrMatchFail"));
return;
}
QString status(obs_module_text(