isl-org / Open3D-ML

An extension of Open3D to address 3D Machine Learning tasks
Other
1.88k stars 321 forks source link

Request a proper display of colored gui.Label3D bounding box meta info in o3d gui #316

Closed Eralien closed 2 years ago

Eralien commented 3 years ago

I have been trying to visualize my own pointcloud sequence data, using the open3d._ml3d.vis.visualize.Visualizerin Linux. I am using pip installed open3d in python=3.8, ubuntu 18.04.

I implemented my own class inherited from open3d._ml3d.datasets.base_dataset.BaseDataset and BaseDatasetSplitfollowing the example customdataset.py, and called the Visualizer.visualize_dataset method. The plotting of bounding boxes labels/info were not what I expected. My implementation was based on the SemanticKitti and NuScenes visualization impl.

The problems are:

  1. Unable to show bbox meta information. The o3d._ml3d.vis.boundingbox.BoundingBox3D constructor implies that a user-defined string \p meta can be initialized, and \p show_meta is the proper way to show it. Yet the open3d._ml3d.vis.visualize.Visualizer calls BoundingBox3D.create_lines static method, which only returns a o3d.geometry.LineSet object. There was no text shown.
  2. Unable to change the color of the Label3D. This above problem can be solved by editing the visualizer._update_bounding_boxes method in line 1160:

            self._3d.scene.remove_geometry(name)
    
            ################## HANDLE OBJ 3D LABEL SHOW #################
            for _, obj_3d_label in self._obj_3d_labels.items():
                self._3d.remove_3d_label(obj_3d_label)
            self._obj_3d_labels.clear()
            ################## HANDLE OBJ 3D LABEL SHOW #################
    
            if len(boxes) > 0:
                lines = BoundingBox3D.create_lines(boxes, lut)
                self._3d.scene.add_geometry(name, lines, mat)
    
                ################## HANDLE OBJ 3D LABEL SHOW #################
                # Starts with open3d v1.13
                for box in boxes:
                    self._obj_3d_labels[box.meta] = self._3d.add_3d_label(box.center, box.meta)
                    self._obj_3d_labels[box.meta].color.set_color(0.8, 0.8, 0)
                ################## HANDLE OBJ 3D LABEL SHOW #################
    
                if name not in self._name2treenode:
                    self._add_tree_name(name, is_geometry=False)
    
            self._3d.force_redraw()

Method add_3d_label returns a Label3D object, and I found no way I can change its shown color. I tried to call Label3D.color.set_color which could change the color memory but not the label color shown. The self._obj_3d_labels is only a dict to store the generated label object.

sanskar107 commented 2 years ago

@errissa could you please take a look at this ?

errissa commented 2 years ago

@Eralien Please try changing the line that sets the text color to:

self._obj_3d_labels[box.meta].color = gui.Color(0.8, 0.8, 0)

The color of the 3D Text is a property and should be set via assignment rather than calling methods on (e.g., set_color)

sanskar107 commented 2 years ago

Closing due to inactivity. Feel free to reopen if issue still persists.