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

Problem with ColoredRenderer and TexturedRenderer #1

Open
benjiebob opened this issue Mar 3, 2018 · 24 comments
Open

Problem with ColoredRenderer and TexturedRenderer #1

benjiebob opened this issue Mar 3, 2018 · 24 comments

Comments

@benjiebob
Copy link

benjiebob commented Mar 3, 2018

Hi,
I've just downloaded the modern opendr library as I'm hoping to accelerate fitting SMPL to some data points. However, I'm having trouble getting the ColoredRenderer and TexturedRenderer to work properly.

For me, the demo code found in this repo at 'opendr/opendr/init.py' results in an error:

import chumpy as ch
from opendr.renderer import TexturedRenderer
rn = TexturedRenderer()

# Assign attributes to renderer
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, vc=m.vc, texture_image=m.texture_image, ft=m.ft, vt=m.vt)

# Show it
import matplotlib.pyplot as plt
plt.ion()
plt.imshow(rn.r)
plt.show()

Error message:

Traceback (most recent call last):
  File "earth_renderer.py", line 17, in <module>
    plt.imshow(rn.r)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 555, in r
    self._call_on_changed()
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 550, in _call_on_changed
    self.on_changed(self._dirty_vars)
  File "/scratch/bjb56/download/opendr/opendr/renderer.py", line 1422, in on_changed
    super().on_changed(which)
  File "/scratch/bjb56/download/opendr/opendr/renderer.py", line 948, in on_changed
    self.vbo_verts_face.set_array(np.array(self.verts_by_face).astype(np.float32))
AttributeError: 'TexturedRenderer' object has no attribute 'vbo_verts_face'

A simpler variant of this with the ColoredRenderer also results in an error. I'm happy to post this too if needed.

Would be grateful if you could advise here.

Thanks,

Ben

@polmorenoc
Copy link
Owner

Hi Ben,
actually those demos are outdated as they are part of OpenDR code I initially forked from Matt Loper's OpenDR. Too many things have changed for them to be working unfortunately.

Can you try the script demo_fit_cube.py or demo_fit_teapot.py, instead?

@benjiebob
Copy link
Author

benjiebob commented Mar 5, 2018

I can see in utils.py there is some more complicated code for setting up a TexturedRenderer which I overlooked before. Actually, I want a ColoredRenderer for my purposes but I will see if I can manipulate your existing code to work for me.

Now, I'm trying the two demos you have identified. The demo_fit_cube.py example runs fine, showing three windows ("Init Cube", "GT object" and "Fitted Object") with the GT & Fitted looking pretty similar.

However, with the teapot demo I obtain lots of scary error messages:

