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

Renderer.r contains only 0 #51

Open
iegorval opened this issue Apr 13, 2021 · 1 comment
Open

Renderer.r contains only 0 #51

iegorval opened this issue Apr 13, 2021 · 1 comment

Comments

@iegorval
Copy link

iegorval commented Apr 13, 2021

Good afternoon,

I have been struggling for some time to make OpenDR work in some other project I have found on github (https://github.com/silviazuffi/smalr_online). So, apparently, even though the renderer parameters, vertices, faces etc seem to make sense, the r it returns contains only zeros. The rendered image is then empty.

Some other script (https://smpl.is.tue.mpg.de/downloads -> Download version 1.1.0 for Python 2.7 (male, female, neutral all with 300 shape PCs) -> smpl -> smpl_webuser -> hello_world -> render_smpl.py (cannot share the code) seems to actually render the image properly, though the input and the renderer setup are very similar.

Is anyone familiar with a similar issue? I use Ubuntu 18.04, Python 3.8, latest version of opend from PyPi.

@iegorval
Copy link
Author

UPD: This is probably one of the weirdest error I have encountered (that is why I apologize for the original description, that was not really detailed - I was really clueless about the possible source).

After (quite) some time, I have discovered that the OpenGL imports breaks the renderer. Or, at least they do for me. I have managed to make a (hopefully) reproducible example, based on the OpenDR demo:

import chumpy as ch
from OpenGL.GL import glPixelStorei, glMatrixMode, glHint, glTexParameterf, glDisableClientState

from opendr.renderer import ColoredRenderer
from opendr.lighting import LambertianPointLight

rn = ColoredRenderer()

from opendr.util_tests import get_earthmesh
m = get_earthmesh(trans=ch.array([0,0,4]), rotation=ch.zeros(3))
w, h = (320, 240)

from opendr.camera import ProjectPoints
rn.camera = ProjectPoints(v=m.v, rt=ch.zeros(3), t=ch.zeros(3), f=ch.array([w,w])/2., c=ch.array([w,h])/2., k=ch.zeros(5))
rn.frustum = {'near': 1., 'far': 10., 'width': w, 'height': h}
rn.set(v=m.v, f=m.f, bgcolor=ch.zeros(3))

rn.vc = LambertianPointLight(
f=m.f,
v=rn.v,
num_verts=len(m.v),
light_pos=ch.array([-1000,-1000,-1000]),
vc=m.vc,
light_color=ch.array([1., 1., 1.]))

import cv2
cv2.imshow('example', rn.r)
cv2.waitKey(0)
cv2.destroyAllWindows()

The from OpenGL.GL import glPixelStorei, glMatrixMode, glHint, glTexParameterf, glDisableClientState line makes the renderer output equal to 0. If I comment this line OR move this line after the opendr imports, the renderer suddenly works. Now, I am not sure if this is the problem of OpenGL, or the opendr, but there seem to be some conflict, which I am not sure how to address.

I get this issue on the Ubuntu 18.04, PyOpenGL 3.1.4 and 3.1.5 (tried both), opendr 0.78.

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