mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
fix: correct_rect在rect负方向完全越界时依旧输出非0宽度结果
This commit is contained in:
@@ -106,8 +106,13 @@ Rect VisionHelper::correct_rect(const Rect& rect, const cv::Mat& image)
|
||||
}
|
||||
res.x = std::clamp(res.x, 0, image.cols - 1);
|
||||
res.y = std::clamp(res.y, 0, image.rows - 1);
|
||||
res.width = std::clamp(res.width, 1, image.cols - res.x);
|
||||
res.height = std::clamp(res.height, 1, image.rows - res.y);
|
||||
res.width = std::clamp(res.width, 0, image.cols - res.x);
|
||||
res.height = std::clamp(res.height, 0, image.rows - res.y);
|
||||
|
||||
if (res.empty()) {
|
||||
Log.warn(__FUNCTION__, "roi is empty after correction");
|
||||
return { 1, 1, 0, 0 }; // 临时修复, 后续需调整默认rect的行为
|
||||
}
|
||||
|
||||
if (res != rect) {
|
||||
Log.warn(__FUNCTION__, "roi is out of range", image.cols, image.rows, rect.to_string(), "clamped");
|
||||
|
||||
Reference in New Issue
Block a user