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

Error plotting custom data with np.uint8 dtype #671

Open
3 tasks done
GregorioFornetti opened this issue Feb 3, 2025 · 0 comments
Open
3 tasks done

Error plotting custom data with np.uint8 dtype #671

GregorioFornetti opened this issue Feb 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@GregorioFornetti
Copy link

Checklist

Describe the issue

When I try to plot a custom point cloud data with an additional attribute (classes attribute) with np.uint8 dtype, all my labels wrongly turn to zero. When using with the dtype np.int64, the plot works fine.

Steps to reproduce the bug

import numpy as np
import open3d.ml.torch as ml3d


# Correct
data = [
    {
        'name': 'test',
        'points': np.array([
            [0, 0, 0],
            [0.1, 0, 0], [0.1, 0.1, 0],
            [0.2, 0, 0], [0.2, 0.1, 0], [0.2, 0.2, 0]
        ]),
        'classes': np.array([
            1,
            0, 0,
            2, 2, 2
        ], dtype=np.int64)
    }
]

lut = ml3d.vis.LabelLUT()
lut.add_label('zero', 0, [1, 0, 0])
lut.add_label('one',  1, [0, 1, 0])
lut.add_label('two',  2, [0, 0, 1])

vis = ml3d.vis.Visualizer()
vis.set_lut("classes", lut)

vis.visualize(data)


# Wrong
data = [
    {
        'name': 'test',
        'points': np.array([
            [0, 0, 0],
            [0.1, 0, 0], [0.1, 0.1, 0],
            [0.2, 0, 0], [0.2, 0.1, 0], [0.2, 0.2, 0]
        ]),
        'classes': np.array([
            1,
            0, 0,
            2, 2, 2
        ], dtype=np.uint8)
    }
]

lut = ml3d.vis.LabelLUT()
lut.add_label('zero', 0, [1, 0, 0])
lut.add_label('one',  1, [0, 1, 0])
lut.add_label('two',  2, [0, 0, 1])

vis = ml3d.vis.Visualizer()
vis.set_lut("classes", lut)

vis.visualize(data)

Error message

Using np.uint8, the plot is:

Image

Where all points are wrongly in the classe zero (red)

Expected behavior

Its expected the plot with np.uint8 to be the same of the plot with np.int64. The result of the np.int64 is given bellow:

Image

Open3D, Python and System information

- Operating system: Windows 11 (WSL Ubuntu 24.01)
- Python version: Python 3.12.3
- Open3D version: 0.19.0
- System type: x86_64
- Is this remote workstation?: no
- How did you install Open3D?: pip (with venv)

Additional information

No response

@GregorioFornetti GregorioFornetti added the bug Something isn't working label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant