[Robotics] Depth information from a camera

Benoit Bolsee benoit.bolsee at online.be
Tue Jan 11 18:52:43 CET 2011


Hi Gilberto,

VideoTexture does not use OpenGL buffer object to make the render, it
uses directly the frame buffer so it should be sufficient to do this
after the render to get the depth buffer:

bgl.glReadPixels(0,0,width,height,bgl.GL_DEPTH_COMPONENT, bgl.GL_FLOAT,
buffer)

Where buffer is an object created with 
buffer = bgl.Buffer(bgl.GL_FLOAT,width*height)

The attribute error you get is because the correct method name is
bgl.Buffer() and not bgl.buffer() and I said earlier. Sorry for the
confusion.


> -----Original Message-----
> From: robotics-bounces at blender.org 
> [mailto:robotics-bounces at blender.org] On Behalf Of Gilberto Echeverria
> Sent: mardi 11 janvier 2011 17:01
> To: Blender and Robotics
> Subject: Re: [Robotics] Depth information from a camera
> 
> 
> Hi Benoit,
> 
> I'm trying to get the zbuffer using the OpenGL functions, but I'm 
> running into a couple of problems.
> First, I did some experiments and I can get the zbuffer using 
> bgl.glReadPixels, but specifying a section of the screen to read. How 
> can I change this to use the image from VideoTexture instead? 
> I thought 
> of using the glBindBuffer method, but that doesn't seem to be 
> implemented in bgl.
> 
> I also have the same problem with bgl.buffer(), where I get an error 
> saying that there is no attribute called 'buffer'. It seems 
> to be caused 
> by lack of support for some OpenGL functions within bgl. At 
> least they 
> don't appear in the documentation of Blender 2.49, and for 
> Blender 2.5 I 
> can't even find the bgl docs.
> 
> Thanks
> 
> Gilberto
> 
> On 01/11/2011 12:24 PM, Benoit Bolsee wrote:
> > Hi Gilberto,
> >
> > The BGL module is still there in Blender 2.5. It is now 
> called 'bgl' 
> > so you have to "import bgl" at the start of the module. The 
> bgl module 
> > is a wrapper around OpenGL, so you can call all OpenGL 
> functions with 
> > it. To get the Zbuffer, you will need to run a custom render from a 
> > camera using VideoTexture and then you can retrieve the 
> Zbuffer using 
> > the appropriate OpenGL function.
> >
> > Void pointer parameters in OpenGL map to buffer objects that you 
> > create with bgl.buffer() method. Unfortunately, the buffer objects 
> > returned by bgl.buffer() do not support the buffer protocol, which 
> > means that you cannot export the internal memory buffer to 
> a C module. 
> > You can however access individual elements of the buffer 
> from python 
> > using sequence methods. Adding support for the buffer protocol to 
> > bgl.buffer object type shouldn't be difficult though.
> >
> > Hope this helps,
> > Benoit
> >
> >    
> >> -----Original Message-----
> >> From: robotics-bounces at blender.org 
> >> [mailto:robotics-bounces at blender.org] On Behalf Of Gilberto 
> >> Echeverria
> >> Sent: mardi 11 janvier 2011 10:07
> >> To: Blender and Robotics
> >> Subject: [Robotics] Depth information from a camera
> >>
> >>
> >> Hello everyone,
> >>
> >> For the MORSE simulator, we are trying to recreate laser range 
> >> scanners, that provide depth information from a sensor on 
> a robot. We 
> >> are currently doing this using ray tracing, but if we want to 
> >> simulate sensor with a lot of lasers, I fear ray tracing 
> all of them
> >> will be too
> >> slow.
> >> So my question is: Is there a way to get the depth information of a
> >> scene in a faster way? We need something that can be used
> >> from the Game
> >> Engine of Blender 2.5
> >> One possible method is to get the z-buffer from a camera. 
> Apparently
> >> this was possible in Blender 2.49, using the BGL modules, but
> >> that seems
> >> to have disappeared from Blender 2.5.
> >>
> >> Any ideas will be greatly appreciated.
> >> Cheers
> >>
> >> Gilberto
> >> _______________________________________________
> >> Robotics mailing list
> >> Robotics at blender.org 
> http://lists.blender.org/mailman/listinfo/robo> >  
> >> tics
> >>
> >>      
> >
> > _______________________________________________
> > Robotics mailing list
> > Robotics at blender.org 
> > http://lists.blender.org/mailman/listinfo/robotics
> >    
> 
> _______________________________________________
> Robotics mailing list
> Robotics at blender.org 
> http://lists.blender.org/mailman/listinfo/robo> tics
> 




More information about the Robotics mailing list