Skip to content

Error plotting custom data with np.uint8 dtype #671

@GregorioFornetti

Description

@GregorioFornetti

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions