49   ConnectionBasedNodelet::onInit();
 
   52   pcl::search::KdTree<pcl::PointXYZ>::Ptr 
normals_tree_(
new pcl::search::KdTree<pcl::PointXYZ>);
 
   55   dyn_srv_ = boost::make_shared< dynamic_reconfigure::Server< Config > >(*pnh_);
 
   56   dynamic_reconfigure::Server<Config>::CallbackType 
f =
 
   60   srv_ = pnh_->advertiseService(
 
   63   pub_points_  = advertise< sensor_msgs::PointCloud2 >(*pnh_, 
"output", 1);
 
   64   pub_point_   = advertise< geometry_msgs::PointStamped >(*pnh_, 
"output_point", 1);
 
   65   pub_polygon_ = advertise< geometry_msgs::PolygonStamped >(*pnh_, 
"output_polygon", 1);
 
  179   bool need_resubscribe = 
false;
 
  183     need_resubscribe = 
true;
 
  197   if (need_resubscribe && isSubscribed())
 
  206     jsk_recognition_msgs::TransformScreenpoint::Request &
req,
 
  207     jsk_recognition_msgs::TransformScreenpoint::Response &
res)
 
  217   bool need_unsubscribe = 
false;
 
  221     need_unsubscribe = 
true;
 
  236   if (need_unsubscribe)
 
  252   res.point.x = rx; 
res.point.y = ry; 
res.point.z = rz;
 
  262   pcl::PointCloud<pcl::PointXYZ> cloud_;
 
  267   cloud_.points.resize(0);
 
  268   cloud_.points.push_back(pt);
 
  270   n3d_.setInputCloud (cloud_.makeShared());
 
  271   pcl::PointCloud<pcl::Normal> cloud_normals;
 
  272   n3d_.compute (cloud_normals);
 
  274   res.vector.x = cloud_normals.points[0].normal_x;
 
  275   res.vector.y = cloud_normals.points[0].normal_y;
 
  276   res.vector.z = cloud_normals.points[0].normal_z;
 
  278   if((
res.point.x * 
res.vector.x + 
res.point.y * 
res.vector.y + 
res.point.z * 
res.vector.z) < 0) {
 
  285     geometry_msgs::PointStamped ps;
 
  287     ps.point.x = 
res.point.x;
 
  288     ps.point.y = 
res.point.y;
 
  289     ps.point.z = 
res.point.z;
 
  299   NODELET_DEBUG(
"PointcloudScreenpoint::points_cb, width=%d, height=%d, fields=%ld",
 
  300                 msg->width, 
msg->height, 
msg->fields.size());
 
  315     geometry_msgs::PointStamped ps;
 
  316     bool ret; 
float rx, ry, rz;
 
  320       ps.point.x = rx; ps.point.y = ry; ps.point.z = rz;
 
  331     sensor_msgs::PointCloud2 out_pts;
 
  345     pcl::PointCloud<pcl::PointXY>::Ptr point_array_cloud(
new pcl::PointCloud<pcl::PointXY>);
 
  347     pcl::PointCloud<pcl::PointXYZ>::Ptr result_cloud(
new pcl::PointCloud<pcl::PointXYZ>);
 
  349     for (
size_t i = 0; 
i < point_array_cloud->points.size(); 
i++) {
 
  350       pcl::PointXY 
point = point_array_cloud->points[
i];
 
  351       geometry_msgs::PointStamped ps;
 
  352       bool ret; 
float rx, ry, rz;
 
  355         pcl::PointXYZ point_on_screen;
 
  356         point_on_screen.x = rx;
 
  357         point_on_screen.y = ry;
 
  358         point_on_screen.z = rz;
 
  359         result_cloud->points.push_back(point_on_screen);
 
  362     sensor_msgs::PointCloud2::Ptr ros_cloud(
new sensor_msgs::PointCloud2);
 
  376   int num_pts = array_ptr->polygon.points.size();
 
  380   } 
else if ( num_pts > 2 ) {
 
  382                  "Used first 2 points to compute mid-coords.",
 
  383                  array_ptr->polygon.points.size());
 
  386   int st_x = array_ptr->polygon.points[0].x;
 
  387   int st_y = array_ptr->polygon.points[0].y;
 
  388   int ed_x = array_ptr->polygon.points[1].x;
 
  389   int ed_y = array_ptr->polygon.points[1].y;
 
  393     geometry_msgs::PointStamped ps;
 
  394     bool ret; 
float rx, ry, rz;
 
  398       ps.point.x = rx; ps.point.y = ry; ps.point.z = rz;
 
  405     sensor_msgs::PointCloud2 out_pts;
 
  420     geometry_msgs::PolygonStamped result_polygon;
 
  422     for (
size_t i = 0; 
i < array_ptr->polygon.points.size(); 
i++) {
 
  423       geometry_msgs::Point32 
p = array_ptr->polygon.points[
i];
 
  430       geometry_msgs::Point32 p_projected;
 
  434       result_polygon.polygon.points.push_back(p_projected);
 
  441     const sensor_msgs::PointCloud2::ConstPtr& points_ptr,
 
  442     const geometry_msgs::PointStamped::ConstPtr& pt_ptr)
 
  450     const sensor_msgs::PointCloud2::ConstPtr& points_ptr,
 
  451     const sensor_msgs::PointCloud2::ConstPtr& pt_arr_ptr)
 
  459     const sensor_msgs::PointCloud2::ConstPtr& points_ptr,
 
  460     const geometry_msgs::PolygonStamped::ConstPtr& array_ptr)
 
  468     const sensor_msgs::PointCloud2::ConstPtr& points_ptr,
 
  469     const geometry_msgs::PolygonStamped::ConstPtr& array_ptr) {
 
  477                                         float &resx, 
float &resy, 
float &resz)
 
  479   if ((
x < 0) || (
y < 0) || (
x >= in_pts.width) || (
y >= in_pts.height)) {
 
  481              "point: (%d, %d)  size: (%d, %d)",
 
  482              x, 
y, in_pts.width, in_pts.height);
 
  486   pcl::PointXYZ 
