@@ -134,9 +134,13 @@ EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){
134
134
#endif
135
135
}
136
136
137
- private_it_ = new image_transport::ImageTransport (nh_p_);
138
- output_image_pub_ = private_it_->advertise (" detected_image" , 1 );
139
-
137
+ // setup output image publishers
138
+ // if( publish_image_output ){
139
+ // private_it_ = new image_transport::ImageTransport(nh_p_);
140
+ // output_image_pub_ = private_it_->advertise("detected_image", 1);
141
+ // }
142
+
143
+ // setup subscribers
140
144
for ( size_t i = 0 ; i < rgb_image_topics.size () ; i++ ){
141
145
142
146
// ROS_INFO("Bounding %s and %s...",rgb_image_topics[i].c_str(), rgb_info_topics[i].c_str());
@@ -322,7 +326,7 @@ void EOD_ROS::detect(const eod::InfoImage& rgb, const eod::InfoImage& depth, std
322
326
cmplx_msg.simple_objects .push_back (eoi_to_base_object (name_eoi.first , -1 , name_eoi.second , rgb.K ()));
323
327
}
324
328
complex_msg.objects .push_back (cmplx_msg);
325
- }
329
+ }private_it_
326
330
if (publish_image_output)
327
331
c_it->drawAll (image_to_draw, cv::Scalar (255 , 255 , 0 ), 2 );
328
332
}
@@ -392,8 +396,14 @@ void EOD_ROS::detect(const eod::InfoImage& rgb, const eod::InfoImage& depth, std
392
396
#endif
393
397
}
394
398
if (publish_image_output){
399
+ if ( output_image_pubs_.find (header.frame_id ) == output_image_pubs_.end () ){
400
+ auto out_it = new image_transport::ImageTransport (nh_p_);
401
+ // printf("Adding new publisher...");
402
+ output_image_pubs_[header.frame_id ] = out_it->advertise (" detected_image_" +std::to_string (output_image_pubs_.size ()), 1 );
403
+ }
404
+
395
405
sensor_msgs::ImagePtr detected_image_msg = cv_bridge::CvImage (std_msgs::Header (), " bgr8" , image_to_draw).toImageMsg ();
396
- output_image_pub_ .publish (detected_image_msg);
406
+ output_image_pubs_[header. frame_id ] .publish (detected_image_msg);
397
407
}
398
408
frame_sequence++;
399
409
// cv::waitKey(1);
0 commit comments