From 4033aede52133f254f320838d2339ca3bfcb77e9 Mon Sep 17 00:00:00 2001
From: wu_xinjun <bent20140204@outlook.com>
Date: 星期二, 15 三月 2022 14:53:11 +0800
Subject: [PATCH] Squashed commit of the following:

---
 src/utils/bin2ply.py |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/utils/bin2ply.py b/src/utils/bin2ply.py
index 38b12ba..90cb889 100644
--- a/src/utils/bin2ply.py
+++ b/src/utils/bin2ply.py
@@ -21,8 +21,8 @@
     try:
         BINfolder = str(sys.argv[1])
         # example pod1-2022-02-21-13-25-03_packet125.udp --> 125
-        sort_lambda = lambda x:int(x.split('.')[0])
-        bin_files = file_fliter(BINfolder,'bin', sort_lambda)
+        # sort_lambda = lambda x:int(x.split('.')[0])
+        bin_files = file_fliter(BINfolder,'bin')
 
     except Exception as e:
         print(e)
@@ -31,24 +31,31 @@
     for file in bin_files:
 
         filename = file
-        (fn, ext) = os.path.splitext(filename)
+        # (fn, ext) = os.path.splitext(filename)
         with open(os.path.join(BINfolder,file), "rb") as bin_file:
             buf = bin_file.read()
-            point_cloud = MicroWaveParser.ParserFrame(buf)
-            with open(os.path.join(BINfolder,fn +".ply"), "w") as f:
-                f.write("ply\n")
-                f.write("format ascii 1.0\n")
-                f.write("comment MicroWave2Ply generated\n")
-                f.write("element vertex %d\n" % len(point_cloud))
-                f.write("property float x\n")
-                f.write("property float y\n")
-                f.write("property float z\n")
-                f.write("element face 0\n")
-                f.write("property list uchar int vertex_indices\n")
-                f.write("end_header\n")
-                n_p = 0
-                for p in point_cloud:
-                    x, y, z = p
-                    f.write("{:.5f} {:.5f} {:.5f}\n".format(x, y, z))
-                    n_p += 1
-                print(time.asctime(),f"Frame {fn}.ply have been saved with {n_p} points!")
\ No newline at end of file
+            buf_data = MicroWaveParser.ParserFrame(buf)
+
+
+            for frame in buf_data:
+                Frame_id = frame[0]
+                FrameNumber = frame[1]
+                point_cloud = frame[2]
+                if len(point_cloud) != 0 :
+                    with open(os.path.join(BINfolder,str(FrameNumber) +".ply"), "w") as f:
+                        f.write("ply\n")
+                        f.write("format ascii 1.0\n")
+                        f.write("comment MicroWave2Ply generated\n")
+                        f.write("element vertex %d\n" % len(point_cloud))
+                        f.write("property float x\n")
+                        f.write("property float y\n")
+                        f.write("property float z\n")
+                        f.write("element face 0\n")
+                        f.write("property list uchar int vertex_indices\n")
+                        f.write("end_header\n")
+                        n_p = 0
+                        for p in point_cloud:
+                            x, y, z = p
+                            f.write("{:.5f} {:.5f} {:.5f}\n".format(x, y, z))
+                            n_p += 1
+                        print(time.asctime(),f"File {file} Frame {FrameNumber}.ply have been saved with {n_p} points!")
\ No newline at end of file

--
Gitblit v1.9.1