From 3053029f140de11fae01e6f54a3377dd45eaeed2 Mon Sep 17 00:00:00 2001 From: lyf <169361657@qq.com> Date: Sun, 30 Nov 2025 21:26:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=99=E9=87=8C=E5=AF=B9=E4=BA=8Ettl?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9A=84=E5=AD=97=E7=AC=A6=E5=BD=A2=E5=BC=8F?= =?UTF-8?q?=E5=81=9A=E5=87=BA=E6=94=B9=E5=8F=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MindVisionMain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MindVisionMain.cpp b/src/MindVisionMain.cpp index 1250ebc..7ce0269 100644 --- a/src/MindVisionMain.cpp +++ b/src/MindVisionMain.cpp @@ -25,7 +25,7 @@ void output_control_data(const cv::Point2f* ballistic_point, bool use_ttl) { // Only send data when TTL is enabled, meets frame interval, and has valid target if (use_ttl && frame_counter % 5 == 0 && ballistic_point != nullptr) { - std::string send_str; + std::ostringstream send_str; // Calculate offset (based on actual image center) int ballistic_offset_x = static_cast(ballistic_point->x - img_center.x); @@ -37,11 +37,13 @@ void output_control_data(const cv::Point2f* ballistic_point, else if (target_color == "blue") simplified_color = "b"; // Construct send string - send_str = "s " + simplified_color + " " + std::to_string(ballistic_offset_x) + " " + std::to_string(ballistic_offset_y); + send_str << "s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y); // Send data if (ttl_communicator != nullptr) { - ttl_communicator->send_data(send_str); + ttl_communicator->send_data(send_str.str()); + }else{ + std::cerr << "Error: TTLCommunicator is a null pointer!" << std::endl; } } }