Пример #1
0
void
pp_callback (const pcl::visualization::PointPickingEvent& event, void* cookie)
{
  if (event.getPointIndex () == -1)
    return;
  sensor_msgs::PointCloud2::Ptr cloud = *static_cast<sensor_msgs::PointCloud2::Ptr*>(cookie);
  if (!cloud)
    return;

  // If two points were selected, draw an arrow between them
  pcl::PointXYZ p1, p2;
  if (event.getPoints (p1.x, p1.y, p1.z, p2.x, p2.y, p2.z) && p)
  {
    std::stringstream ss;
    ss << p1 << p2;
    p->addArrow<pcl::PointXYZ, pcl::PointXYZ> (p1, p2, 1.0, 1.0, 1.0, ss.str ());
    return;
  }

  // Else, if a single point has been selected
  std::stringstream ss;
  ss << event.getPointIndex ();
  // Get the cloud's fields
  for (size_t i = 0; i < cloud->fields.size (); ++i)
  {
    if (!isMultiDimensionalFeatureField (cloud->fields[i]))
      continue;
    ph_global.addFeatureHistogram (*cloud, cloud->fields[i].name, event.getPointIndex (), ss.str ());
  }
  if (p)
  {
    pcl::PointXYZ pos;
    event.getPoint (pos.x, pos.y, pos.z);
    p->addText3D<pcl::PointXYZ> (ss.str (), pos, 0.0005, 1.0, 1.0, 1.0, ss.str ());
  }
  ph_global.spinOnce ();
}
 void pointpickingEventOccurred (const pcl::visualization::PointPickingEvent &event, void* viewer_void)
 {
 	int indx;
 	float x,y,z;
    indx = event.getPointIndex();
 	if(indx == -1)
          return;
 	std::cout << indx << " " << std::endl;
    event.getPoint(x,y,z);

    first.x = x;
 	first.y = y;
 	first.z = z;
 	std::cout<<"First point "<<first.x<<" , "<<first.y<<" , "<<first.z<<std::endl;

 	// Green region detection
 	pcl::PointCloud<pcl::PointXYZRGBA>::Ptr final_cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
 	final_cloud->width    = cloud->width;
 	final_cloud->height   = cloud->height;
 	final_cloud->resize (cloud->width * cloud->height);
 	//


 }