2 #include <opencv2/imgproc/imgproc.hpp> 3 #include <cv_bridge/cv_bridge.h> 12 cv_image = cv_bridge::toCvShare(message, tracked_object, message.encoding)->image;
14 catch (cv::Exception &e)
16 ROS_ERROR(
"Could not convert from '%s' to '%s'.", message.encoding.c_str(), message.encoding.c_str());
21 double subsampling_factor;
22 std::string param_name;
23 nh().
param<
double>(
"resized_image_transport_subsampling_factor", subsampling_factor, 2.0);
26 int new_width = cv_image.cols / subsampling_factor + 0.5;
27 int new_height = cv_image.rows / subsampling_factor + 0.5;
29 cv::resize(cv_image, buffer, cv::Size(new_width, new_height));
32 image_transport_tutorial::ResizedImage resized_image;
33 resized_image.original_height = cv_image.rows;
34 resized_image.original_width = cv_image.cols;
35 resized_image.image = *(cv_bridge::CvImage(message.header,
"bgr8", cv_image).toImageMsg());
36 publish_fn(resized_image);
const ros::NodeHandle & nh() const
Returns the ros::NodeHandle to be used for parameter lookup.
boost::function< void(const image_transport_tutorial::ResizedImage &)> PublishFn
Generic function for publishing the internal message type.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
virtual void publish(const sensor_msgs::Image &message, const PublishFn &publish_fn) const
Publish an image using the specified publish function. Must be implemented by the subclass...