打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
点云极坐标的获取

转自:http://www.zhangzscn.com/2016/08/24/pclbianchengbaodian-huoqudianyunzuobiaojizhi/

有时需要获取点云的范围,即包围盒,这个可以通过获取点云的极值来得到。这里的极值指的是点云里x坐标、y坐标、z坐标的极大值和极小值。PCL里提供了getMinMax3D函数来得到点云极值,具体用法如下代码所示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/common/common.h>
int main(int, char**)
{
    //定义存储点云的类实例
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    //读取点云文件
    if (pcl::io::loadPCDFile<pcl::PointXYZ>("D:\\bunny.pcd", *cloud)==-1)
    {
        std::cout << "读取失败";
    }
     
    //定义存储极值的两个点
    pcl::PointXYZ minPt, maxPt;
    //获取坐标极值
    pcl::getMinMax3D(*cloud, minPt, maxPt);
    //输出结果
    std::cout << "Max x: " << maxPt.x << std::endl;
    std::cout << "Max y: " << maxPt.y << std::endl;
    std::cout << "Max z: " << maxPt.z << std::endl;
    std::cout << "Min x: " << minPt.x << std::endl;
    std::cout << "Min y: " << minPt.y << std::endl;
    std::cout << "Min z: " << minPt.z << std::endl;
    return (0);
}

输出结果为:
Max x: 0.0613699
Max y: 0.18794
Max z: 0.0591165
Min x: -0.0951318
Min y: 0.0329872
Min z: -0.0627642

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
点云拟合
使用lambda,远离bind
C 中的大括号(花括号)有什么功能
(十三)Visualization教程一
PCL—低层次视觉—点云分割(邻近信息)
178 f0602
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服