使用tinyply.net保存ply格式点云

1.github项目地址

https://github.com/yk35/tinyply.net/tree/master

2.安装方式。文档说明需要下载项目后编译生成dll文件

3.按文档说明生产dll文件

4.在自己的项目中引用tinyplynet.dll即可

5.github文档中的使用说明

6.我的代码示例

复制代码
     public static async Task<string> SavePointCloudToPLYV4(string PlyName, SurfacePoint[] surfaceBuffer, bool isAsync,bool isBinary)
     {
         string result = "";

         try
         { 
             string PlyDir = "";

             PlyDir = AppDomain.CurrentDomain.BaseDirectory + "AppPLY";
             if (!Directory.Exists(PlyDir))
             {
                 Directory.CreateDirectory(PlyDir);
             }

             string PLYFile = $@"{PlyDir}/{PlyName}.ply";

           
                 _ = Task.Run(async () =>
                 {
                     Serilog.Log.Logger.Debug($"开始异步拼接PLY文件内容");

                     try
                     {
                         var vertices = new List<double>();
                         foreach(var item in surfaceBuffer)
                         {
                             vertices.Add(item.x);
                             vertices.Add(item.y);
                             vertices.Add(item.z); 
                         }

                         var output = new PlyFile();
                         output.AddPropertiesToElement("vertex", new[] { "x", "y", "z" }, vertices);
                         //output.AddListPropertyToElement("face", "vertex_indices", faces);
                         using var outStream = File.Create(PLYFile);
                         output.Write(outStream, isBinary); // true = binary
 
                     }
                     catch (Exception ex)
                     {
                         Serilog.Log.Logger.Error($" 异步点云保存出现异常 [{PLYFile}] {ex.Message} {ex.StackTrace}");
                     }

                     Serilog.Log.Logger.Debug($" 异步点云保存完成 [{PLYFile}]");
                 });
              
        
             result = PLYFile;
 
         }
         catch (Exception ex)
         {
             Serilog.Log.Logger.Error($" 保存点云出现异常[{PlyName}] {ex.Message}");
          
         }
 

         return result;
     }

使用二进制格式ply文件保存和读取速度会比ascii码格式快很多

相关推荐
波力海苔夹心脆6759 小时前
C# 视觉检测实战:PLC 按钮触发 VisionPro 检测,OK 亮灯 / NG 灭灯(西门子 PLC,含界面显示与图片存档)
开发语言·经验分享·c#·自动化·视觉检测·.net
hez201011 小时前
一行代码在 .NET 项目里启用 Satori GC
c#·.net·.net core·gc·clr
QUDONG_biubiubiu14 小时前
.NET Runtime 6.0/7.0/8.0/9.0下载修复教程,软件打不开这样解决
.net·net runtime下载·net运行库修复·net runtime安装
宝桥南山15 小时前
.NET 11 - 尝试创建一下AGUIServer和AGUIClient(基于新版.NET SDK for AG-UI)
microsoft·ai·微软·c#·aigc·.net
波力海苔夹心脆67515 小时前
C# LINQ 入门到上手:一篇讲透查询语法、常用操作符与延迟执行(含示例与速查表
经验分享·c#·.net·solr·linq
小羊没烦恼!2 天前
Windows Azure Platform体验(1):Windows Azure
java·大数据·后端·python·flask·word·.net
CSharp精选营3 天前
IIS 后面挂 Kestrel,这 3 个配置错了就 502
kestrel·.net·iis配置
鑫 源3 天前
C#源码开源, 获取macOS 电池数据,包括iOS (xamarin开发)
c#·.net·xamarin
xiangcns4 天前
PDMS PiplineTool(三十)一堆小优化+一个彩蛋功能
.net·二次开发·pdms