2021-07-15

PCL点云将带强度信息LAS格式转换成PCD文件

很多人说在CloudCompare里面不是有现成的格式转换吗,但是我试了下CloudCompare里面转换出来的效果是这样的。。。在这里插入图片描述我们可以发现他是这种Intensity在前面的形式,其实这种格式的PCD在PCL读取中是读不出来强度信息的。

我的方法是用CloudCompare把LAS格式转换成TXT格式,再读取TXT格式,代码转换成符合PCL规范的PCD文件。(其实可以直接将LAS转为PCD的,但是我的库函数有点问题,就换了成TXT了,有点麻烦了)

#include<fstream>
#include<string>
#include<iostream>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/io/pcd_io.h>
#include <time.h>
#include <boost/thread/thread.hpp>
typedef pcl::PointXYZI PointT;
typedef pcl::PointCloud<PointT> PointCloud;
using namespace std;

int main() {
    double x, y, z;
    float intensity;
    string s;
    FILE* fp_txt;
    fp_txt = fopen("txt.txt", "r");

    PointCloud::Ptr cloud_src_o(new PointCloud);//原点云,待配准
	pcl::io::loadPCDFile("鼎垵6_13_1yes.pcd", *cloud_src_o);
    cout << "start" << endl;
    int i=0;
    int point_size = cloud_src_o->size();
    while (i< point_size) {
        if (fscanf(fp_txt, "%lf %lf %lf %f",&x,&y,&z,&intensity)) {
            cloud_src_o->points[i].intensity = intensity;
        }
        else {
            cout << "error" << endl;
        }
        i++;
    }
    pcl::io::savePCDFileASCII("intensity.pcd", *cloud_src_o);
    cout << "success" << endl;

}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值