Closed SERPENT-H closed 4 years ago
That should be fairly straight forward, if you understand how xyz files of semantic3d is being converted to h5 file, the next step will be to use laspy extension and grab the xyz...or any other attributes and feed to h5 creator.
i use this function instead of 50 to 58 line of https://github.com/yangyanli/PointCNN/blob/master/data_conversions/prepare_semantic3d_data.py
def read_las(filename_las,remove_noise=False): print('{}-Loading {}...'.format(datetime.now(), filename_las)) f = laspy.file.File(filename_las, mode='r') xyzirgb_num = f.header.point_records_count label = np.array(f.classification,dtype=np.int16) if remove_noise: keep_points = np.logical_and(label != 18, label != 7) print('Data will be processed without noise class 7, and 18') else: keep_points = np.logical_and(label>=0, label<256) print('Inactivate noise removal....you will have noise class in h5') xyz = np.rollaxis(np.vstack((f.x[keep_points], f.y[keep_points], f.z[keep_points])),1) i = np.array(f.intensity[keep_points],dtype=np.int32).reshape(len(f.X[keep_points]),1)/65535 rcrn = np.rollaxis(np.vstack((f.return_num[keep_points],f.num_returns[keep_points])),1)/10 labels = np.array(f.classification[keep_points],dtype=np.int16)#.reshape(len(f.X[keep_points]),1) label1=labels.copy() unique,count=np.unique(label1,return_counts=True) print('Class codes:',dict(zip(unique,count))) return xyz, i, rcrn, labels, xyzirgb_num
It looks good,but I have no idea how to operate in details.
Hi, I am working on a similar problem. I have .las file and I used las tools to convert it to Xyz txt file. Each line has x,y,z values separated by a space. Can I use the above function to convert the Xyz text file and use the architecture to train? I am very new to point cloud and any info would be helpful.
Hi, I am working on a similar problem. I have .las file and I used las tools to convert it to Xyz txt file. Each line has x,y,z values separated by a space. Can I use the above function to convert the Xyz text file and use the architecture to train? I am very new to point cloud and any info would be helpful.
Could you please tell me how can I convert .las file to .txt file. I would be grateful if you send me your program.
@SERPENT-H: If you see semantic3d data preparation part the x,y,z is loaded through np.loadtxt function, the function that i had given you earlier is a replacement of np.loadtxt, try loading a text file of semantic3d by np.loadtxt function and understand the shape and values of the data. You can then understand the problem easily. I used laspy extension to read the data from las/laz file files. Hope this helps. Converting to txt files is also an option but i would not prefer to do that for unnecessary disk space usage.
@SERPENT-H: If you see semantic3d data preparation part the x,y,z is loaded through np.loadtxt function, the function that i had given you earlier is a replacement of np.loadtxt, try loading a text file of semantic3d by np.loadtxt function and understand the shape and values of the data. You can then understand the problem easily. I used laspy extension to read the data from las/laz file files. Hope this helps. Converting to txt files is also an option but i would not prefer to do that for unnecessary disk space usage.
Thank u so much.I converted las file to txt file,and then converted it to h5 file,I didn't use the semantic3d data preparation file,So I am worrying whether my h5 file is useful.I will try the way you said just now.
@SERPENT-H Hi. I converted las to txt using lastools, a software. Can you tell me how did you convert your x,y,z into h5 file? was it by the above code or by any other approaches?
@SERPENT-H Hi. I converted las to txt using lastools, a software. Can you tell me how did you convert your x,y,z into h5 file? was it by the above code or by any other approaches?
I follow this pagehttps://blog.csdn.net/qq_41965957/article/details/103471757 and it do form a .h5 file,but I doubt it can be used because it has no label.
@SERPENT-H Yeah, but the labels have to present in your .las or .txt file if I am not wrong.
THANKS FOR EVERYONE! I just converted my txt file to h5 file by using prepare_scannet_cls_data.py file that is put in the data_conversions folder. Here are my solutions: 1.Convert .las files to .txt files by using CloudCompare(a point cloud software) The txt files contain x,y,z,r,g,b,intensity information
@SERPENT-H can You share simple instruction what to change and how to prepare las files for that? They must be labeled first or what? I want ot detect cars and power lines etc
@SERPENT-H Happy that you were able to generate .h5 files. I face the same issue. I have a lot of .txt files containing (X,Y,Z,R, G, B, Classification) on each line of the file. I want to create the h5 files for the same. Kindly share the script that you used. It will be of immense help to me. Thanks in advance
That should be fairly straight forward, if you understand how xyz files of semantic3d is being converted to h5 file, the next step will be to use laspy extension and grab the xyz...or any other attributes and feed to h5 creator.
i use this function instead of 50 to 58 line of https://github.com/yangyanli/PointCNN/blob/master/data_conversions/prepare_semantic3d_data.py