p = in_pts.points[in_pts.width * 
y + 
x];
 
  491   if ( !std::isnan (
p.x) && ((
p.x != 0.0) || (
p.y != 0.0) || (
p.z == 0.0)) ) {
 
  492     resx = 
p.x; resy = 
p.y; resz = 
p.z;
 
  500                                           float &resx, 
float &resy, 
float &resz)
 
  504   x = reqx < 0.0 ? ceil(reqx - 0.5) : floor(reqx + 0.5);
 
  505   y = reqy < 0.0 ? ceil(reqy - 0.5) : floor(reqy + 0.5);
 
  512       for (
int y2 = 0; y2 <= 
n; y2++) {
 
  514         if (
checkpoint (in_pts, 
x + x2, 
y + y2, resx, resy, resz)) {
 
  517         if (x2 != 0 && y2 != 0) {
 
  518           if (
checkpoint (in_pts, 
x - x2, 
y - y2, resx, resy, resz)) {
 
  523           if (
checkpoint (in_pts, 
x - x2, 
y + y2, resx, resy, resz)) {
 
  528           if (
checkpoint (in_pts, 
x + x2, 
y - y2, resx, resy, resz)) {
 
  541                                           sensor_msgs::PointCloud2& out_pts)
 
  543   sensor_msgs::PointCloud2::Ptr points_ptr(
new sensor_msgs::PointCloud2);
 
  546   if ( st_x < 0 ) st_x = 0;
 
  547   if ( st_y < 0 ) st_y = 0;
 
  548   if ( ed_x >= points_ptr->width ) ed_x = points_ptr->width -1;
 
  549   if ( ed_y >= points_ptr->height ) ed_y = points_ptr->height -1;
 
  551   int wd = points_ptr->width;
 
  552   int ht = points_ptr->height;
 
  553   int rstep = points_ptr->row_step;
 
  554   int pstep = points_ptr->point_step;
 
  556   out_pts.header = points_ptr->header;
 
  557   out_pts.width = ed_x - st_x + 1;
 
  558   out_pts.height = ed_y - st_y + 1;
 
  559   out_pts.row_step = out_pts.width * pstep;
 
  560   out_pts.point_step = pstep;
 
  561   out_pts.is_bigendian = 
false;
 
  562   out_pts.fields = points_ptr->fields;
 
  563   out_pts.is_dense = 
false;
 
  564   out_pts.data.resize(out_pts.row_step * out_pts.height);
 
  566   unsigned char * dst_ptr = &(out_pts.data[0]);
 
  568   for (
size_t idx_y = st_y; idx_y <= ed_y; idx_y++) {
 
  569     for (
size_t idx_x = st_x; idx_x <= ed_x; idx_x++) {
 
  570       const unsigned char * src_ptr = &(points_ptr->data[idx_y * rstep + idx_x * pstep]);
 
  571       memcpy(dst_ptr, src_ptr, pstep);