Skip to content

Fieldnames in multiple exemple #347

Description

@Raizencorp

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):

  • OS: ubuntu 18.04
  • Version master branch

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(np_type)
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions