@@ -134,9 +134,13 @@ EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){
134134#endif
135135 }
136136
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
140144 for ( size_t i = 0 ; i < rgb_image_topics.size () ; i++ ){
141145
142146 // 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
322326 cmplx_msg.simple_objects .push_back (eoi_to_base_object (name_eoi.first , -1 , name_eoi.second , rgb.K ()));
323327 }
324328 complex_msg.objects .push_back (cmplx_msg);
325- }
329+ }private_it_
326330 if (publish_image_output)
327331 c_it->drawAll (image_to_draw, cv::Scalar (255 , 255 , 0 ), 2 );
328332 }
@@ -392,8 +396,14 @@ void EOD_ROS::detect(const eod::InfoImage& rgb, const eod::InfoImage& depth, std
392396#endif
393397 }
394398 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+
395405 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);
397407 }
398408 frame_sequence++;
399409 // cv::waitKey(1);
0 commit comments