@@ -121,14 +121,14 @@ def label_points(normals, reference=np.array([0, 0, 1])):
121121 else :
122122 normalised_ref = reference
123123
124- # Determine angle threshold
124+ # Determine angle threshold
125125 cos_angle = np .cos (np .deg2rad (angle_degree ))
126126
127127 # Calculate dot product for all normals at once
128128 dot_products = np .dot (normals , normalised_ref )
129129
130130 # Check threshold and create an array of labels based on the dot product values
131- label_array = np .where (np .abs (dot_products ) <= cos_angle , 1 , 0 )
131+ label_array = np .where (np .abs (dot_products ) <= cos_angle , 2 , 1 )
132132
133133 return label_array
134134
@@ -142,6 +142,13 @@ def write_label(label_array, folder_path, filename):
142142 # Id is set by default to 0
143143 file .write (bin_label )
144144
145+ # If the intensity or the coordinates of a point is 0, label it as void (0)
146+ def label_void (data , labels ):
147+ for i in range (data .shape [0 ]):
148+ if (data [i , 0 ] == 0 and data [i , 1 ] == 0 and data [i , 2 ] == 0 ) or data [i , 3 ] == 0 :
149+ labels [i ] = 0
150+ return labels
151+
145152
146153# List of all files in the bin folder
147154bin_folder = os .path .join (id_sequence_folder , folder_data )
@@ -159,5 +166,7 @@ def write_label(label_array, folder_path, filename):
159166 normals = estimate_normals (data_bin , nb_neighboors )
160167 # Generate an array of labels
161168 labels = label_points (normals )
169+ # Check void points
170+ labels = label_void (data_bin , labels )
162171 # Write the resulting .label file
163172 write_label (labels , label_folder , file_name )
0 commit comments