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

Preview window opens via OpenGL and closes without error code (using x-server) #7052

Open
3 tasks done
Petros626 opened this issue Nov 11, 2024 · 1 comment
Open
3 tasks done

Comments

@Petros626
Copy link

Checklist

Steps to reproduce the issue

I first used Open3D in OpenPCDet:

pip install open3d

Then, I tried the new O3DVisualizer instead of Visualizer:

visualizer_test.py

Source Code

import open3d 
from tools.visual_utils import open3d_vis_utils_O3D as O3DVisualizer

def main(mode=str):
    logger = common_utils.create_logger()
    if mode == 'raw':
        logger.info('-----------------Quick Visualizer Demo of data-------------------------')
        logger.info(f'Mode for visualization: {mode}')
        demo_dataset = DemoDataset(dataset_cfg=dataset_cfg, class_names=class_names, training=False, root_path=data_path, logger=logger, data_processor_flag=False, fov_mode=False)
        logger.info(f'Total number of samples: \t{len(demo_dataset)}')
        data_dict = demo_dataset[2]
        points = data_dict['points']
        gt_boxes = data_dict['gt_boxes']
        O3DVisualizer.draw_demo_scenesO3D(points=points, gt_boxes=gt_boxes, point_colors=None, draw_origin=True)
        logger.info('Demo visualization of data done.')
def draw_demo_scenesO3D(points, gt_boxes=None, gt_names=None, ref_boxes=None, ref_labels=None, ref_scores=None, point_colors=None, draw_origin=True):
    if isinstance(points, torch.Tensor):
        points = points.cpu().numpy()
    if isinstance(gt_boxes, torch.Tensor):
        gt_boxes = gt_boxes.cpu().numpy()
    if isinstance(ref_boxes, torch.Tensor):
        ref_boxes = ref_boxes.cpu().numpy()

    app = open3d.visualization.gui.Application.instance
    app.initialize()
    vis = open3d.visualization.O3DVisualizer('Open3D - O3DVisualizer', 640, 480)
    vis.show_settings = True
   
    vis.point_size = 1
    vis.set_background((0, 0, 0, 1), None) # RGBA

    # draw origin (x = Forward, y = Left ,z = Upward)
    if draw_origin:
        axis_pcd = open3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0, origin=[0, 0, 0])
        vis.add_geometry('axis', axis_pcd)

    pts = open3d.geometry.PointCloud()
    pts.points = open3d.utility.Vector3dVector(points[:, :3]) # x, y, z
    

    if point_colors is None:
        pts.colors = open3d.utility.Vector3dVector(np.ones((points.shape[0], 3)))
    else:
        pts.colors = open3d.utility.Vector3dVector(point_colors)

    vis.add_geometry('points', pts)

    if gt_boxes is not None:
        vis = draw_demo_boxO3D(vis, gt_boxes, keypoint_color=(0, 0, 1)) 

    app.add_window(vis)
    app.run


def draw_demo_boxO3D(vis, gt_boxes, ref_labels=None, keypoint_color=(0, 0, 1)):
    
    for i in range(gt_boxes.shape[0]):
        line_set, box3d, middle_diagonal = translate_boxes_to_open3d_instanceO3D(gt_boxes[i], use_custom_diagonal_color=False)
        vis.add_geometry('line_set_' + str(i), line_set)

        class_idx = int(gt_boxes[i, 7])
        bbox_color = box_colormap[class_idx]
        
        # Add object keypoint
        center = gt_boxes[i, :3]
        size = gt_boxes[i, 3:6]
        keypoint = create_bbox_keypoint(class_idx, center, size, color=keypoint_color)
        vis.add_geometry('keypoint_' + str(i), keypoint)

        # Add object arrow
        heading = gt_boxes[i, 6]
        arrow = create_bbox_arrow(class_idx, middle_diagonal, heading, cylinder_r=0.015, cone_r=0.045, cylinder_h=0.5, cone_h=0.2, color=bbox_color)
        vis.add_geometry('arrow_' + str(i), arrow)

        # Add object label
    return vis

Terminal output

2024-11-11 20:46:43,515   INFO  -----------------Quick Visualizer Demo of data-------------------------
2024-11-11 20:46:43,515   INFO  Mode for visualization: raw
PointFeatureEncoder: absolute_coordinates_encoding() called with no points. Number output features: 4
DataProcessor: mask_points_and_boxes_outside_range() called with no data_dict
DataProcessor: shuffle_points() called with no data_dict
2024-11-11 20:46:43,515   INFO  DemoDataset: Loading raw KITTI dataset
2024-11-11 20:46:43,515   INFO  Total number of samples:        5
DemoDataset: __getitem__ called
DatasetTemplate: prepare_demo_data() called
PointFeatureEncoder: absolute_coordinates_encoding() processed 122798 points. Point features shape: (122798, 4)
FEngine (64 bits) created at 0x7f503003c010 (threading is enabled)
FEngine resolved backend: OpenGL
2024-11-11 20:46:51,999   INFO  Demo visualization of data done.

Error message

No error message appeared, when executing the code, preview window opens and closes.

Open3D, Python and System information

- Operating system: Windows 10 64-bit --> SSH and VcXsrv (X-Server) to Ubuntu 20.04
- Python version: Python 3.8.19 
- Open3D version: output from python: 0.18.0
- System architecture: x86 / arm64 
- Is this a remote workstation?: yes
- How did you install Open3D?: pip

Additional information

image

Thank you for your help!

@Petros626
Copy link
Author

Petros626 commented Nov 19, 2024

update:

I found out that I forget the brackets here:

app.run()

OpenGL version is 4.5 or 3.1?:

glxinfo | grep OpenGL
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 12.0.0, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 21.2.6
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.1 Mesa 21.2.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 21.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

Error message:

X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  72 (X_PutImage)
  Resource id in failed request:  0x200007
  Serial number of failed request:  169
  Current serial number in output stream:  185

Additional information:

image

current Problem:

there should be showed a 3D point cloud scene instead of this template (tried this too #2836). Could you take a look @wasdee, @littlesaohuo, @errissa

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