Quickest ofFbo to greyscale image

#1

Hello,

I am doing some drawing in an ofFbo which I then wish to translate into a ofxCvGrayscaleImage for tracing.

The following works fine, but when I start to work on very large ofFbos (3,000 pixels across, etc) it starts to stall (just takes a long time and so hangs for a couple of seconds).

Does anyone have any suggestions on how I can shorten how long the below code will take? Or, is there a more efficient way of making the translation?

//start and clear ofFbo object
    drawTo.begin();
    ofClear(ofColor(255,0,255));
    ofSetColor(255);
//do drawing here with black lines etc
//.....
    drawTo.end();
    
// move to pixels object
    ofPixels tmpPixels;
    tmpPixels.clear();
    drawTo.readToPixels(tmpPixels);
    
//move to rgb image object
    colorImg.clear();
    colorImg.setFromPixels(tmpPixels);
    tmpPixels.clear();
    
//move to ofxCvGrayscaleImage object
    grayImage = colorImg;
    grayImage.threshold(170);
#2

Not sure if it’s the quickest, but I’ve found using ofxCv instead of ofxOpenCv and using methods like ofxCv::convertColor(input, output, CV_RGB2GRAY); is quite fast for most applications. Additionally, depending on what you’re trying to do with CV operations, ofxCv might be faster at most things as well.

#3

I’m mainly just interested in how to speed up the translation from ofFbo to an image ready for CV functions

At present with larger images, the move to pixels stage takes circa 300ms and the subsequent move from pixels object to image object takes 500ms, so it is quite a slow down moment.

S