fix: 博朗台计算等待时间失败数据处理

This commit is contained in:
status102
2025-01-06 20:02:15 +08:00
parent b49b1ee0f4
commit ace5129b3e
2 changed files with 5 additions and 1 deletions

View File

@@ -69,6 +69,7 @@ int asst::DrGrandetTaskPlugin::analyze_time_left(const cv::Mat& image)
analyzer.set_use_char_model(false);
if (!analyzer.analyze()) {
Log.warn(__FUNCTION__, "unable to analyze time");
return -1;
}
auto text = analyzer.get_result().front().text;
@@ -76,6 +77,7 @@ int asst::DrGrandetTaskPlugin::analyze_time_left(const cv::Mat& image)
auto regex = std::regex(R"((\d):(\d?)(\d?))");
std::smatch match;
if (!std::regex_search(text, match, regex)) {
Log.warn(__FUNCTION__, "Unable to match time:", text);
return -1;
}
std::string time = match.str(0);

View File

@@ -104,7 +104,9 @@ bool asst::MedicineCounterTaskPlugin::_run()
if (*sanity_target >= *sanity_max) [[unlikely]] {
auto waitTime = DrGrandetTaskPlugin::analyze_time_left(image);
sleep(waitTime);
if (waitTime > 0) {
sleep(waitTime);
}
}
}