diff --git a/plugins/video/opencv-helpers.cpp b/plugins/video/opencv-helpers.cpp index bd5ac933..92f80a3f 100644 --- a/plugins/video/opencv-helpers.cpp +++ b/plugins/video/opencv-helpers.cpp @@ -231,10 +231,9 @@ std::optional 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 {}; } diff --git a/plugins/video/parameter-wrappers.hpp b/plugins/video/parameter-wrappers.hpp index a2421f27..04ad2dc2 100644 --- a/plugins/video/parameter-wrappers.hpp +++ b/plugins/video/parameter-wrappers.hpp @@ -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(); diff --git a/plugins/video/preview-dialog.cpp b/plugins/video/preview-dialog.cpp index 844ccebd..e3f28f4a 100644 --- a/plugins/video/preview-dialog.cpp +++ b/plugins/video/preview-dialog.cpp @@ -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(