Is it possible to get the value of every pixel?

I am really a beginner and my question is:

In openGL, is it possible to get the data of every pixel?
I want to get what every pixel means in the image (e,g, a tree, a house or sky) and the RGB value of that pixel.
If there is such a way to do this, how?

Thanks very much.

glReadPixels() can be used to read the contents of a framebuffer.

As mentioned, glReadPixels will do it.

However, it may help us to help you better if you talked a little about why you want to do this. While you can just issue a glReadPixels call and get the pixel data, it’s not always the ideal solution for all problems, and depending on the problem you’re trying to solve, there are probably better ways.

[QUOTE=mhagain;1280435]As mentioned, glReadPixels will do it.

However, it may help us to help you better if you talked a little about why you want to do this. While you can just issue a glReadPixels call and get the pixel data, it’s not always the ideal solution for all problems, and depending on the problem you’re trying to solve, there are probably better ways.[/QUOTE]

Thanks for your help.
I am trying to generate image data to build an object recognition system using machine learning algorithms, so I need to know what every pixel means.
It might be not difficult to get the RGB values, but I want to know the meaning of pixels.
For example, which pixel can be labeled as cars, and which pixel can be labeled as roads.

[QUOTE=wcx730916119;1280437]Thanks for your help.
I am trying to generate image data to build an object recognition system using machine learning algorithms, so I need to know what every pixel means.
It might be not difficult to get the RGB values, but I want to know the meaning of pixels.
For example, which pixel can be labeled as cars, and which pixel can be labeled as roads.[/QUOTE]

OpenGL is a rendering system, not an image recognition system. It’s job is to draw triangles, not to understand the “meaning” of those triangles.

If you know what a particular triangle “means”, you can associate that data with that triangle and write it to a buffer in your framebuffer. But OpenGL itself won’t have any particular “meaning” attached to anything it renders.

[QUOTE=Alfonse Reinheart;1280439]OpenGL is a rendering system, not an image recognition system. It’s job is to draw triangles, not to understand the “meaning” of those triangles.

If you know what a particular triangle “means”, you can associate that data with that triangle and write it to a buffer in your framebuffer. But OpenGL itself won’t have any particular “meaning” attached to anything it renders.[/QUOTE]

For example, when OpenGL is rendering a blue sky with white clouds, how does it know that which triangle should be white? Is there anything telling OpenGL that some triangles should be covered by white but not the background color blue?
If I really need to know the meaning of those rendered triangles, what should I learn?

Thanks.

For example, when OpenGL is rendering a blue sky with white clouds, how does it know that which triangle should be white? Is there anything telling OpenGL that some triangles should be covered by white but not the background color blue?

Yes: you.

You tell OpenGL what to render. You tell OpenGL which triangles are white. You tell OpenGL what color a triangle is or what texture gets applied to it.

If I really need to know the meaning of those rendered triangles, what should I learn?

It’s not clear what you mean by that. If you’re rendering something, then by definition, you must know what you’re drawing. Just like if you’re making a sketch with a pencil, you have to know what you’re sketching.

It makes no more sense to ask OpenGL what the meaning of something is than to ask your pencil what the meaning of a sketch is.