Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code that takes data in .txt format and converts it to .ply format, after that it performs some operations on it. when I run the code it shows me the given error! please help me fix that error.
the code:

def convert_pc2ply(anno_path, save_path):
 
    data_list = []
    for f in glob.glob(join(anno_path, '*.txt')):
         class_name = os.path.basename(f).split('_')[0]
         if class_name not in gt_class: 
           class_name = 'clutter'
         pc = pd.read_csv(f, header=None, delim_whitespace=True).values
         labels = np.ones((pc.shape[0], 1)) * gt_class2label[class_name]
         data_list.append(np.concatenate([pc, labels], axis=1))  # Nx7

    pc_label = np.concatenate((data_list, [0]))
    xyz_min = np.amin(pc_label, axis=0)[0:3]
    pc_label[:, 0:3] -= xyz_min
    xyz = pc_label[:, :3].astype(np.float32)
    colors = pc_label[:, 3:6].astype(np.uint8)
    labels = pc_label[:, 6].astype(np.uint8)
    write_ply(save_path, (xyz, colors, labels), ['x', 'y', 'z', 'red', 'green', 'blue', 'class'])


the error:
<pre>Traceback (most recent call last):
  File "data_prepare.py", line 78, in <module>
    convert_pc2ply(annotation_path, join(original_pc_folder, out_file_name))
  File "data_prepare.py", line 48, in convert_pc2ply
    xyz_min = np.amin(pc_label, axis=0)[0:3]
  File "<__array_function__ internals>", line 6, in amin
  File "/home/youssefhany/miniconda3/envs/randlanet/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 2793, in amin
    keepdims=keepdims, initial=initial, where=where)
  File "/home/youssefhany/miniconda3/envs/randlanet/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 90, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: operands could not be broadcast together with shapes (61528,7) (19727,7)


What I have tried:

I don't understand the error or where it came from to try!
Posted
Comments
Richard MacCutchan 2-Oct-21 4:20am    
The message tells you where it cam from: File "data_prepare.py", line 48, in convert_pc2ply.

You need to use the debugger to find out what values are causing the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900