wu_xinjun
2022-03-04 e839f2e83fed7eaceb677242f5f9650a79fb8c43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os, sys
import numpy as np
 
def file_fliter(folder:str, file_ext:str, sort_format):
 
    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)
    # 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):
    count = 0
    ply_list = []
    with open(path,"r") as ply_file:
        # read the line
        for line in ply_file.readlines():
            # strip the str of the header
            if count < start_line:
                pass
            else:
                line_str_list = line.strip().split(' ')
                # convert the str type to float type
                line_float_list = []
                for value in line_str_list:
                    line_float_list.append(float(value))
 
                ply_list.append(line_float_list)
            count += 1
    ply_array = np.array(ply_list,dtype=np.float16)
 
    return ply_array
 
 
 
 
if __name__ == "__main__":
    ply_array = read_ply('src\\microwave\\demo\\demoData\\2522.ply')
    
    print(type(ply_array))
    print(ply_array)