0

I have code which is something like this:

osgViewer::Viewer viewer;
viewer.setSceneData(scene);
viewer.setCameraManipulator( tracker.get() );
viewer.setUpViewInWindow(10,10,1024,768,0);
viewer.realize();

Now, this viewer object gives me a view of a scene which contains a vehicle model, terrain etc. I would like to get an RGB image out of this viewer, irrespective of how the data has been written into the scene.

Essentially, I want an RGB image from the viewer with no previous information as to what data is written into the scene. If the viewer shows something in a 1024*768 window, I want it as an RGB image.

Bart
  • 19,692
  • 7
  • 68
  • 77
Balaji Sridharan
  • 339
  • 1
  • 5
  • 7

1 Answers1

1

If I understand you correctly, then the osg::ScreenCaptureHandler should fit your bill. It is part of the ViewerEventHandlers header located in include/osgViewer.

It is a simple event handler which, upon a key press, captures and stores an image of the current view. You can either use this or adapt it to your liking.

Bart
  • 19,692
  • 7
  • 68
  • 77
  • Hi, actually I dont want to store it as a file. I want to use it for processing, without a keystroke. So the idea is as I get the viewer output, I would need to do some image processing like keypoint generation etc on the viewer output as an image (RGB format). So, I cannot have a keystroke wait, I can only have a fps capture into a frame buffer – Balaji Sridharan Apr 17 '12 at 21:44
  • 1
    Then adapt it to your liking. You can use whatever event to trigger it with some modification. And you don't need to necessarily store the resulting osg::Image in a file. – Bart Apr 17 '12 at 21:46