本文整理汇总了C++中PCLVisualizer::removePointCloud方法的典型用法代码示例。如果您正苦于以下问题:C++ PCLVisualizer::removePointCloud方法的具体用法?C++ PCLVisualizer::removePointCloud怎么用?C++ PCLVisualizer::removePointCloud使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PCLVisualizer
的用法示例。
在下文中一共展示了PCLVisualizer::removePointCloud方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
break;
}
case 'h':
default:
printUsage (argv[0]);
exit (0);
}
}
angular_resolution = deg2rad (angular_resolution);
ros::init (argc, argv, "tutorial_range_image_live_viewer");
ros::NodeHandle node_handle;
ros::Subscriber subscriber, subscriber2;
if (node_handle.resolveName("input")=="/input")
std::cerr << "Did you forget input:=<your topic>?\n";
if (source == 0)
subscriber = node_handle.subscribe ("input", 1, cloud_msg_cb);
else if (source == 1)
{
if (node_handle.resolveName("input2")=="/input2")
std::cerr << "Did you forget input2:=<your camera_info_topic>?\n";
subscriber = node_handle.subscribe ("input", 1, depth_image_msg_cb);
subscriber2 = node_handle.subscribe ("input2", 1, camera_info_msg_cb);
}
else if (source == 2)
subscriber = node_handle.subscribe ("input", 1, disparity_image_msg_cb);
PCLVisualizer viewer (argc, argv, "Live viewer - point cloud");
RangeImageVisualizer range_image_widget("Live viewer - range image");
RangeImagePlanar* range_image_planar;
RangeImage* range_image;
if (source==0)
range_image = new RangeImage;
else
{
range_image_planar = new RangeImagePlanar;
range_image = range_image_planar;
}
while (node_handle.ok ())
{
usleep (10000);
viewer.spinOnce (10);
RangeImageVisualizer::spinOnce ();
ros::spinOnce ();
if (source==0)
{
// If no new message received: continue
if (!cloud_msg || cloud_msg == old_cloud_msg)
continue;
old_cloud_msg = cloud_msg;
Eigen::Affine3f sensor_pose(Eigen::Affine3f::Identity());
PointCloud<PointWithViewpoint> far_ranges;
RangeImage::extractFarRanges(*cloud_msg, far_ranges);
if (pcl::getFieldIndex(*cloud_msg, "vp_x")>=0)
{
PointCloud<PointWithViewpoint> tmp_pc;
fromROSMsg(*cloud_msg, tmp_pc);
Eigen::Vector3f average_viewpoint = RangeImage::getAverageViewPoint(tmp_pc);
sensor_pose = Eigen::Translation3f(average_viewpoint) * sensor_pose;
}
PointCloud<PointType> point_cloud;
fromROSMsg(*cloud_msg, point_cloud);
range_image->createFromPointCloud(point_cloud, angular_resolution, deg2rad(360.0f), deg2rad(180.0f),
sensor_pose, coordinate_frame, noise_level, min_range, border_size);
}
else if (source==1)
{
// If no new message received: continue
if (!depth_image_msg || depth_image_msg == old_depth_image_msg || !camera_info_msg)
continue;
old_depth_image_msg = depth_image_msg;
range_image_planar->setDepthImage(reinterpret_cast<const float*> (&depth_image_msg->data[0]),
depth_image_msg->width, depth_image_msg->height,
camera_info_msg->P[2], camera_info_msg->P[6],
camera_info_msg->P[0], camera_info_msg->P[5], angular_resolution);
}
else if (source==2)
{
// If no new message received: continue
if (!disparity_image_msg || disparity_image_msg == old_disparity_image_msg)
continue;
old_disparity_image_msg = disparity_image_msg;
range_image_planar->setDisparityImage(reinterpret_cast<const float*> (&disparity_image_msg->image.data[0]),
disparity_image_msg->image.width, disparity_image_msg->image.height,
disparity_image_msg->f, disparity_image_msg->T, angular_resolution);
}
range_image_widget.setRangeImage (*range_image);
viewer.removePointCloud ("range image cloud");
pcl_visualization::PointCloudColorHandlerCustom<pcl::PointWithRange> color_handler_cloud(*range_image,
200, 200, 200);
viewer.addPointCloud (*range_image, color_handler_cloud, "range image cloud");
}
}