Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

crash when using egl headless render #302

Copy link
Copy link
@vipcxj

Description

@vipcxj
Issue body actions

here is code

main.py

import os
os.environ['PYOPENGL_PLATFORM'] = 'egl'
import open3d as o3d
import renderer as renderer

if __name__ == '__main__':    
    try:
        mesh_src = o3d.io.read_triangle_mesh("XXX.obj")
        renderer.render_to_image(mesh_src, "XXX.jpg")
    except Exception as e:
        print(e)

renderer.py

import open3d as o3d
import trimesh
import numpy as np
import matplotlib.pyplot as plt
import pyrender

def render_to_image(mesh, output_path: str, width=640, height=480):
    _mesh = trimesh.Trimesh(
        vertices=np.asarray(mesh.vertices), 
        faces=np.asarray(mesh.triangles), 
        vertex_normals=np.asarray(mesh.vertex_normals),
        # vertex_colors=np.asarray(mesh.vertex_colors),
    )
    
    scene = pyrender.Scene()
    mesh = pyrender.Mesh.from_trimesh(_mesh)
    scene.add(mesh)
    camera = pyrender.PerspectiveCamera(yfov=np.pi / 3.0)
    camera_pose = np.array([
        [1.0, 0.0, 0.0, 0.0],
        [0.0, 1.0, 0.0, -0.5],
        [0.0, 0.0, 1.0, 1.0],
        [0.0, 0.0, 0.0, 1.0]
    ])
    scene.add(camera, pose=camera_pose)
    light = pyrender.PointLight(color=np.ones(3), intensity=10.0)
    scene.add(light, pose=camera_pose)
    
    r = pyrender.OffscreenRenderer(viewport_width=width, viewport_height=height, point_size=1.0)
    
    // crash here, no conole output, no exception, just crash.
    color, depth = r.render(scene)
    
    r.delete()
    
    if output_path is not None and output_path != "":
        plt.imsave(output_path, color)
    
    return color, depth

After debug, I found crash here:

        total_sz = sum(attr_sizes)
        offset = 0
        for i, sz in enumerate(attr_sizes):
            // crash here
            glVertexAttribPointer(
                i, sz, GL_FLOAT, GL_FALSE, FLOAT_SZ * total_sz,
                ctypes.c_void_p(FLOAT_SZ * offset)
            )
            glEnableVertexAttribArray(i)
            offset += sz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.