fix: improve post processing in depot item quantity match

fix #4057
This commit is contained in:
Horror Proton
2023-03-24 19:51:40 +08:00
parent 5ee9f6bcd2
commit b7e026ea19

View File

@@ -241,9 +241,13 @@ int asst::DepotImageAnalyzer::match_quantity(const ItemInfo& item)
auto mask_rect = cv::boundingRect(mask);
mask_rect.width -= 1;
mask_rect.height -= 1;
if (mask_rect.height < 18) mask_rect.height = 18;
const auto mid_x = mask.cols / 2; // center of image
if (mask_rect.br().x - mid_x < 30) mask_rect.width = mid_x + 30 - mask_rect.x;
// minus 1 to trim white pixels
Rect ocr_roi { item.rect.x + mask_rect.x, item.rect.y + mask_rect.y, mask_rect.width, mask_rect.height };
Rect ocr_roi { item.rect.x + mask_rect.x, item.rect.y + mask_rect.y, mask_rect.width - 1, mask_rect.height - 1 };
cv::Mat ocr_img = m_image_resized.clone();
cv::subtract(m_image_resized(make_rect<cv::Rect>(item.rect)), item_templ * 0.41,