fix: 关卡内教程降低暂停按钮亮度,导致无法识别

This commit is contained in:
status102
2025-05-19 12:45:38 +08:00
parent f76db36364
commit aa46d668d1
5 changed files with 25 additions and 10 deletions

View File

@@ -4600,8 +4600,8 @@
"BattleHasStarted": {
"template": "empty.png",
"roi": [1178, 33, 49, 39],
"specialParams_Doc": "亮度阈值点的数量",
"specialParams": [245, 200]
"specialParams_Doc": "亮度阈值; 点的数量; 存在剧情提示时备用阈值",
"specialParams": [245, 200, 125, 130]
},
"BattleSpeedButton": {
"template": "empty.png",

View File

@@ -581,7 +581,7 @@ bool asst::BattleHelper::check_in_battle(const cv::Mat& reusable, bool weak)
BattlefieldMatcher analyzer(image);
m_in_battle = analyzer.analyze().has_value();
}
else {
else { // init时, weak = false
check_skip_plot_button(image);
m_in_battle = check_pause_button(image);
}

View File

@@ -436,7 +436,7 @@ bool asst::BattleProcessTask::check_in_battle(const cv::Mat& reusable, bool weak
m_in_battle = result.has_value();
if (m_in_battle && !result->pause_button) {
if (check_skip_plot_button(image) && check_in_speed_up(image)) {
speed_up();
speed_up(); // 跳过剧情后, 方舟会自动恢复1倍速, 如果是2倍速就恢复一下
}
}
}

View File

@@ -354,14 +354,28 @@ bool BattlefieldMatcher::pause_button_analyze() const
{
auto task_ptr = Task.get("BattleHasStarted");
cv::Mat roi = m_image(make_rect<cv::Rect>(task_ptr->roi));
cv::Mat roi_gray;
cv::Mat roi_gray, bin;
cv::cvtColor(roi, roi_gray, cv::COLOR_BGR2GRAY);
cv::Mat bin;
double min_val = 0.0, max_val = 0.0;
cv::Point min_loc, max_loc;
cv::minMaxLoc(roi_gray, &min_val, &max_val, &min_loc, &max_loc);
const int value_threshold = task_ptr->special_params[0];
cv::threshold(roi_gray, bin, value_threshold, 255, cv::THRESH_BINARY);
int count = cv::countNonZero(bin);
const int count_threshold = task_ptr->special_params[1];
Log.trace(__FUNCTION__, "count", count, "threshold", count_threshold);
int count;
if (max_val > value_threshold) {
cv::threshold(roi_gray, bin, value_threshold, 255, cv::THRESH_BINARY);
count = cv::countNonZero(bin);
}
else {
cv::inRange(
roi_gray,
cv::Scalar::all(task_ptr->special_params[2]),
cv::Scalar::all(task_ptr->special_params[3]),
bin);
count = cv::countNonZero(bin);
}
#ifdef ASST_DEBUG
cv::rectangle(m_image_draw, make_rect<cv::Rect>(task_ptr->roi), cv::Scalar(0, 0, 255), 2);

View File

@@ -30,7 +30,7 @@ public:
// bool in_detail = false;
bool speed_button = false;
bool pause_button = false;
bool pause_button = false; // 是否有暂停/恢复按钮
};
using ResultOpt = std::optional<Result>;
@@ -47,6 +47,7 @@ public:
protected:
bool hp_flag_analyze() const;
bool kills_flag_analyze() const;
// 判断是否存在暂停/恢复按钮
bool pause_button_analyze() const;
std::vector<battle::DeploymentOper> deployment_analyze() const; // 识别干员