39 #include <opencv2/opencv.hpp>
50 DiagnosticNodelet::onInit();
51 pub_out_ = advertise<sensor_msgs::Image>(*pnh_,
"output", 1);
74 if (!pnh_->getParam(
"input_topics", input_topics))
81 NODELET_ERROR(
"Invalid type of '~input_topics' is specified. String array is expected.");
92 sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
93 sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image> >(
queue_size_));
98 sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
99 sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image> > (
queue_size_));
103 ROS_INFO(
"Subscribing to %d topics user given topics as inputs:", input_topics.
size());
104 for (
size_t i = 0;
i < input_topics.
size ();
i++)
114 if (input_topics.
size() == 2)
125 else if (input_topics.
size() == 3)
136 else if (input_topics.
size() == 4)
147 else if (input_topics.
size() == 5)
158 else if (input_topics.
size() == 6)
171 else if (input_topics.
size() == 7)
184 else if (input_topics.
size() == 8)
199 NODELET_ERROR(
"Invalid number of topics is specified: %d. It must be > 1 and <= 8.", input_topics.
size());
215 for (
size_t i = 0;
i <
filters_.size();
i++) {
221 const sensor_msgs::Image::ConstPtr& in,
222 const int height_expected,
223 const int width_expected,
224 std::vector<cv::Mat>& inputs)
226 if (in->height == 0 && in->width == 0)
231 if (in->height != height_expected || in->width != width_expected)
234 height_expected, width_expected);
240 encoding_.c_str(), in->encoding.c_str());
248 const sensor_msgs::Image::ConstPtr& in1,
const sensor_msgs::Image::ConstPtr& in2,
249 const sensor_msgs::Image::ConstPtr& in3,
const sensor_msgs::Image::ConstPtr& in4,
250 const sensor_msgs::Image::ConstPtr& in5,
const sensor_msgs::Image::ConstPtr& in6,
251 const sensor_msgs::Image::ConstPtr& in7,
const sensor_msgs::Image::ConstPtr& in8)
254 int width = in1->width;
255 std::vector<cv::Mat> inputs;
272 out.setTo(std::numeric_limits<float>::quiet_NaN());
273 for (
size_t j = 0; j < inputs[0].rows; j++)
275 for (
size_t i = 0;
i < inputs[0].cols;
i++)
278 float value_fused = 0;
279 for (
size_t k = 0;
k < inputs.size();
k++)
281 float value = inputs[
k].at<
float>(j,
i);
282 if (!std::isnan(
value))
284 value_fused +=
value;
290 out.at<
float>(j,
i) = value_fused / n_fused;
300 out.setTo(cv::Scalar(0, 0, 0));
301 for (
size_t j = 0; j < inputs[0].rows; j++)
303 for (
size_t i = 0;
i < inputs[0].cols;
i++)
306 cv::Vec3b value_fused(0, 0, 0);
307 for (
size_t k = 0;
k < inputs.size();
k++)
309 cv::Vec3b
value = inputs[
k].at<cv::Vec3b>(j,
i);
316 value_fused +=
value;
322 out.at<cv::Vec3b>(j,
i) = value_fused / n_fused;