30 #include <opencv2/core/core.hpp> 39 #include <sensor_msgs/Image.h> 45 const cv::Scalar
NO_MASK = cv::Scalar(-1, -1, -1);
65 const sensor_msgs::ImageConstPtr &base_image,
66 const sensor_msgs::ImageConstPtr &top_image);
82 alpha_(DEFAULT_ALPHA_LEVEL),
105 priv.
param(
"mask_r", mask_r, -1.0);
106 priv.
param(
"mask_g", mask_g, -1.0);
107 priv.
param(
"mask_b", mask_b, -1.0);
110 if ((mask_r >= 0) && (mask_g >= 0) && (mask_b >= 0) &&
111 (mask_r <= 255) && (mask_g <= 255) && (mask_b <= 255))
117 ROS_ERROR(
"Mask color components must be in range [0,255]");
118 ROS_ERROR(
" Components were (%f, %f, %f)", mask_r, mask_g, mask_b);
140 const sensor_msgs::ImageConstPtr& base_image,
141 const sensor_msgs::ImageConstPtr& top_image)
151 base_image->encoding);
154 cv::Mat blended = cv::Mat::zeros(
155 cv_base_image->image.rows,
156 cv_base_image->image.cols,
157 cv_base_image->image.type());
166 cv_base_image->image,
175 cv_base_image->image,
181 cv_blended->image = blended;
182 cv_blended->encoding = cv_base_image->encoding;
183 cv_blended->header = cv_base_image->header;
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
const double DEFAULT_ALPHA_LEVEL
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, sensor_msgs::Image > ApproximateTimePolicy
image_transport::Publisher image_pub_
ros::NodeHandle & getNodeHandle() const
Publisher advertise(const std::string &base_topic, uint32_t queue_size, bool latch=false)
message_filters::Subscriber< sensor_msgs::Image > base_image_sub_
cv::Mat blend(const cv::Mat &src1, const cv::Mat &alpha1, const cv::Mat &src2, const cv::Mat &alpha2)
ros::NodeHandle & getPrivateNodeHandle() const
boost::shared_ptr< ApproximateTimeSync > image_sync_
void imageCallback(const sensor_msgs::ImageConstPtr &base_image, const sensor_msgs::ImageConstPtr &top_image)
cv::Mat overlayColor(const cv::Mat &src, const cv::Mat &mask, const cv::Scalar &color, double alpha)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
SWRI_NODELET_EXPORT_CLASS(swri_image_util, DrawPolygonNodelet)
message_filters::Subscriber< sensor_msgs::Image > top_image_sub_
void publish(const sensor_msgs::Image &message) const
void subscribe(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::TransportHints &transport_hints=ros::TransportHints(), ros::CallbackQueueInterface *callback_queue=0)
message_filters::Synchronizer< ApproximateTimePolicy > ApproximateTimeSync