python demo_fit_teapot.py
Initializing GLFW.
FRAMEBUFFER ERR: 36053
FRAMEBUFFER ERR: 36053
glValidateProgram: None
glGetProgramInfoLog
GL_MAX_VERTEX_ATTRIBS: 16
0
Initializing Texture OpenGL.
Traceback (most recent call last):
  File "demo_fit_teapot.py", line 206, in <module>
    ch.minimize({'raw': negLikModel}, bounds=None, method=methods[method], x0=chShapeParams, callback=cb, options=options)
  File "/scratch/bjb56/download/opendr/chumpy/optimization.py", line 462, in minimize
    x1, fX, i = min_ras.minimize(np.concatenate([free_variable.r.ravel() for free_variable in free_variables]), residuals, scalar_jacfunc, args=(obj, obj_scalar, free_variables), on_step=callback, maxnumfuneval=maxiter)
  File "/scratch/bjb56/download/opendr/chumpy/minimize_ras.py", line 83, in minimize
    df0 = grad(X, *args)
  File "/scratch/bjb56/download/opendr/chumpy/optimization.py", line 437, in scalar_jacfunc
    jacs = [obj_scalar.dr_wrt(wrt) for wrt in free_variables]
  File "/scratch/bjb56/download/opendr/chumpy/optimization.py", line 437, in <listcomp>
    jacs = [obj_scalar.dr_wrt(wrt) for wrt in free_variables]
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 711, in dr_wrt
    dr2 = p.dr_wrt(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 711, in dr_wrt
    dr2 = p.dr_wrt(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 711, in dr_wrt
    dr2 = p.dr_wrt(wrt)
  [Previous line repeated 10 more times]
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 714, in dr_wrt
    indirect_dr = self.compute_rop(p, rhs=dr2)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 676, in compute_rop
    dr = self._compute_dr_wrt_sliced(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 266, in _compute_dr_wrt_sliced
    result = self.compute_dr_wrt(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 2323, in compute_dr_wrt
    idxs_postsum = np.tile(idxs_postsum, tp)
  File "/scratch/bjb56/miniconda3/envs/py3/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 932, in tile
    return c.reshape(shape_out)
TypeError: 'numpy.float64' object cannot be interpreted as an integer

Perhaps this is Python3.6 expecting integer array sizes for the reshape rather than a float64?

@polmorenoc
Copy link
Owner

Glad the cube demo works for you.
I think you may be right, I'll have a look at the script . I believe sometimes chumpy returns an array instead of a a float64 directly which can mess up with some of the optimizers.

@z6491679
Copy link

z6491679 commented Nov 1, 2018

I have met the same error:
Traceback (most recent call last):
File "E:\Anaconda\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "E:\Anaconda\envs\tensorflow\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\mesh\hmr-master\demo.py", line 143, in
main(config.img_path, config.json_path)
File "D:\mesh\hmr-master\demo.py", line 130, in main
visualize(img, proc_param, joints[0], verts[0], cams[0])
File "D:\mesh\hmr-master\demo.py", line 51, in visualize
vert_shifted, cam=cam_for_render, img=img, do_alpha=True)
File "D:\mesh\hmr-master\src\util\renderer.py", line 79, in call
color_id=color_id)
File "D:\mesh\hmr-master\src\util\renderer.py", line 225, in render_model
imtmp = simple_renderer(rn, verts, faces, color=color)
File "D:\mesh\hmr-master\src\util\renderer.py", line 179, in simple_renderer
return rn.r
File "E:\Anaconda\envs\tensorflow\lib\site-packages\chumpy\ch.py", line 595, in r
self._call_on_changed()
File "E:\Anaconda\envs\tensorflow\lib\site-packages\chumpy\ch.py", line 590, in _call_on_changed
self.on_changed(self._dirty_vars)
File "E:\Anaconda\envs\tensorflow\lib\site-packages\opendr-0.73-py3.5.egg\opendr\renderer.py", line 1082, in on_changed
self.vbo_verts_face.set_array(np.array(self.verts_by_face).astype(np.float32))
AttributeError: 'ColoredRenderer' object has no attribute 'vbo_verts_face'

Are there any solutions to fix this?Thansk a lot

@AdityaAS
Copy link

I can see in utils.py there is some more complicated code for setting up a TexturedRenderer which I overlooked before. Actually, I want a ColoredRenderer for my purposes but I will see if I can manipulate your existing code to work for me.

Now, I'm trying the two demos you have identified. The demo_fit_cube.py example runs fine, showing three windows ("Init Cube", "GT object" and "Fitted Object") with the GT & Fitted looking pretty similar.

However, with the teapot demo I obtain lots of scary error messages:

python demo_fit_teapot.py
Initializing GLFW.
FRAMEBUFFER ERR: 36053
FRAMEBUFFER ERR: 36053
glValidateProgram: None
glGetProgramInfoLog
GL_MAX_VERTEX_ATTRIBS: 16
0
Initializing Texture OpenGL.
Traceback (most recent call last):
  File "demo_fit_teapot.py", line 206, in <module>
    ch.minimize({'raw': negLikModel}, bounds=None, method=methods[method], x0=chShapeParams, callback=cb, options=options)
  File "/scratch/bjb56/download/opendr/chumpy/optimization.py", line 462, in minimize
    x1, fX, i = min_ras.minimize(np.concatenate([free_variable.r.ravel() for free_variable in free_variables]), residuals, scalar_jacfunc, args=(obj, obj_scalar, free_variables), on_step=callback, maxnumfuneval=maxiter)
  File "/scratch/bjb56/download/opendr/chumpy/minimize_ras.py", line 83, in minimize
    df0 = grad(X, *args)
  File "/scratch/bjb56/download/opendr/chumpy/optimization.py", line 437, in scalar_jacfunc
    jacs = [obj_scalar.dr_wrt(wrt) for wrt in free_variables]
  File "/scratch/bjb56/download/opendr/chumpy/optimization.py", line 437, in <listcomp>
    jacs = [obj_scalar.dr_wrt(wrt) for wrt in free_variables]
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 711, in dr_wrt
    dr2 = p.dr_wrt(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 711, in dr_wrt
    dr2 = p.dr_wrt(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 711, in dr_wrt
    dr2 = p.dr_wrt(wrt)
  [Previous line repeated 10 more times]
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 714, in dr_wrt
    indirect_dr = self.compute_rop(p, rhs=dr2)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 676, in compute_rop
    dr = self._compute_dr_wrt_sliced(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 266, in _compute_dr_wrt_sliced
    result = self.compute_dr_wrt(wrt)
  File "/scratch/bjb56/download/opendr/chumpy/ch.py", line 2323, in compute_dr_wrt
    idxs_postsum = np.tile(idxs_postsum, tp)
  File "/scratch/bjb56/miniconda3/envs/py3/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 932, in tile
    return c.reshape(shape_out)
TypeError: 'numpy.float64' object cannot be interpreted as an integer

Perhaps this is Python3.6 expecting integer array sizes for the reshape rather than a float64?

@benjiebob were you able to fix the error?

@SelvamArul
Copy link

@AdityaAS I ran into similar issues. This is because the newer versions of numpy does not allow the data type of indices and size arguments to be float. I don't have a permanent fix but in my case, I changed some scipy code that was calling numpy functions with indices and size arguments of float type to use int type.
eg: self._shape = check_shape((M, N))
to
self._shape = check_shape((int(M), int(N)))

This is not a clean solution but serves a quick workaround.

@penincillin
Copy link

I have meet with the same error.

File "/home/rongyu/work/smpl_dp/DCT/py3_opendr/utils/renderer.py", line 228, in render_model
imtmp = simple_renderer(rn, verts, faces, color=color)
File "/home/rongyu/work/smpl_dp/DCT/py3_opendr/utils/renderer.py", line 181, in simple_renderer
return rn.r
File "/home/rongyu/work/smpl_dp/DCT/py3_opendr/utils/chumpy/ch.py", line 555, in r
self._call_on_changed()
File "/home/rongyu/work/smpl_dp/DCT/py3_opendr/utils/chumpy/ch.py", line 550, in _call_on_changed
self.on_changed(self._dirty_vars)
File "/home/rongyu/work/smpl_dp/DCT/py3_opendr/utils/opendr/renderer.py", line 1082, in on_changed
self.vbo_verts_face.set_array(np.array(self.verts_by_face).astype(np.float32))
AttributeError: 'ColoredRenderer' object has no attribute 'vbo_verts_face'

@benjiebob Have you fixed this bug?
Thanks.

@Dawars
Copy link

Dawars commented Dec 18, 2018

Me too, looking into it now

@azelk
Copy link

azelk commented Dec 23, 2018

I've found a solution to this bug.

If you look inside the renderer.py code trying to find out why does renderer.py (1080-1088) use vbo_verts_face inside the class ColoredRenderer(BaseRenderer) if "'ColoredRenderer' object has no attribute 'vbo_verts_face'", you'll find out that it only initializes vbo_verts_face inside initGL() for BaseRenderer class. You'll also get the message "Necessary variables have not been set (frustum, f, v, or vc)." in initGL() if you don't set glMode. Also unlike mesa glfw code uses sharedWin variable before setting it, so you need to set it to None.

So the solution is to set glMode, sharedWin, camera.openglMat do renderer.initGL() prior to any renderer.r calls. So you'll need lines like these prior to renderer.r:

flipXRotation = np.array([[1.0, 0.0, 0.0, 0.0],
            [0.0, -1.0, 0., 0.0],
            [0.0, 0., -1.0, 0.0],
            [0.0, 0.0, 0.0, 1.0]])
renderer.camera.openglMat = flipXRotation #this is from setupcamera in utils
renderer.glMode = 'glfw'
renderer.sharedWin = None
renderer.overdraw = True
renderer.nsamples = 8
renderer.msaa = True  #Without anti-aliasing optimization often does not work.
renderer.initGL()
renderer.debug = False

polmorenoc, please keep this version of opendr compatible with widely used one, especially because it's not that hard to do and it's why we need your version in the first place.

@AdityaAS
Copy link

@azelk thanks for the solution! Although I'm still unable to perform the rendering on a headless server (remote ssh) via OpenGL. Tried looking up on stackoverflow with no luck. With matt loper's opendr version I was able to render easily and produce images in a jupyter notebook on the remote server. I'm unable to do that with this one. Any thoughts on this?

@AdityaAS
Copy link

@azelk could you share a working snippet of the render code that works?
What I've figured out is that one needs to set renderer.glMode = 'mesa' to do headless rendering but I still am getting runtime errors.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/latebind.py in __call__(self, *args, **named)
     40             try:
---> 41                 return self._finalCall( *args, **named )
     42             except (TypeError,AttributeError) as err:

TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-11-18e740a8605b> in <module>()
     99 rn.nsamples = 8
    100 rn.msaa = True  #Without anti-aliasing optimization often does not work.
--> 101 rn.initGL()
    102 rn.debug = False
    103 

~/projects/pytorch_HMR/src/opendr/renderer.py in initGL(self)
    168 
    169         #FBO_f
--> 170         self.fbo = GL.glGenFramebuffers(1)
    171 
    172         GL.glDepthMask(GL.GL_TRUE)

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/latebind.py in __call__(self, *args, **named)
     43                 if self._finalCall is None:
     44                     self._finalCall = self.finalise()
---> 45                 return self._finalCall( *args, **named )
     46 if Curry is None:
     47     class Curry(object):

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/wrapper.py in wrapperCall(*args)
    655                                 cArguments = cArgs
    656                                 try:
--> 657                                     result = wrappedOperation( *cArguments )
    658                                 except ctypes.ArgumentError as err:
    659                                     err.args = err.args + (cArguments,)

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/platform/baseplatform.py in __call__(self, *args, **named)
    399         return None
    400     def __call__( self, *args, **named ):
--> 401         if self.load():
    402             return self( *args, **named )
    403         else:

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/platform/baseplatform.py in load(self)
    388                 argNames = self.argNames,
    389                 extension = self.extension,
--> 390                 error_checker = self.error_checker,
    391             )
    392         except AttributeError as err:

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/platform/baseplatform.py in constructFunction(self, functionName, dll, resultType, argTypes, doc, argNames, extension, deprecated, module, force_extension, error_checker)
    146         """
    147         is_core = (not extension) or extension.split('_')[1] == 'VERSION'
--> 148         if (not is_core) and not self.checkExtension( extension ):
    149             raise AttributeError( """Extension not available""" )
    150         argTypes = [ self.finalArgType( t ) for t in argTypes ]

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/platform/baseplatform.py in checkExtension(self, name)
    259         if context:
    260             from OpenGL import contextdata
--> 261             set = contextdata.getValue( 'extensions', context=context )
    262             if set is None:
    263                 set = {}

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/OpenGL/contextdata.py in getValue(constant, context)
    104     context = getContext( context )
    105     for storage in STORAGES:
--> 106         contextStorage = storage.get( context  )
    107         if contextStorage:
    108             value =  contextStorage.get( constant )

TypeError: unhashable type

@charliememory
Copy link

charliememory commented Jan 18, 2019

I've found a solution to this bug.

If you look inside the renderer.py code trying to find out why does renderer.py (1080-1088) use vbo_verts_face inside the class ColoredRenderer(BaseRenderer) if "'ColoredRenderer' object has no attribute 'vbo_verts_face'", you'll find out that it only initializes vbo_verts_face inside initGL() for BaseRenderer class. You'll also get the message "Necessary variables have not been set (frustum, f, v, or vc)." in initGL() if you don't set glMode. Also unlike mesa glfw code uses sharedWin variable before setting it, so you need to set it to None.

So the solution is to set glMode, sharedWin, camera.openglMat do renderer.initGL() prior to any renderer.r calls. So you'll need lines like these prior to renderer.r:

flipXRotation = np.array([[1.0, 0.0, 0.0, 0.0],
            [0.0, -1.0, 0., 0.0],
            [0.0, 0., -1.0, 0.0],
            [0.0, 0.0, 0.0, 1.0]])
renderer.camera.openglMat = flipXRotation #this is from setupcamera in utils
renderer.glMode = 'glfw'
renderer.sharedWin = None
renderer.overdraw = True
renderer.nsamples = 8
renderer.msaa = True  #Without anti-aliasing optimization often does not work.
renderer.initGL()
renderer.debug = False

polmorenoc, please keep this version of opendr compatible with widely used one, especially because it's not that hard to do and it's why we need your version in the first place.

Nice solution. Thanks. I make it work with your steps and some modification as follows.
change line 479-485 in renderer.py to

    @depends_on('f', 'v')
    def tn(self):
        from opendr.geometry import TriNormals
        return TriNormals(self.v, self.f).r.reshape((-1,3))

        # tn = np.mean(self.vn.r[self.f.ravel()].reshape([-1, 3, 3]), 1)
        # return tn

otherwise there will be error "AttributeError: 'ColoredRenderer' object has no attribute 'vn'".

@dariogentiletti
Copy link

I've found a solution to this bug.

If you look inside the renderer.py code trying to find out why does renderer.py (1080-1088) use vbo_verts_face inside the class ColoredRenderer(BaseRenderer) if "'ColoredRenderer' object has no attribute 'vbo_verts_face'", you'll find out that it only initializes vbo_verts_face inside initGL() for BaseRenderer class. You'll also get the message "Necessary variables have not been set (frustum, f, v, or vc)." in initGL() if you don't set glMode. Also unlike mesa glfw code uses sharedWin variable before setting it, so you need to set it to None.

So the solution is to set glMode, sharedWin, camera.openglMat do renderer.initGL() prior to any renderer.r calls. So you'll need lines like these prior to renderer.r:

flipXRotation = np.array([[1.0, 0.0, 0.0, 0.0],
            [0.0, -1.0, 0., 0.0],
            [0.0, 0., -1.0, 0.0],
            [0.0, 0.0, 0.0, 1.0]])
renderer.camera.openglMat = flipXRotation #this is from setupcamera in utils
renderer.glMode = 'glfw'
renderer.sharedWin = None
renderer.overdraw = True
renderer.nsamples = 8
renderer.msaa = True  #Without anti-aliasing optimization often does not work.
renderer.initGL()
renderer.debug = False

polmorenoc, please keep this version of opendr compatible with widely used one, especially because it's not that hard to do and it's why we need your version in the first place.

I'm struggling with this for days and would like your help: where should I insert your code? I'm confused about renderer.r calls - I don't see any of them. If I try to insert your script at the start of opendr/renderer.py, it will return

NameError: name 'renderer' is not defined

Thank you!

@tszhang97
Copy link

I've found a solution to this bug.
If you look inside the renderer.py code trying to find out why does renderer.py (1080-1088) use vbo_verts_face inside the class ColoredRenderer(BaseRenderer) if "'ColoredRenderer' object has no attribute 'vbo_verts_face'", you'll find out that it only initializes vbo_verts_face inside initGL() for BaseRenderer class. You'll also get the message "Necessary variables have not been set (frustum, f, v, or vc)." in initGL() if you don't set glMode. Also unlike mesa glfw code uses sharedWin variable before setting it, so you need to set it to None.
So the solution is to set glMode, sharedWin, camera.openglMat do renderer.initGL() prior to any renderer.r calls. So you'll need lines like these prior to renderer.r:

flipXRotation = np.array([[1.0, 0.0, 0.0, 0.0],
            [0.0, -1.0, 0., 0.0],
            [0.0, 0., -1.0, 0.0],
            [0.0, 0.0, 0.0, 1.0]])
renderer.camera.openglMat = flipXRotation #this is from setupcamera in utils
renderer.glMode = 'glfw'
renderer.sharedWin = None
renderer.overdraw = True
renderer.nsamples = 8
renderer.msaa = True  #Without anti-aliasing optimization often does not work.
renderer.initGL()
renderer.debug = False

polmorenoc, please keep this version of opendr compatible with widely used one, especially because it's not that hard to do and it's why we need your version in the first place.

I'm struggling with this for days and would like your help: where should I insert your code? I'm confused about renderer.r calls - I don't see any of them. If I try to insert your script at the start of opendr/renderer.py, it will return

NameError: name 'renderer' is not defined

Thank you!

Same question, have you figured out?

@SergeiGorbatiuk
Copy link

@dariogentiletti , @willie1997 , I suppose this renderer is considered to be the one in your code, not in the opendr's one. In your files the name could be different. Although, I've done this, and still, that did not work out, seems like I am missing something:(

@erezposner
Copy link

I've tried the above solution but now It crashes in draw_color_image function in opendr\renderer.py
what do you think?

Initializing GLFW.
FRAMEBUFFER ERR: 36053
FRAMEBUFFER ERR: 36053
glValidateProgram: None
glGetProgramInfoLog 
GL_MAX_VERTEX_ATTRIBS: 16
0
--Return--
> lib\opendr\renderer.py(1156)draw_color_image()->None
-> import pdb; pdb.set_trace()
(Pdb) 

@fengpingxuan
Copy link

I've tried the above solution but now It crashes in draw_color_image function in opendr\renderer.py
what do you think?

Initializing GLFW.
FRAMEBUFFER ERR: 36053
FRAMEBUFFER ERR: 36053
glValidateProgram: None
glGetProgramInfoLog 
GL_MAX_VERTEX_ATTRIBS: 16
0
--Return--
> lib\opendr\renderer.py(1156)draw_color_image()->None
-> import pdb; pdb.set_trace()
(Pdb) 

@erezposner
Hi erezposner, I have encountered the same problem. So I was wondering have you already found a solution or not?

@WinstonDeng
Copy link

Same question I have on Win10. Anyone can fix it?

@iegorval
Copy link

I've found a solution to this bug.

If you look inside the renderer.py code trying to find out why does renderer.py (1080-1088) use vbo_verts_face inside the class ColoredRenderer(BaseRenderer) if "'ColoredRenderer' object has no attribute 'vbo_verts_face'", you'll find out that it only initializes vbo_verts_face inside initGL() for BaseRenderer class. You'll also get the message "Necessary variables have not been set (frustum, f, v, or vc)." in initGL() if you don't set glMode. Also unlike mesa glfw code uses sharedWin variable before setting it, so you need to set it to None.

So the solution is to set glMode, sharedWin, camera.openglMat do renderer.initGL() prior to any renderer.r calls. So you'll need lines like these prior to renderer.r:

flipXRotation = np.array([[1.0, 0.0, 0.0, 0.0],
            [0.0, -1.0, 0., 0.0],
            [0.0, 0., -1.0, 0.0],
            [0.0, 0.0, 0.0, 1.0]])
renderer.camera.openglMat = flipXRotation #this is from setupcamera in utils
renderer.glMode = 'glfw'
renderer.sharedWin = None
renderer.overdraw = True
renderer.nsamples = 8
renderer.msaa = True  #Without anti-aliasing optimization often does not work.
renderer.initGL()
renderer.debug = False

polmorenoc, please keep this version of opendr compatible with widely used one, especially because it's not that hard to do and it's why we need your version in the first place.

Hello. I have tried your solution, but it did not solve the issue.

Anyone else here who was able to fix it?

P.S. The demo code is failing for me as well, but with completely other error (KeyError: 'Zshift' for chDistMat = geometry.Translate(x=0, y=cameraParams['Zshift'], z=0)).

@LingSmart
Copy link

@charliememory I want to know this code need what files where line?
flipXRotation = np.array([[1.0, 0.0, 0.0, 0.0],
[0.0, -1.0, 0., 0.0],
[0.0, 0., -1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])
renderer.camera.openglMat = flipXRotation #this is from setupcamera in utils
renderer.glMode = 'glfw'
renderer.sharedWin = None
renderer.overdraw = True
renderer.nsamples = 8
renderer.msaa = True #Without anti-aliasing optimization often does not work.
renderer.initGL()
renderer.debug = False

@Guocode
Copy link

Guocode commented Nov 18, 2021

I've tried the above solution but now It crashes in draw_color_image function in opendr\renderer.py what do you think?

Initializing GLFW.
FRAMEBUFFER ERR: 36053
FRAMEBUFFER ERR: 36053
glValidateProgram: None
glGetProgramInfoLog 
GL_MAX_VERTEX_ATTRIBS: 16
0
--Return--
> lib\opendr\renderer.py(1156)draw_color_image()->None
-> import pdb; pdb.set_trace()
(Pdb) 

The same problem

@GabbyYam
Copy link

GabbyYam commented Dec 16, 2021

I've tried the above solution but now It crashes in draw_color_image function in opendr\renderer.py what do you think?

Initializing GLFW.
FRAMEBUFFER ERR: 36053
FRAMEBUFFER ERR: 36053
glValidateProgram: None
glGetProgramInfoLog 
GL_MAX_VERTEX_ATTRIBS: 16
0
--Return--
> lib\opendr\renderer.py(1156)draw_color_image()->None
-> import pdb; pdb.set_trace()
(Pdb) 

Totally the same problem, i wonder if you have found the solution for it.

@sitifukujin
Copy link

I found 1 clue.
Just in case, I tried to remove try & except blocks for checking except message.
Except message said:

result = np.flipud(np.frombuffer(GL.glReadPixels( 0,0, self.frustum['width'], self.frustum['height'], GL.GL_RGB, GL.GL_UNSIGNED_BYTE), np.uint8).reshape(self.frustum['height'],self.frustum['height'],3).astype(np.float64))/255.0
ValueError: cannot reshape array of size 921600 into shape (480,480,3)

480 x 480 x 3 is 691,200 not equal 921600 byte

That might be 2 candidate causes.
1 GL.glReadPixels reutrn 4 channels (RGBA)
480 x 480 x 4 = 921,600
2. self.frustum['width'] return wrong value
correct is 640
640 x 480 x 3 =921,600

@sitifukujin
Copy link

It is clearly issue on opendr:v 0.73
reshape(self.frustum['height'],self.frustum['height'],3) => eshape(self.frustum['width'],self.frustum['height'],3)

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