perf: 地图截图使用 360p 保存坐标点,节省储存空间

This commit is contained in:
uye
2025-05-20 19:37:28 +08:00
parent 12400f2415
commit ea041f477d

View File

@@ -714,17 +714,29 @@ void asst::BattleHelper::save_map(const cv::Mat& image)
using namespace asst::utils::path_literals;
const auto& MapRelativeDir = "debug"_p / "map"_p;
auto draw = image.clone();
constexpr float scale_factor = 0.5;
cv::Mat resized;
cv::resize(image, resized, cv::Size(), scale_factor, scale_factor, cv::INTER_AREA);
for (const auto& [loc, info] : m_normal_tile_info) {
cv::circle(draw, cv::Point(info.pos.x, info.pos.y), 5, cv::Scalar(0, 255, 0), -1);
cv::putText(draw, loc.to_string(), cv::Point(info.pos.x - 30, info.pos.y), 1, 1.2, cv::Scalar(0, 0, 255), 2);
cv::Point scaled_pos(static_cast<int>(info.pos.x * scale_factor), static_cast<int>(info.pos.y * scale_factor));
cv::circle(resized, scaled_pos, static_cast<int>(5 * scale_factor), cv::Scalar(0, 255, 0), -1);
cv::putText(
resized,
loc.to_string(),
cv::Point(static_cast<int>(scaled_pos.x - (40 * scale_factor)), scaled_pos.y),
1,
1.5 * scale_factor,
cv::Scalar(0, 0, 255),
static_cast<int>(2 * scale_factor));
}
std::string suffix;
if (++m_camera_count > 1) {
suffix = "-" + std::to_string(m_camera_count);
}
asst::imwrite(MapRelativeDir / asst::utils::path(m_stage_name + suffix + ".png"), draw);
std::vector<int> png_params = { cv::IMWRITE_PNG_COMPRESSION, 9 };
asst::imwrite(MapRelativeDir / asst::utils::path(m_stage_name + suffix + ".png"), resized, png_params);
}
bool asst::BattleHelper::click_oper_on_deployment(const std::string& name)