PCL开发——备忘1

来源:互联网 发布:系统更新软件 编辑:程序博客网 时间:2024/06/11 13:12

1. QString to String

Qt打开文件保存文件时用到。

QString filename = "bunny.pcd";string name = filename.toUtf8().constData();

2. pcl::PointIndices与pcl::PointIndices::Ptr相互转换

2.1 pcl::PointIndices转换成pcl::PointIndices::Ptr来源:

颜色区域增长分割算法用的是pcl::PointIndices

vector <pcl::PointIndices> clusters;pcl::RegionGrowingRGB<PointT> reg;reg.extract (clusters);

提取索引用的是pcl::PointIndices::Ptr

pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>);//存放滤波结果pcl::ExtractIndices<PointT> extract; pcl::PointIndices::Ptr tem (new pcl::PointIndices(clusters[0]));//定义指向clusters[0]的指针extract.setIndices (tem);        extract.filter (*cloud);
2.2 pcl::PointIndices::Ptr转换成pcl::PointIndices
pcl::PointIndices::Ptr tem1 (new pcl::PointIndices);pcl::PointIndices tem2;*tem1 = tem2;(tem2 = *tem1)

3. 输出pcd点云的fields属性

cout<<"There are"<<cloud->width*cloud->height<<"data points(" << pcl::getFieldsList (*cloud)<<").";

4. addCubes

一共有三种方式添加立方体:

addCube (const pcl::ModelCoefficients &coefficients, const std::string &id="cube", int viewport=0);addCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth, const std::string &id="cube", int viewport=0);addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max, double r=1.0, double g=1.0, double b=1.0, const std::string &id="cube", int viewport=0);
//对于第三种,如果min>max,不能画出立方体。缺颜色也不行       viewer->addCube(min.x, max.x, min.y, max.y, min.z, max.z, a[i], b[i], c[i], ss.str(), v2);

5. pcl常用小知识(别人总结的)

  • 时间计算
  • 如何实现类似pcl::PointCloud::Ptr和pcl::PointCloud的两个类相互转换?
  • 如何查找点云的x,y,z的极值?
  • 如果知道需要保存点的索引,如何从原点云中拷贝点到新点云?
  • 如何从点云里删除和添加点?
  • 如何对点云进行全局或局部变换
  • 链接两个点云字段(两点云大小必须相同)
  • 如何从点云中删除无效点
  • 将xyzrgb格式转换为xyz格式的点云
  • flann kdtree 查询k近邻
  • 关于ply文件
  • 计算点的索引
  • 计算质心
  • 从网格提取顶点(将网格转化为点)

参考

pcl::addCube
pcl常用小知识(segmentfault)

原创粉丝点击