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

//ofClear(0, 0, 0, 0);
shader.setUniformTexture("tex0", videoGrabber.getTextureReference(), videoGrabber.getTextureID());
shader.setUniform1f("time", ofGetElapsedTimef());
shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight());
glReadPixels(0,0, omxCameraSettings.width, omxCameraSettings.height, GL_RGBA, GL_UNSIGNED_BYTE, videoPixels);	

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();


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

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");


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?


@leefense that is all in this example

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.