@@ -42,6 +42,7 @@ namespace jsk_perception
4242 _client.shutdown ();
4343 _pub.shutdown ();
4444 _pub_agg.shutdown ();
45+ _pub_pixel.shutdown ();
4546 }
4647
4748 void PointPoseExtractor::initialize () {
@@ -319,6 +320,17 @@ namespace jsk_perception
319320 if ((int )vo6p.size () != 0 ) {
320321 pose_msg.pose = od.objects [0 ].pose ;
321322 _pub_pose.publish (pose_msg);
323+ // Publish pixel coordinate of the detected object
324+ cv::Point3f pt3d (pose_msg.pose .position .x ,
325+ pose_msg.pose .position .y ,
326+ pose_msg.pose .position .z );
327+ cv::Point2f pt2d = pcam.project3dToPixel (pt3d);
328+ geometry_msgs::PointStamped pixel_msg;
329+ pixel_msg.header = od.header ;
330+ pixel_msg.point .x = pt2d.x ;
331+ pixel_msg.point .y = pt2d.y ;
332+ pixel_msg.point .z = 0 ; // z is not used for pixel coordinate
333+ _pub_pixel.publish (pixel_msg);
322334 }
323335 // broadcast tf
324336 if ( this ->_publish_tf ) {
@@ -374,6 +386,7 @@ namespace jsk_perception
374386 _pub = advertise<posedetection_msgs::ObjectDetection>(*nh_, " ObjectDetection" , 10 );
375387 _pub_agg = advertise<posedetection_msgs::ObjectDetection>(*nh_, " ObjectDetection_agg" , 10 );
376388 _pub_pose = advertise<geometry_msgs::PoseStamped>(*nh_, " object_pose" , 10 );
389+ _pub_pixel = advertise<geometry_msgs::PointStamped>(*nh_, " object_pixel" , 10 );
377390 _debug_pub = it->advertise (" debug_image" , 1 );
378391 _server = nh_->advertiseService (" SetTemplate" , &PointPoseExtractor::settemplate_cb, this );
379392 _initialized = false ;
0 commit comments