Publish the last set images.
| 878 | |
| 879 | // Publish the last set images. |
| 880 | void Publisher::publishImages() { |
| 881 | // advertise what's been missing: |
| 882 | if (images_.size() != pubImagesVector_.size()) { |
| 883 | pubImagesVector_.clear(); |
| 884 | for (size_t i = 0; i < images_.size(); ++i) { |
| 885 | std::stringstream drawingNameStream; |
| 886 | drawingNameStream << "okvis_drawing_" << i; |
| 887 | pubImagesVector_.push_back(image_transport_.advertise(drawingNameStream.str(), 10)); |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | // publish: |
| 892 | for (size_t i = 0; i < images_.size(); ++i) { |
| 893 | sensor_msgs::msg::Image msg; |
| 894 | std::stringstream cameraNameStream; |
| 895 | cameraNameStream << "camera_" << i; |
| 896 | msg.header.stamp = node_->get_clock()->now(); |
| 897 | msg.header.frame_id = cameraNameStream.str(); |
| 898 | sensor_msgs::fillImage(msg, |
| 899 | sensor_msgs::image_encodings::MONO8, |
| 900 | images_[i].rows, |
| 901 | images_[i].cols, |
| 902 | images_[i].step.buf[0], |
| 903 | images_[i].data); |
| 904 | pubImagesVector_[i].publish(msg); |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | // Publish the last set path. |
| 909 | void Publisher::publishPath() { pubPath_->publish(path_); } |