Skip to content

Commit a1cf5e5

Browse files
committed
fix: 修正排序算法
1 parent ef0da72 commit a1cf5e5

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

source/MaaFramework/Vision/VisionUtils.hpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@
99

1010
MAA_VISION_NS_BEGIN
1111

12-
// | 1 2 3 4 |
13-
// | 5 6 7 8 |
12+
// | 1 3 5 7 |
13+
// | 2 4 6 8 |
1414
template <typename ResultsVec>
1515
inline static void sort_by_horizontal_(ResultsVec& results)
1616
{
1717
std::ranges::sort(results, [](const auto& lhs, const auto& rhs) -> bool {
18-
// y 差距较小则理解为是同一排的,按x排序
19-
return std::abs(lhs.box.y - rhs.box.y) < 5 ? lhs.box.x < rhs.box.x : lhs.box.y < rhs.box.y;
18+
return lhs.box.x == rhs.box.x ? lhs.box.y < rhs.box.y : lhs.box.x < rhs.box.x;
2019
});
2120
}
2221

23-
// | 1 3 5 7 |
24-
// | 2 4 6 8 |
22+
// | 1 2 3 4 |
23+
// | 5 6 7 8 |
2524
template <typename ResultsVec>
2625
inline static void sort_by_vertical_(ResultsVec& results)
2726
{
2827
std::ranges::sort(results, [](const auto& lhs, const auto& rhs) -> bool {
29-
// x 差距较小则理解为是同一排的,按y排序
30-
return std::abs(lhs.box.x - rhs.box.x) < 5 ? lhs.box.y < rhs.box.y : lhs.box.x < rhs.box.x;
28+
return lhs.box.y == rhs.box.y ? lhs.box.x < rhs.box.x : lhs.box.y < rhs.box.y;
3129
});
3230
}
3331

0 commit comments

Comments
 (0)