From c60d25229b528362e4297592c51ad0f85f3ee10a Mon Sep 17 00:00:00 2001 From: Raul Tapia Date: Thu, 4 Jul 2024 16:25:50 +0200 Subject: [PATCH] Add ImageConstPtr to ros-cv-bridge --- include/rush/ros-cv-bridge.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/rush/ros-cv-bridge.hpp b/include/rush/ros-cv-bridge.hpp index f8b2c29..23fb315 100644 --- a/include/rush/ros-cv-bridge.hpp +++ b/include/rush/ros-cv-bridge.hpp @@ -87,6 +87,26 @@ inline cv::Mat ros2cv(const sensor_msgs::Image &ros) { return (cv_ptr->image); } +/** + * @brief Converts a ROS Image message to an OpenCV Mat. + * @param ros The input ROS Image message. + * @param cv The output OpenCV Mat. + * @note This function is provided for convenience when working with ImageConstPtr. + */ +inline void ros2cv(const sensor_msgs::ImageConstPtr &ros, cv::Mat &cv) { + ros2cv(*ros); +} + +/** + * @brief Converts a ROS Image message to an OpenCV Mat. + * @param ros The input ROS Image message. + * @return The output OpenCV Mat. + * @note This function is provided for convenience when working with ImageConstPtr. + */ +inline cv::Mat ros2cv(const sensor_msgs::ImageConstPtr &ros) { + return ros2cv(*ros); +} + /** * @brief This class extends ros::Publisher to directly publish OpenCV matrices. */