I wanted to make a PCL Visualiser where a user can see co-ordinates of the point in the point cloud when he clicks on it. I implemented that part but now the issue is the user do not get any response which point he picked so I want to make the picked point bigger or if possible coloured.
I am using PCLVisualizer and PointPickingEvent header files provided by PointCloudLibrary.
void pointPickingOccured( const pcl::visualization::PointPickingEvent &event,void* viewer_void)
{
float x,y,z;
event.getPoint(x,y,z);
std::cout << "X: " << x << " Y: " << y << " Z: " << z << std::endl;
}
boost::shared_ptr<pcl::visualization::PCLVisualizer> simpleVis (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, filename);
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, filename);
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters ();
viewer->registerMouseCallback (mouseEventOccurred, (void*)&viewer);
viewer->registerPointPickingCallback(pointPickingOccured, (void*)&viewer);
viewer->spin();
return (viewer);
//new Code
void pointPickingOccured( const pcl::visualization::PointPickingEvent &event,void* viewer_void)
{
float x,y,z;
event.getPoint(x,y,z);
pointIndex = event.getPointIndex();
std::cout <<"Point No. " << pointIndex <<" ";
std::cout << "X: " << x << " Y: " << y << " Z: " << z << std::endl;
viewer->updateSphere(cloud->points[pointIndex], 0.03, 255, 0, 0, "pt");
viewer->spinOnce (100);
boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
void simpleVis (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
{
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, filename);
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, filename);
viewer->registerPointPickingCallback(pointPickingOccured, (void*)&viewer);
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters ();
viewer->addSphere(cloud->points[pointIndex], 0.03, "pt", 0); viewer->spin();}
Since you're using PCLVisualizer, if I understood your question, you have two options: