Skip to content

Commit

Permalink
fix: 重新实现重试算法
Browse files Browse the repository at this point in the history
  • Loading branch information
Sallee1 committed Jun 1, 2023
1 parent bb4cedd commit 54f5213
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
29 changes: 17 additions & 12 deletions cvAutoTrack/src/match/surf/SurfMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,31 @@ void SurfMatch::match()
is_success_match = false;
return;
}
continuity_retry = max_continuity_retry - 1; //全局检测后只局部检测一次
}

// 尝试连续匹配,匹配角色附近小范围区域
for (int retry_times = 1; retry_times <= max_continuity_retry; retry_times++)
bool calc_continuity_is_faile = false;
pos = match_continuity(calc_continuity_is_faile);

if (!calc_continuity_is_faile)
{
isContinuity = true;
continuity_retry = 0;
}
else
{
bool calc_continuity_is_faile = false;
pos = match_continuity(calc_continuity_is_faile);
pos = last_pos;
is_success_match = false;
continuity_retry++;

if (!calc_continuity_is_faile)
{
isContinuity = true;
break; //匹配成功,结束,否则重试
}
else if (retry_times == max_continuity_retry)
if (continuity_retry >= max_continuity_retry)
{
pos = last_pos;
isContinuity = false;
is_success_match = false;
return;
continuity_retry = 0;
}

return;
}
last_pos = pos;
is_success_match = true;
Expand Down
5 changes: 3 additions & 2 deletions cvAutoTrack/src/match/surf/SurfMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SurfMatch


cv::Point2d pos;
cv::Point2d last_pos; // 上一次匹配的地点,如果匹配失败,则返回上一次的结果,防止瞬移
cv::Point2d last_pos; // 上一次匹配的地点,匹配失败,返回上一次的结果
cv::Rect rect_continuity_map;
public:
SurfMatch() = default;
Expand All @@ -72,7 +72,8 @@ class SurfMatch
bool isCoveying = false;
bool isOnCity = false;

int max_continuity_retry = 3;
int continuity_retry = 0; //局部匹配重试次数
const int max_continuity_retry = 3; //最大重试次数

bool is_success_match = false;

Expand Down
2 changes: 1 addition & 1 deletion cvAutoTrack/src/version/version_tag.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.8.83
7.8.90

0 comments on commit 54f5213

Please sign in to comment.