35 #include <dynamic_reconfigure/server.h> 39 #include <sensor_msgs/CameraInfo.h> 40 #include <sensor_msgs/Image.h> 42 #include "image_proc/ResizeConfig.h" 58 typedef image_proc::ResizeConfig
Config;
67 void imageCb(
const sensor_msgs::ImageConstPtr& image_msg);
68 void infoCb(
const sensor_msgs::CameraInfoConstPtr& info_msg);
70 void configCb(Config &config, uint32_t level);
82 pub_info_ = advertise<sensor_msgs::CameraInfo>(*
pnh_,
"camera_info", 1);
109 boost::lock_guard<boost::recursive_mutex> lock(
config_mutex_);
113 sensor_msgs::CameraInfo dst_info_msg = *info_msg;
117 if (config.use_scale)
119 scale_y = config.scale_height;
120 scale_x = config.scale_width;
121 dst_info_msg.height =
static_cast<int>(info_msg->height * config.scale_height);
122 dst_info_msg.width =
static_cast<int>(info_msg->width * config.scale_width);
126 scale_y =
static_cast<double>(config.height) / info_msg->height;
127 scale_x = static_cast<double>(config.width) / info_msg->width;
128 dst_info_msg.height = config.height;
129 dst_info_msg.width = config.width;
132 dst_info_msg.K[0] = dst_info_msg.K[0] * scale_x;
133 dst_info_msg.K[2] = dst_info_msg.K[2] * scale_x;
134 dst_info_msg.K[4] = dst_info_msg.K[4] * scale_y;
135 dst_info_msg.K[5] = dst_info_msg.K[5] * scale_y;
137 dst_info_msg.P[0] = dst_info_msg.P[0] * scale_x;
138 dst_info_msg.P[2] = dst_info_msg.P[2] * scale_x;
139 dst_info_msg.P[3] = dst_info_msg.P[3] * scale_x;
140 dst_info_msg.P[5] = dst_info_msg.P[5] * scale_y;
141 dst_info_msg.P[6] = dst_info_msg.P[6] * scale_y;
150 boost::lock_guard<boost::recursive_mutex> lock(
config_mutex_);
156 if (config.use_scale)
158 cv::resize(cv_ptr->image, cv_ptr->image, cv::Size(0, 0),
159 config.scale_width, config.scale_height, config.interpolation);
163 int height = config.height == -1 ? image_msg->height : config.height;
164 int width = config.width == -1 ? image_msg->width : config.width;
165 cv::resize(cv_ptr->image, cv_ptr->image, cv::Size(width, height), 0, 0, config.interpolation);
void imageCb(const sensor_msgs::ImageConstPtr &image_msg)
void publish(const boost::shared_ptr< M > &message) const
boost::shared_ptr< ReconfigureServer > reconfigure_server_
void infoCb(const sensor_msgs::CameraInfoConstPtr &info_msg)
void configCb(Config &config, uint32_t level)
dynamic_reconfigure::Server< Config > ReconfigureServer
ros::Publisher pub_image_
PLUGINLIB_EXPORT_CLASS(image_proc::CropNonZeroNodelet, nodelet::Nodelet)
ros::Subscriber sub_info_
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
image_proc::ResizeConfig Config
boost::recursive_mutex config_mutex_
virtual void unsubscribe()
ros::Subscriber sub_image_