fix: 修复待部署区干员费用不识别的错误

This commit is contained in:
status102
2023-11-22 09:36:34 +08:00
parent 801bf1b7f4
commit 55bfc531ae
2 changed files with 20 additions and 5 deletions

View File

@@ -8340,9 +8340,8 @@
"BattleOperRoleTank": {},
"BattleOperRoleWarrior": {},
"BattleOperRoleDrone": {},
"BattleOperCostRange": {
"algorithm": "Hash",
"hash": [],
"BattleOperCost": {
"template": "empty.png",
"rectMove": [
-10,
12,

View File

@@ -90,6 +90,7 @@ std::vector<battle::DeploymentOper> BattlefieldMatcher::deployment_analyze() con
const Rect& avlb_move = Task.get("BattleOperAvailable")->rect_move;
const Rect& cooling_move = Task.get("BattleOperCooling")->rect_move;
const Rect& avatar_move = Task.get("BattleOperAvatar")->rect_move;
const Rect& cost_move = Task.get("BattleOperCost")->rect_move;
std::vector<battle::DeploymentOper> oper_result;
size_t index = 0;
@@ -128,6 +129,9 @@ std::vector<battle::DeploymentOper> BattlefieldMatcher::deployment_analyze() con
Log.error("oper is available, but with cooling");
}
Rect cost_rect = correct_rect(flag_res.rect.move(cost_move), m_image);
oper.cost = oper_cost_analyze(cost_rect);
oper.index = index++;
oper_result.emplace_back(std::move(oper));
@@ -205,8 +209,20 @@ bool BattlefieldMatcher::oper_cooling_analyze(const Rect& roi) const
int BattlefieldMatcher::oper_cost_analyze(const Rect& roi) const
{
std::ignore = roi;
return 0;
int cost = -1;
RegionOCRer cost_analyzer(m_image, roi);
cost_analyzer.set_replace(Task.get<OcrTaskInfo>("NumberOcrReplace")->replace_map);
cost_analyzer.set_use_char_model(true);
cost_analyzer.set_bin_threshold(80, 255);
if (!cost_analyzer.analyze()) {
Log.warn("oper cost analyze failed");
return cost;
}
if (!utils::chars_to_number(cost_analyzer.get_result().text, cost)) {
Log.warn("oper cost convert failed, str:", cost_analyzer.get_result().text);
return cost;
}
return cost;
}
bool BattlefieldMatcher::oper_available_analyze(const Rect& roi) const