我想创建一个PCL Visualiser,用户可以在点击它时看到点云中点的坐标。我实现了那个部分,但现在的问题是用户没有得到任何响应,他选择了这一点,所以我想让拾取的点更大或者如果可能的颜色。
我正在使用PointCloudLibrary提供的PCLVisualizer和PointPickingEvent头文件。
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);
//新代码
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();}
答案 0 :(得分:1)
由于您正在使用 PCLVisualizer ,如果我理解您的问题,您有两种选择: