Getting pixels from a 3D scene using an fbo

I have an fbo wrapping my camera in my 3d scene and use readToPixels to get the fbo’s pixels.

    //enemy camera draw
    ofPixels pixels;
    ofSaveImage(pixels, "save.png", OF_IMAGE_QUALITY_BEST);

however when I call ofSaveImage I get the error
ofImage: saveImage(): couldn’t save ‘’‘save.png’’ pixels are not allocated

This makes me think the fbo isn’t being given what the camera is seeing properly, but i’m not sure.
Is there perhaps a better way I could be manipulating the pixels object?

Thanks for any help.

EDIT: This is all in the draw() function of my ofApp if that has any relevance.

Hi, I remember seeing this same question not long ago but cant find it (did not search much though).

did you allocate the fbo?

I did try allocating it, but i’m not sure what width and height I should give it. The camera it’s wrapping is one of many cameras in my app. This specific camera is using a viewport of 100x100 pixels. Should I just pass fbo.allocate(100,100) ?

it depends on how many pixels you want to save, but yes, if you want to save a specific camera allocate the image to the size of that cameras viewport