mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
fix: 修复掉落和仓库识别 mask 错误, 缩小 roi
This commit is contained in:
@@ -6598,7 +6598,7 @@
|
||||
22
|
||||
],
|
||||
"maskRange": [
|
||||
110,
|
||||
150,
|
||||
255
|
||||
]
|
||||
},
|
||||
@@ -6718,8 +6718,8 @@
|
||||
"DepotQuantity": {
|
||||
"template": "empty.png",
|
||||
"maskRange": [
|
||||
0,
|
||||
110
|
||||
110,
|
||||
255
|
||||
]
|
||||
},
|
||||
"DepotBegin": {
|
||||
|
||||
@@ -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<cv::Rect>(item.rect)), item_templ * 0.41,
|
||||
|
||||
@@ -569,6 +569,8 @@ std::optional<asst::TextRect> 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::TextRect> 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;
|
||||
|
||||
Reference in New Issue
Block a user