使用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码格式快很多

相关推荐
半亩码田12 小时前
【.NET新特性·第14篇】.NET 10 运行时与 SDK 新特性
.net
祀爱16 小时前
C# MQTT 连接服务
后端·c#·.net
足球中国2 天前
.net DataExcel控件 2.11.1.53版发布
c#·.net·excel
rockey6272 天前
C#脚本引擎之AScript与Jurassic、Jint对比
javascript·c#·.net·js·script·动态脚本
界面开发小八哥2 天前
界面控件DevExpress WinForms中文帮助文档 - 入门指南
ai·c#·.net·devexpress·ui开发·winforms
清风与日月3 天前
Yitter.IdGenerator:高性能分布式唯一ID生成器详解
分布式·c#·.net·.netcore
大鹏说大话3 天前
用 Semantic Kernel 在 .NET 中构建你的第一个 AI 智能体(Agent)
人工智能·.net
七仔啊3 天前
C#、.NET 、ASP.NET Core、Visual Studio全系列快速入门
c#·asp.net·.net
超龄超能程序猿3 天前
实战优化:.NET 8 容器 Debian 源+时间同步企业级 Dockerfile
运维·debian·.net
一个帅气昵称啊3 天前
.Net C# AI智能体开发-快速开始
开发语言·c#·.net