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

C# 读取pcd点云文件数据

        pcd文件有ascii 和二进制格式,ascii可以直接记事本打开,C#可以一行行读。但二进制格式的打开是乱码,如果尝试程序中读取,对比下看了数据也对不上。

      这里可以使用pcl里的函数来读取pcd,无论二进制或ascii都可以正确读取,但pcl是C++写的,不太方便使用。我写了个C#的dll文件Q_PclCs.dll,此dll基于pcl 1.13.1版本开发,可以通过引用此dll文件来读取pcd文件,而不需要额外配置其他东西。

     

     文件下载地址

链接:https://pan.baidu.com/s/1dgXmd9VTf3G4ux__-fhtGg 
提取码:vx8u

 使用说明 将这些dll文件都放到你程序的可执行文件目录下,引用Q_PclCs.dll

读取方式

命名空间 Q_PclCs

using Q_PclCs;

PcdReader pcdReader = new PcdReader();

先读点云长度length

int length=pcdReader.GetLength(ofd.FileName);

准备数组存储

                double[] x = new double[length];
                double[] y= new double[length];
                double[] z=new double[length];
                pcdReader.PcdReaderFast(ref x, ref y, ref z);

这样就读出来了

测试程序,可以用vtk展示读出来的图,简单展示下

 测试代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Kitware.VTK;
using Q_PclCs;namespace testCsGetPcd
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();if(ofd.ShowDialog() == DialogResult.OK){PcdReader pcdReader = new PcdReader();int length=pcdReader.GetLength(ofd.FileName);double[] x = new double[length];double[] y= new double[length];double[] z=new double[length];pcdReader.PcdReaderFast(ref x, ref y, ref z);vtkPoints points = new vtkPoints();for (int i = 1; i < length; i++){points.InsertPoint(i, x[i], y[i], z[i]);}vtkPolyData polydata = vtkPolyData.New();polydata.SetPoints(points);vtkVertexGlyphFilter glyphFilter = vtkVertexGlyphFilter.New();glyphFilter.SetInputConnection(polydata.GetProducerPort());vtkPolyDataMapper mapper = vtkPolyDataMapper.New();mapper.SetInputConnection(glyphFilter.GetOutputPort());vtkActor actor = vtkActor.New();actor.SetMapper(mapper);vtkRenderer render = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();render.AddActor(actor);//render.AddActor(scalarBar);//render.SetViewport(0.0, 0.0, 1, 1);render.ResetCamera();this.Refresh();}}}
}

 

http://www.lryc.cn/news/134699.html

相关文章:

  • .NET CORE Api 上传excel解析并生成错误excel下载
  • 数据结构,二叉树,前中后序遍历
  • 项目实战笔记2:硬技能(上)
  • 神经网络基础-神经网络补充概念-59-padding
  • 【开源免费】ChatGPT-Java版SDK重磅更新收获2.3k,支持插件模式、实现ChatGpt联网操作。
  • 情报与GPT技术大幅降低鱼叉攻击成本
  • Swift 周报 第三十五期
  • uni-app + SpringBoot +stomp 支持websocket 打包app
  • LeetCode--HOT100题(35)
  • idea插件grep console最佳实践
  • Android 12 源码分析 —— 应用层 二(SystemUI大体组织和启动过程)
  • 【C#】通用类型转换
  • 传统DNS、负载均衡服务发现框架与专业服务发现框架(Eurek、nacos)分析
  • js中数组常用操作函数
  • Windows、Mac、Linux端口占用解决
  • 企业文件透明加密软件——「天锐绿盾」数据防泄密管理软件系统
  • Postman接口自动化测试实例
  • 软件团队降本增效-构建人员评价体系
  • Python实现SSA智能麻雀搜索算法优化随机森林分类模型(RandomForestClassifier算法)项目实战
  • web JS高德地图标点、点聚合、自定义图标、自定义窗体信息、换肤等功能实现和高复用性组件封装教程
  • AlpacaFarm: A Simulation Framework for Methods that Learn from Human Feedback
  • 【Linux】Linux工具篇(yum、vim、gcc/g++、gdb、Makefile、git)
  • 自己实现 SpringMVC 底层机制 系列之-实现任务阶段 5- 完成 Spring 容器对象的自动装配 -@Autowried
  • linux的http服务
  • Restful架构简单了解
  • conda常用命令
  • Linux:shell脚本:基础使用(6)《正则表达式-awk工具》
  • 国际阿里云腾讯云:阿里云服务器怎么打包
  • FPGA中锁存器(latch)、触发器(flip-flop)以及寄存器(register)详解
  • 【正点原子STM32连载】第十八章 通用定时器PWM输出实验 摘自【正点原子】APM32F407最小系统板使用指南