FBO turns circles to ellipses after rendering via setFromPixels for some sizes

Hello. I’m getting some curious behavior I haven’t found a workaround for. It may be a bug, or it may be my naivety regarding compatibility across ofImageTypes, ofPixelFormats, and ways to allocate ofFbo objects. I’ve attached a small but complete oF app to demonstrate the issue.

High level, I want to stitch images from two cameras together and pass the combined image into openCV for blob detection. The following code shows a test function I have towards this end. The function seems fine until you uncomment the line “//allocX = 522;” For several values of allocX and allocY, circles become diagonal ellipses.

I can get around this issue by changing “fbo.allocate(allocX, allocY, GL_RGB);” to “fbo.allocate(allocX, allocY);”. However, this breaks the function, and colorCVImage is not correctly set.

Thanks for any assistance. Also, if you know of a great resource to understand the nuances of ofImageTypes, ofPixelFormats, and ways to allocate ofFbo objects, I’d be grateful for the link.

void testApp::draw(){  
    ofFbo fbo;  
    ofImage image;  
    ofxCvGrayscaleImage grayCVImage;  
    ofxCvColorImage colorCVImage;  
    ofPixels pixels;  
    int allocX = 500;  
    int allocY = 512;  
    //allocX = 522;  
    fbo.allocate(allocX, allocY, GL_RGB);  
    pixels.allocate(allocX, allocY, OF_PIXELS_RGB);  
    grayCVImage.allocate(allocX, allocY);  
    colorCVImage.allocate(allocX, allocY);  
    ofEllipse(100, 100, 100, 100);  
    grayCVImage = colorCVImage;  
    //fbo.draw(0, 0);  
    image.draw(0, 0);  
    //colorImage.draw(0, 0);  
    //grayImage.draw(0, 0);  

I had the same issue when I was trying to get text drawn into an fbo into greyscale opencv images. I wanted to have each image fitted to the text and it was slanting weirdly when it was dynamically figuring out the size of the fbo from the size of the text. I tried out different formats for both the ofFbo and the ofPixels to no avail.

I looks like the problem is when casting from the fbo to pixels and it only comes up when you have specific usually odd dimension 551w X 231h produces the problem where as 1000 x 1000 does not.
My work around was to set it to some a good rounded off dimension and then crop the pixels before adding them to opencv image like so. In my .h:

    ofxCvColorImage original;
    ofxCvGrayscaleImage toBlur;
    ofTrueTypeFont font;
    ofFbo drawTextin;
    ofPixels tempPix;
    int padding; 

In my .cpp:

void fadeTextIn::setup(string text, int millis, int size){
    font.loadFont("PT.ttf", size);
    ofRectangle box = font.getStringBoundingBox(text, 0, 0);
    padding = 20;
    int width = box.width+padding;
    int height = box.height+padding;
    drawTextin.allocate(1000, 1000, GL_RGB);
    tempPix.allocate(1000, 1000,OF_PIXELS_RGB);
    original.allocate(width, height);
    toBlur.allocate(width, height);
    font.drawString(text,0+ padding/2,box.height+ padding/2);

    tempPix.crop(0, 0, width, height);
    toBlur = original;