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 7a6aaf0..e16b8ef 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 @@ -624,7 +624,12 @@ void ArmorYoloDetectorNode::performBinaryThresCalibration( // Get YOLO detection for ROIs auto yolo_objects = detector_->detectRaw(img); + + // If YOLO doesn't detect anything, stop calibration this frame + // Calibration will resume when YOLO detects again if (yolo_objects.empty()) { + FYT_INFO("armor_yolo_detect", "Calibration: waiting for YOLO detection..."); + calib_frame_count_ = 0; // Reset counter when YOLO loses detection return; } @@ -707,10 +712,11 @@ void ArmorYoloDetectorNode::performBinaryThresCalibration( } } - // Update binary threshold with optimal value + // Only count frames where we got valid YOLO detection calib_frame_count_++; + FYT_INFO("armor_yolo_detect", "Calibration progress: {}/10", calib_frame_count_); + if (calib_frame_count_ >= 10) { - // Use median of recent errors to confirm stable calibration calib_done_ = true; detector_->binary_thres = best_thres;