How do i copy an ofFbo object into an ofImage object?

fbo.begin();
//ofClear(0, 0, 0, 0);
shader.begin();
shader.setUniformTexture("tex0", videoGrabber.getTextureReference(), videoGrabber.getTextureID());
shader.setUniform1f("time", ofGetElapsedTimef());
shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight());
videoGrabber.draw();
shader.end();
if(doPixels)
{
glReadPixels(0,0, omxCameraSettings.width, omxCameraSettings.height, GL_RGBA, GL_UNSIGNED_BYTE, videoPixels);	
}	
fbo.end();


ofImage myImage;


// Put line of code here to copy FBO into myImage







// This returns a pointer to the pixel array. We have named it PixelPointer

PixelType * PixelPointer = myImage.getPixels();

fbo.allocate(omxCameraSettings.width,omxCameraSettings.height,GL_RGBA);


// Replaced what was previously here with PixelPointer
fbo.readToPixels(PixelPointer);
        myImage.saveImage('omg', OF_IMAGE_QUALITY_MEDIUM);

if(doPixels)
{
videoTexture.loadData(videoPixels, omxCameraSettings.width, omxCameraSettings.height, GL_RGBA);	
}

}

We are using a Raspberry Pi camera and applying a shader program to it (source code can be found on github if you search ofxRPiCameraVideoGrabber). The code above is taken from the shaderApp.cpp file. We would like to save an image from the fbo. Ultimately we would like to send the image data from the fbo to our LED screen that is connected via a USB port on the Raspberry Pi (/dev/ttyUSB0). If someone could either help us save the image or better yet send the image data directly to the screen we would be very thankful. We know that sending the image to the screen involves the same getPixelsRef() function to iterate through the pixels of the image and send them to the screen.

with the unmodified code you should able to use

ofSaveImage(videoPixels, "omg.png");

or

ofImage myImage;
myImage.setFromPixels(videoPixels, omxCameraSettings.width, omxCameraSettings.height, OF_IMAGE_COLOR_ALPHA);
myImage.saveImage('omg', OF_IMAGE_QUALITY_MEDIUM);

This post grabbed my attention because I’m also working with the Raspberry Pi camera to save a still image from video and show it onscreen. I don’t need to draw the video itself to the screen. I’m very new to OF and FBOs, etc. and am trying to cram. What’s the simplest way to do this with the RPi cam?

My working desktop version relies on the line:

newGrab.setFromPixels(vidGrabber.getPixels(), camWidth, camHeight, OF_IMAGE_COLOR);

But I see that .getPixels() doesn’t exist yet. Do I need to use an FBO at all?

Thanks.

@leefense that is all in this example

https://github.com/jvcleave/ofxRPiCameraVideoGrabber/blob/master/example-pixels/src/pixelsApp.cpp

Thanks Jason,

That is actually the example I’m trying to work off of, but I’m just not getting it to work. My saved image does not seem to contain any data. I’ll try again a bit later on.

Thanks for putting the addon together. It’s great you worked on it and apologies that I’m a little new at this.