fix.修复两个肉鸽闪退的问题

https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/669
This commit is contained in:
MistEO
2022-06-03 01:30:58 +08:00
parent 3517c4f173
commit 56983880d0
4 changed files with 29 additions and 3 deletions

View File

@@ -98,8 +98,6 @@ void asst::MatchImageAnalyzer::set_task_info(MatchTaskInfo task_info) noexcept
}
bool asst::MatchImageAnalyzer::match_templ(const cv::Mat templ)
{
cv::Mat matched;
if (m_roi.x < 0) {
Log.info("roi is out of range", m_roi.to_string());
m_roi.x = 0;
@@ -124,6 +122,8 @@ bool asst::MatchImageAnalyzer::match_templ(const cv::Mat templ)
"templ size:", templ.cols, templ.rows);
return false;
}
cv::Mat matched;
if (m_mask_range.first == 0 && m_mask_range.second == 0) {
cv::matchTemplate(image_roi, templ, matched, cv::TM_CCOEFF_NORMED);
}

View File

@@ -9,6 +9,8 @@
bool asst::OcrImageAnalyzer::analyze()
{
LogTraceFunction;
m_ocr_result.clear();
std::vector<TextRectProc> preds_vec;
@@ -67,6 +69,23 @@ bool asst::OcrImageAnalyzer::analyze()
}
}
if (need_local) {
if (m_roi.x < 0) {
Log.info("roi is out of range", m_roi.to_string());
m_roi.x = 0;
}
if (m_roi.y < 0) {
Log.info("roi is out of range", m_roi.to_string());
m_roi.y = 0;
}
if (m_roi.x + m_roi.width > m_image.cols) {
Log.info("roi is out of range", m_roi.to_string());
m_roi.width = m_image.cols - m_roi.x;
}
if (m_roi.y + m_roi.height > m_image.rows) {
Log.info("roi is out of range", m_roi.to_string());
m_roi.height = m_image.rows - m_roi.y;
}
m_ocr_result = Resrc.ocr().recognize(m_image, m_roi, all_pred, m_without_det);
}
//log.trace("ocr result", m_ocr_result);

View File

@@ -18,6 +18,13 @@ bool asst::RoguelikeSkillSelectionImageAnalyzer::analyze()
const auto& flags = flag_analyzer.get_result();
if (flags.size() > 13) {
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/669
// 不知道为什么会匹配出来一堆结果,得分完全相同,坐标间隔还特别有规律。这种情况直接报错然后重试
Log.error("Too many flags");
return false;
}
int unknow_index = 0;
for (const auto& flag : flags) {
std::string name = name_analyze(flag.rect);

View File

@@ -24,7 +24,7 @@ asst::RoguelikeTask::RoguelikeTask(AsstCallback callback, void* callback_arg)
m_recruit_task_ptr->set_retry_times(2);
m_skill_task_ptr = m_roguelike_task_ptr->regiseter_plugin<RoguelikeSkillSelectionTaskPlugin>();
m_skill_task_ptr->set_retry_times(0);
m_skill_task_ptr->set_retry_times(3);
// 这个任务如果卡住会放弃当前的肉鸽并重新开始,所以多添加一点。先这样凑合用
for (int i = 0; i != 10000; ++i) {