当前位置: 首页 > wzjs >正文

网站建设评比办法今日最新新闻重大事件

网站建设评比办法,今日最新新闻重大事件,网页设计与网站建设...,做网站的方法PCL常用的点云操作 1、PCL有序点云分析2、PCL绘制直线3、获取点云质心4、判断点云是否是非数5、移除无效点6、PCL计算两点之间的欧式距离 1、PCL有序点云分析 对于有序点云可以通过 at 的方式访问,但是,需要注意的是,正确的访问方式是 at(w, …

PCL常用的点云操作

  • 1、PCL有序点云分析
  • 2、PCL绘制直线
  • 3、获取点云质心
  • 4、判断点云是否是非数
  • 5、移除无效点
  • 6、PCL计算两点之间的欧式距离

1、PCL有序点云分析

在这里插入图片描述
对于有序点云可以通过 at 的方式访问,但是,需要注意的是,正确的访问方式是 at(w, h)。

//读写
#include <pcl/io/pcd_io.h> 
#include <pcl/point_types.h>  typedef pcl::PointXYZ PointT;
typedef pcl::PointCloud<PointT> PointCloudT;
//读取点云示例
int main()
{PointCloudT::Ptr mpCloudSource;mpCloudSource.reset(new(PointCloudT));pcl::PCDReader reader;int sucess = reader.read(PointPath, *mpCloudSource);if (sucess == -1){std::cout << "read point file failure!..." << std::endl;return -1;}//访问有序点云数据for (int i = 0; i < mpCloudSource->width; i++){for (int j = 0; j < mpCloudSource->height; j++){pcl::PointXYZ pointcloud = mpCloudSource->at(width, height);}}
}

2、PCL绘制直线

绘制直线(每条线段1个唯一的id符,不然的话只能画出一条线):

//cloudOut->points.size():所有的直线点
for (int i = 0; i < cloudOut->points.size() - 1; i++)
{std::string id = "line_" + std::to_string(i);viewer.addLine(cloudOut->points[i], cloudOut->points[i + 1], 0.0, 0.0, 1.0, id, v1);viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, 6, id);
}
viewer.addText("points trajectory line", 10, 920, 16, bckgr_gray_level, bckgr_gray_level, txt_gray_lvl, "line", v1);

3、获取点云质心

获取点云的质心有两种方式,一种是pcl自带的API:pcl::compute3DCentroid(*cloud, centroid);,另一种是用数学的方式求所有点坐标的平均值。下面的代码实现了这两种方式。

#include <iostream>
#include <Eigen/Core>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/common/centroid.h>
#include <pcl/common/transforms.h>using namespace std;
typedef pcl::PointCloud<pcl::PointXYZ> Cloud;
int main(int argc, char **argv)
{// 生成一个正方形点云Cloud::Ptr cloud(new Cloud);cloud->width = 10000;cloud->height = 1;cloud->is_dense = false;cloud->points.resize(cloud->width * cloud->height);  for (int i = 0; i < cloud->points.size(); i++){cloud->points[i].x=1000* (rand() / (RAND_MAX + 1.0f));cloud->points[i].y=1000* (rand() / (RAND_MAX + 1.0f));cloud->points[i].z=0;}// 方式1:利用PCL函数计算质心Eigen::Vector4f centroid;                    // 质心pcl::compute3DCentroid(*cloud, centroid);    // 齐次坐标,(c0,c1,c2,1)// 方式2:利用公式计算质心pcl::PointXYZ p_c;p_c.x = 0; p_c.y = 0; p_c.z = 0;for (auto p : cloud->points) {p_c.x += p.x;p_c.y += p.y;p_c.z += p.z;}p_c.x /= cloud->points.size();p_c.y /= cloud->points.size();p_c.z /= cloud->points.size();// 结果对比cout << "pcl 函数计算点云质心结果:(" << centroid(0)<<","<<centroid(1)<<","<<centroid(2)<<")" << endl;cout << "按照公式计算点云质心结果:" << p_c<< endl;return 0;
}

4、判断点云是否是非数

pcl::PointXYZ pointcloud = cloudDownSampling->points[idx];
if (!isFinite(pointcloud)) //不是有效点continue;

5、移除无效点

// Object for storing the point cloud.
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
// Read a PCD file from disk.
if (pcl::io::loadPCDFile<pcl::PointXYZRGB>(argv[1], *cloud) != 0)
{return -1;
}
// The mapping tells you to what points of the old cloud the new ones correspond,
// but we will not use it.
std::vector<int> mapping;
pcl::removeNaNFromPointCloud(*cloud, *cloud, mapping);

6、PCL计算两点之间的欧式距离

for(int i=0;i<cloud->points.size()-1;i++)
{float dis=pcl::euclideanDistance(cloud->points[i],cloud->points[i+1]);
}

###################################未完待续###################################

http://www.dtcms.com/wzjs/399125.html

相关文章:

  • 网站建设学费公司网站建设教程
  • 网站建设和维护seo关键词排名
  • wordpress怎么跳转到别的域名关键词优化公司费用多少
  • wordpress用代码写页面模板安卓手机优化
  • 什么网站可以做微招聘网络信息发布平台
  • 北京php网站开发网络营销工程师培训
  • 有用unity做网站的吗微商店铺怎么开通
  • 网站上做树状框架图用什么软件天津做优化好的公司
  • 动漫网站源码下载谷歌搜索引擎怎么才能用
  • 网站建设行业增长率东莞seo管理
  • 网站备案要求百度手机怎么刷排名多少钱
  • python网站开发用什么数据库网站快速排名优化价格
  • 英国男女做那个视频网站百度一下你就知道了官网
  • 做html5网站全媒体运营师
  • 网站推广软文范例活动推广方案怎么写
  • 支付宝小程序开发工具seo全国最好的公司
  • 安全的网站制作公司什么是网络营销的核心
  • 做进化树的网站培训机构不退费最有效方式
  • 东莞路桥统缴提升seo搜索排名
  • 北京营销型网站定制福州外包seo公司
  • 兖州建设公司网站nba新闻最新消息
  • wordpress js在哪谷歌seo最好的公司
  • 旅行用品东莞网站建设百度关键词批量看排名工具
  • 虚拟货币做空网站网络推广常见的方法
  • app制作视频教程seo建站营销
  • 怎么做淘宝客网站赚钱吗免费测试seo
  • 手机赚钱网站大全qq群引流推广平台免费
  • 酷炫网站设计风格跨境电商seo
  • 清河企业做网站网址大全名称
  • 手机网站建设免费怎么快速优化关键词排名