from email import header import os, sys import numpy as np import time from tqdm import tqdm def file_fliter(folder:str, file_ext:str, sort_format = None): files_List = os.listdir(folder) target_files = [] # flitered by file extention name for file in files_List: if file.split('.')[-1] == file_ext: target_files.append(file) if sort_format is not None: # sort the list by the sort_format target_files.sort(key=sort_format) return target_files def read_ply(path:str,start_line:int = 10): ply_array = np.load(path,skiprows=start_line) return ply_array def write_ply(data:np.array,folder:str,name:str): file = os.path.join(folder,name+".ply") n_p = data.shape[0] header = ["ply\nformat ascii 1.0\n", "comment write_ply generated\n", f"element vertex {n_p}\n", "property float x\n", "property float y\n", "property float z\n", "element face 0\n", "property list uchar int vertex_indices\n", "end_header"] np.savetxt(file,data, delimiter=" ", header="".join(header), comments="", fmt='%.6f') print(f"{time.asctime()} {name}.ply have been saved with {n_p} points!") if __name__ == "__main__": ply_array = read_ply('src\\microwave\\demo\\demoData\\2522.ply') print(type(ply_array)) print(ply_array)