daavoo / pyntcloud

pyntcloud is a Python library for working with 3D point clouds.
http://pyntcloud.readthedocs.io
MIT License
1.42k stars 224 forks source link

Fieldnames in multiple exemple #347

Open Raizencorp opened 1 year ago

Raizencorp commented 1 year ago

Describe the bug When a pcd file get for exemple : FIELDS x y z intensity ring where _ are juste empty field who have a count number as below: COUNT 1 1 1 4 1 1 10

To Reproduce run Pyntcloud.from_file('path/to/file.pcd)

Expected behavior error warning, "ValueError: field '__0000' occurs more than once"

Desktop (please complete the following information):

Fix ` def build_dtype(metadata): """ build numpy structured array dtype from pcl metadata. note that fields with count > 1 are 'flattened' by creating multiple single-count fields. TODO: allow 'proper' multi-count fields. """ fieldnames = [] typenames = [] count = 0 for f, c, t, s in zip(metadata['fields'], metadata['count'], metadata['type'], metadata['size']): np_type = pcd_type_to_numpy_type[(t, s)] if c == 1: fieldnames.append(f) typenames.append(nptype) else: fieldnames.extend(['%s%04d' % (f, i + count) for i in range(c)]) count += c typenames.extend([np_type] * c)

# This modify the fieldnames automatically generated who create an error

dtype = np.dtype(list(zip(fieldnames, typenames)))
return dtype

` add a count to prevent repetition on dataframe