PCL自定义点类型
来源:互联网 发布:上海浦东软件协会朱 编辑:程序博客网 时间:2024/05/18 04:57
除了pcl已定义点类型,参考http://www.cnblogs.com/li-yao7758258/p/6433445.html
很多时候都需要自定义所需点类型,定义方法如下
以下例子是创建新的点类型,数据中包含X,Y,Z,PC1,PC2,meanPC(平均曲率),作为参考
step 1 新建myPointType.h
#define PCL_NO_PRECOMPILE#ifndef MYPOINTTYPE_H#define MYPOINTTYPE_H#include <pcl/point_types.h>struct XYZ_CURVA{PCL_ADD_POINT4D;union{float coordinate[3];struct{float x;float y;float z;};};float pc1;float pc2;float mean_pc;EIGEN_MAKE_ALIGNED_OPERATOR_NEW;}EIGEN_ALIGN16;POINT_CLOUD_REGISTER_POINT_STRUCT(XYZ_CURVA,// 注册点类型宏(float, x, x)(float, y, y)(float, z, z)(float, pc1, pc1)(float, pc2, pc2)(float, mean_pc, mean_pc))#endif
step 2 cpp中使用
法线和曲率计算参见官网法线例子,曲率计算例子如下(并不是真正数学意义上的曲率)
pcl::PointCloud<pcl::Normal>::Ptr cloud_with_normals;pcl::PointCloud<pcl::PrincipalCurvatures>::Ptr principal_curvatures;pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimation;
normal_estimation.setInputCloud(cloud);pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);normal_estimation.setSearchMethod(tree);//适合本实验数据的k值normal_estimation.setKSearch(60);normal_estimation.compute(*cloud_with_normals);// Setup the principal curvatures computationpcl::PrincipalCurvaturesEstimation<pcl::PointXYZ, pcl::Normal, pcl::PrincipalCurvatures> principal_curvatures_estimation;// Provide the original point cloud (without normals)principal_curvatures_estimation.setInputCloud(cloud);// Provide the point cloud with normalsprincipal_curvatures_estimation.setInputNormals(cloud_with_normals);// Use the same KdTree from the normal estimationprincipal_curvatures_estimation.setSearchMethod(tree);principal_curvatures_estimation.setKSearch(60);// Actually compute the principal curvaturesprincipal_curvatures_estimation.compute(*principal_curvatures);pcl::io::savePCDFile("temp/curva_out.pcd", *principal_curvatures);pcl::io::savePCDFile("temp/normal_out.pcd", *cloud_with_normals);
将每个点坐标以及计算好的数据保存至新文件
int size = cloud->size();pcl::PointCloud<XYZ_CURVA> xyz_curva;xyz_curva.points.resize(size);xyz_curva.width = size;xyz_curva.height = 1;for (int i = 0; i < size; i++){xyz_curva.points[i].x = cloud->points[i].x;xyz_curva.points[i].y = cloud->points[i].y;xyz_curva.points[i].z = cloud->points[i].z;xyz_curva.points[i].pc1 = principal_curvatures->points[i].pc1;xyz_curva.points[i].pc2 = principal_curvatures->points[i].pc2;xyz_curva.points[i].mean_pc = (principal_curvatures->points[i].pc1 + principal_curvatures->points[i].pc2)/2;}pcl::io::savePCDFile("temp/test.pcd", xyz_curva);
存在问题:
IntelliSense: 常量表达式中不允许该运算符 myPointType.h (但是最终结果不受影响,编译器或者版本的问题maybe)
1 0
- PCL自定义点类型
- PCL 不同类型的点云之间进行类型转换
- PCL点云滤波
- 点云python-pcl
- 65.[PCL]点云及PCL基础
- PCL编程-点云采样
- PCL可视化显示点云
- PCL点云程序学习
- pcl点云PCD文件
- PCL点云光滑化
- PCL显示点云[微记]
- PCL点云的显示
- pcl 学习 离群点删除
- PCL关键点(1)
- PCL可视化显示点云
- pcl点云的离群点去除
- PCL 学习笔记-使用 PCL 来显示点云
- vs2015+pcl。pcl头文件找不到!读取点云失败!
- 数据结构与算法:图的理论基础
- Shell中调用、引用、包含另一个脚本文件的三种方法
- Android自定义控件:类QQ未读消息拖拽效果
- TabLayout的使用,设置tab图片
- 记录错误Error:java.lang.RuntimeException: Some file crunching failed, see logs for details
- PCL自定义点类型
- 测试文章
- redis实现分布式锁
- SynaptiCAD.Product.Suite.v14.19c
- QT-QML调用IOS原生通讯录
- 第二十四讲项目一分段函数求值
- 求两个有序数组A和B的第k大的数——Java
- Mysql避免重复插入记录
- Kirill the Gardener 3 URAL 2072