diff --git a/src/MindVisionMain.cpp b/src/MindVisionMain.cpp index 0b1a1c6..2bef31b 100644 --- a/src/MindVisionMain.cpp +++ b/src/MindVisionMain.cpp @@ -80,7 +80,7 @@ void output_control_data(const cv::Point2f* ballistic_point, // Calculate offset (based on actual image center) float raw_offset_x = -(ballistic_point->x - img_center.x); // yaw error - float raw_offset_y = -(img_center.y - ballistic_point->y - 30); // pitch error + float raw_offset_y = -(img_center.y - ballistic_point->y ); // pitch error // Calculate time delta static auto last_time = std::chrono::high_resolution_clock::now(); @@ -416,6 +416,17 @@ int main(int /*argc*/, char* /*argv*/[]) { frame_counter++; + float area = 0.0; + if (!armor_plates.empty()) { + // 获取装甲板配对的第一个灯条 + const LightBar& light_bar = armor_plates[0].pair.first; + // 直接使用灯条的area(即rect_area)赋值 + area = light_bar.area; + // 额外校验:确保灯条面积有效(避免负数/0值) + if (area <= 0) { + area = 0.0f; + } + } // Control max frame rate (100 FPS) auto end_time = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast(end_time - current_time).count();