Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fieldnames in multiple exemple #347

Open
Raizencorp opened this issue Feb 21, 2023 · 0 comments
Open

Fieldnames in multiple exemple #347

Raizencorp opened this issue Feb 21, 2023 · 0 comments

Comments

@Raizencorp
Copy link

Raizencorp commented Feb 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant