diff --git a/resource/tasks.json b/resource/tasks.json index 8f851a9e4d..97592f7346 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -6598,7 +6598,7 @@ 22 ], "maskRange": [ - 110, + 150, 255 ] }, @@ -6718,8 +6718,8 @@ "DepotQuantity": { "template": "empty.png", "maskRange": [ - 0, - 110 + 110, + 255 ] }, "DepotBegin": { diff --git a/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp index 8b09a84d70..17d324ca18 100644 --- a/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp +++ b/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp @@ -239,9 +239,11 @@ int asst::DepotImageAnalyzer::match_quantity(const ItemInfo& item) cv::morphologyEx(mask, mask, cv::MORPH_OPEN, cv::getStructuringElement(cv::MORPH_RECT, { 4, 4 })); auto mask_rect = cv::boundingRect(mask); + mask_rect.width -= 1; + mask_rect.height -= 1; if (mask_rect.height < 18) mask_rect.height = 18; // minus 1 to trim white pixels - Rect ocr_roi { item.rect.x + mask_rect.x, item.rect.y + mask_rect.y, mask_rect.width - 1, mask_rect.height - 1 }; + Rect ocr_roi { item.rect.x + mask_rect.x, item.rect.y + mask_rect.y, mask_rect.width, mask_rect.height }; cv::Mat ocr_img = m_image_resized.clone(); cv::subtract(m_image_resized(make_rect(item.rect)), item_templ * 0.41, diff --git a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp index 5b256b912f..4857952c1e 100644 --- a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp +++ b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp @@ -569,6 +569,8 @@ std::optional asst::StageDropsImageAnalyzer::match_quantity_stri cv::morphologyEx(mask, mask, cv::MORPH_OPEN, cv::getStructuringElement(cv::MORPH_RECT, { 4, 4 })); auto mask_rect = cv::boundingRect(mask); + mask_rect.width -= 1; + mask_rect.height -= 1; if (mask_rect.height < 20) mask_rect.height = 20; cv::Mat ocr_img = m_image.clone(); @@ -578,7 +580,7 @@ std::optional asst::StageDropsImageAnalyzer::match_quantity_stri ocr.set_task_info("StageDrops-NumberOcrReplace"); Rect ocr_roi { new_roi.x + mask_rect.x, new_roi.y + mask_rect.y, mask_rect.width, mask_rect.height }; ocr.set_roi(ocr_roi); - ocr.set_threshold(task_ptr->mask_range.first, task_ptr->mask_range.second); + ocr.set_threshold(110, 255); // TODO: do not hardcode if (!ocr.analyze()) { return std::nullopt;