2 #include <opencv2/imgproc/imgproc.hpp>
3 #include <cv_bridge/cv_bridge.h>
6 const PublishFn& publish_fn)
const
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);