Skip to content

Commit 300149f

Browse files
authored
Merge pull request #2893 from mqcmd196/point-pose-extractor-add-pixel
[jsk_perception][point_pose_extractor] Publish template pixel in image
2 parents c31bfba + 45ba673 commit 300149f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

jsk_perception/include/jsk_perception/point_pose_extractor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <posedetection_msgs/ImageFeature0D.h>
5252
#include <posedetection_msgs/ObjectDetection.h>
5353
#include <posedetection_msgs/Object6DPose.h>
54+
#include <geometry_msgs/PointStamped.h>
5455
#include <geometry_msgs/PoseStamped.h>
5556
#include <geometry_msgs/Pose.h>
5657
#include <geometry_msgs/Quaternion.h>
@@ -750,7 +751,7 @@ namespace jsk_perception
750751
ros::Subscriber _sub;
751752
ros::ServiceServer _server;
752753
ros::ServiceClient _client;
753-
ros::Publisher _pub, _pub_agg, _pub_pose;
754+
ros::Publisher _pub, _pub_agg, _pub_pose, _pub_pixel;
754755
tf::TransformBroadcaster _br;
755756
image_transport::Publisher _debug_pub;
756757
bool _first_sample_change;

jsk_perception/src/point_pose_extractor.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)