Fix vision pipeline: search-first IPM, IMU non-blocking, LCD inverse IPM, servo direction, model WIP

This commit is contained in:
2026-05-25 13:57:47 +08:00
parent 610f0a7549
commit 235ec4c41e
15 changed files with 260 additions and 87 deletions

View File

@@ -96,7 +96,7 @@ namespace {
void element_init()
{
std::memset(&g_elm, 0, sizeof(g_elm));
g_elm = ElementMachine{};
g_elm.state = TRACK_STRAIGHT;
g_elm.last_state = TRACK_STRAIGHT;
g_elm.normal_width = 50.0f;

View File

@@ -20,7 +20,7 @@ static constexpr float CAL_FAR_Y_MM = 1050.0f; // 矩形远边 Y (mm)
static constexpr float CAL_HALF_W_MM = 200.0f; // 矩形半宽 (mm)
static bool g_ipm_enabled = true; // 启用 IPM
static cv::Mat g_ipm_matrix; // 3×3 透视变换矩阵
cv::Mat g_ipm_matrix; // 3×3 透视变换矩阵 (extern)
void preprocess_init() {}
@@ -95,21 +95,6 @@ void preprocess_run(const cv::Mat& bgr_frame)
cv::resize(bgr_frame, small, cv::Size(PROC_W, PROC_H));
cv::Mat bin = track_binarize(small);
// IPM 透视校正 (首次调用时计算矩阵)
if (g_ipm_enabled)
{
if (g_ipm_matrix.empty())
init_ipm_calibration();
cv::Mat ipm_out;
cv::warpPerspective(bin, ipm_out, g_ipm_matrix,
cv::Size(PROC_W, PROC_H),
cv::INTER_LINEAR,
cv::BORDER_CONSTANT, cv::Scalar(0));
bin = ipm_out;
}
cv::Mat track = flood_fill_track(bin);
cv::Mat full;
cv::resize(track, full, cv::Size(IMAGE_WIDTH, IMAGE_HEIGHT), 0, 0, cv::INTER_NEAREST);

View File

@@ -3,8 +3,9 @@
#include "types.hpp"
void preprocess_init();
void preprocess_run(const cv::Mat& bgr_frame); // 全彩 HSV 二值化 + IPM
void preprocess_run(const cv::Mat& bgr_frame);
extern uint8 g_ipm_image[IMAGE_HEIGHT][IMAGE_WIDTH];
extern uint8 g_valid_l_bound[IMAGE_HEIGHT];
extern uint8 g_valid_r_bound[IMAGE_HEIGHT];
extern cv::Mat g_ipm_matrix; // 80x60 鸟瞰→相机 透视矩阵

View File

@@ -5,7 +5,7 @@
void search_init(SearchResult& r)
{
std::memset(&r, 0, sizeof(r));
r = SearchResult{};
}
void search_run(SearchResult& r)