Re: [osg-users] Getting RGB-values out of frame

2011-07-15 Thread J.P. Delport

Hi,

On 15/07/2011 11:14, Diana Kittelmann wrote:

Hi,

I'm implementing a lidar scanner simulator ins osg and got kind oft
stucked.

I'm loading a world from file as my scene and let my sensor fly
through the world, everything works fine. From a 3d Party I got a
Vertex- and Fragment Shader to calculate the actual view of the lidar
scanner.

In other words what I get right now is an image with colored Pixel
-the color of a pixel tells me the distance between the sensor and
point of object hit by the laser ray -the image doesent have any
depth informations -when I get the distance-values I have to send
them vie ethernet (not relevant here cause already implemennted) so
waht I need as result ist a vector of long-values including the
length of the laser rays

And now I don't know how I can get the distance or better I don't
know how I can get the RGB-Values of the Pixel in the image.  (notice
that image doesen't mean I get an Image-object but the actual picture
shown in the View)

I tried to realize it via osg::Image:

Code:

osg::Image* buffer = new osg::Image;

...

void getBuffer() { buffer->readPixels(0,0,200,200,GL_RGB,GL_FLOAT);
float* bufferRaw; bufferRaw = (float*) buffer->data();

... }



you have the right idea with readpixels, but you must make sure that the 
readpixels is happening after the camera has drawn so that the context 
where the data lives is still active. Stick it into a drawcallback. See 
the osgscreencapture example for inspiration. It also shows the other 
methods of reading data back to the CPU.







With this I just get a wrong value (something undefined like
-4.3160208e+008)

I have no idea if I am on the right way or totally wrong. I'm just
new to OSG. So can anyone give me a tip what I should try or for what
to search ...

I'm using OSG 2.8.1, have one View and one Camera (the one the view
got by default) and I'm using a kind of complex class hierarchie (ie:
I have a cameraView-clas which realizes the view, and I have a
lidarView-class which realizes the lidar stuff and calls the shaders
and which inherits from the cameraView).

Thank you!

Cheers, Diana

PS: The worst ist that it hast to be very fast. I have to write a
real-time lidar scanner simulation.[/code]


You'll probably be limited by the amount of data you can read back from 
the GPU to CPU. You'll have to test this on your setup and you can work 
out the required rate you'll need.


jp



-- Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41378#41378





___ osg-users mailing
list osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Getting RGB-values out of frame

2011-07-15 Thread Diana Kittelmann
Hi,

I'm implementing a lidar scanner simulator ins osg and got kind oft stucked.

I'm loading a world from file as my scene and let my sensor fly through the 
world, everything works fine. From a 3d Party I got a Vertex- and Fragment 
Shader to calculate the actual view of the lidar scanner.

In other words what I get right now is an image with colored Pixel
-the color of a pixel tells me the distance between the sensor and point of 
object hit by the laser ray
-the image doesent have any depth informations
-when I get the distance-values I have to send them vie ethernet (not relevant 
here cause already implemennted) so waht I need as result ist a vector of 
long-values including the length of the laser rays

And now I don't know how I can get the distance or better I don't know how I 
can get the RGB-Values of the Pixel in the image.  (notice that image doesen't 
mean I get an Image-object but the actual picture shown in the View)

I tried to realize it via osg::Image:

Code:

osg::Image* buffer = new osg::Image;

...

void getBuffer()
{
buffer->readPixels(0,0,200,200,GL_RGB,GL_FLOAT);
float* bufferRaw;
bufferRaw = (float*) buffer->data();

...
}





With this I just get a wrong value (something undefined like -4.3160208e+008)

I have no idea if I am on the right way or totally wrong. I'm just new to OSG. 
So can anyone give me a tip what I should try or for what to search ...

I'm using OSG 2.8.1, have one View and one Camera (the one the view got by 
default) and I'm using a kind of complex class hierarchie (ie: I have a 
cameraView-clas which realizes the view, and I have a lidarView-class which 
realizes the lidar stuff and calls the shaders and which inherits from the 
cameraView). 

Thank you!

Cheers,
Diana

PS: 
The worst ist that it hast to be very fast. I have to write a real-time lidar 
scanner simulation.[/code]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41378#41378





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org