diff --git a/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector.hpp b/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector.hpp index 2babdb6..e90af7e 100644 --- a/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector.hpp +++ b/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector.hpp @@ -120,6 +120,7 @@ public: // Debug bool enable_debug = false; cv::Mat debug_img; + cv::Mat debug_binary_img; // Store ROI rectangles for debug drawing std::vector debug_rois_; diff --git a/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp b/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp index ffc1f4d..ecb1878 100644 --- a/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp +++ b/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp @@ -99,6 +99,7 @@ private: // Image transport for debug image_transport::Publisher result_img_pub_; + image_transport::Publisher binary_img_pub_; // TF std::shared_ptr tf2_buffer_; diff --git a/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector.cpp b/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector.cpp index c009e14..0b5512e 100644 --- a/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector.cpp +++ b/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector.cpp @@ -71,6 +71,11 @@ std::vector Detector::detect(const cv::Mat& input) { cv::Mat full_binary_img; cv::threshold(gray_img, full_binary_img, binary_thres, 255, cv::THRESH_BINARY); + // Store binary image for debug visualization + if (enable_debug) { + debug_binary_img = full_binary_img.clone(); + } + uint64_t current_frame = frame_counter_.fetch_add(1, std::memory_order_relaxed); // Update YOLO objects based on mode diff --git a/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp b/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp index e3689a3..860673f 100644 --- a/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp +++ b/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp @@ -437,6 +437,12 @@ std::vector ArmorYoloDetectorNode::detectArmors( // Publish result image result_img_pub_.publish( cv_bridge::CvImage(img_msg->header, "bgr8", detector_->debug_img).toImageMsg()); + + // Publish binary image if available + if (!detector_->debug_binary_img.empty()) { + binary_img_pub_.publish( + cv_bridge::CvImage(img_msg->header, "mono8", detector_->debug_binary_img).toImageMsg()); + } } if (debug_publish_ms != nullptr) { @@ -554,10 +560,12 @@ void ArmorYoloDetectorNode::setModeCallback( void ArmorYoloDetectorNode::createDebugPublishers() { result_img_pub_ = image_transport::create_publisher(this, "armor_detector/result_img"); + binary_img_pub_ = image_transport::create_publisher(this, "armor_detector/binary_img"); } void ArmorYoloDetectorNode::destroyDebugPublishers() { result_img_pub_.shutdown(); + binary_img_pub_.shutdown(); } void ArmorYoloDetectorNode::refreshDebugPublishersIfNeeded() {