diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 132d1895..3635b35e 100644 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -1810,10 +1810,13 @@ bool OBCameraNode::decodeColorFrameToBuffer(const std::shared_ptr &fr } CHECK_NOTNULL(image_publishers_[COLOR]); bool has_subscriber = image_publishers_[COLOR]->get_subscription_count() > 0; - if (camera_h26x_publishers_[COLOR] && - camera_h26x_publishers_[COLOR]->get_subscription_count() > 0) { - has_subscriber = true; + if (!camera_h26x_publishers_.empty()) { + if (camera_h26x_publishers_[COLOR] && + camera_h26x_publishers_[COLOR]->get_subscription_count() > 0) { + has_subscriber = true; + } } + if (enable_colored_point_cloud_ && depth_registration_cloud_pub_->get_subscription_count() > 0) { has_subscriber = true; } @@ -1909,8 +1912,12 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, has_subscriber = has_subscriber || (metadata_publishers_.count(stream_index) && metadata_publishers_[stream_index]->get_subscription_count() > 0); - has_subscriber = has_subscriber || (camera_h26x_publishers_[COLOR] && - camera_h26x_publishers_[COLOR]->get_subscription_count() > 0); + if (!camera_h26x_publishers_.empty()) { + has_subscriber = + has_subscriber || (camera_h26x_publishers_[COLOR] && + camera_h26x_publishers_[COLOR]->get_subscription_count() > 0); + } + if (!has_subscriber) { return; } @@ -1989,7 +1996,9 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, publishMetadata(frame, stream_index, camera_info.header); } CHECK_NOTNULL(image_publishers_[stream_index]); + if (image_publishers_[stream_index]->get_subscription_count() == 0 && + !camera_h26x_publishers_.empty() && (!camera_h26x_publishers_[COLOR] && camera_h26x_publishers_[COLOR]->get_subscription_count() == 0)) { return;