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

Offscreen rendering doesn't work on server & workarounds & fixes #15

Open
jimeiyang opened this issue Feb 28, 2022 · 1 comment
Open

Comments

@jimeiyang
Copy link

Hi Davis,

I found the offscreen rendering doesn't work with the required installation. My workaround is to 1) re-installing pyrender with mesa and 2) adding os.environ["PYOPENGL_PLATFORM"] = "osmesa" to viz_fitting_rgb.py.

Then there is a related issue. Even if it is set as "RGBA" by default, my renderer only generates the color_image with three channels, which leads to an error of computing the valid_mask here and then the composition here.

My fix in mesh_viewer.py is as follows:

input_img = self.cur_bg_img
if color_img.shape[2] == 4:
    output_img = (color_img[:, :, :-1] * color_img[:,:,3:] +(1.0 - color_img[:,:,3:])*input_img)
else:
    valid_mask = (depth_img > 0)[:, :, np.newaxis]
     output_img = (color_img * valid_mask + (1 - valid_mask) * input_img)

-Jimei

@AIML
Copy link

AIML commented Jul 12, 2022

When use offscreen render mode in Pyrender with platform='osmesa', it will produce 3 channel image, which means the alpha channel is lossed. I don't konw why, but it is. Instead you can do like follow trickly:

# valid_mask = (color_img[:, :, -1] > 0)[:, :, np.newaxis]
valid_mask = (np.sum(color_img, axis=-1) > 0)[:, :, np.newaxis]

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

2 participants