@petermc wrote:
Hi OFers
I'm trying to use the blur function in ofxCv so that I can draw circles then blur them. The only way I have found that works its:
1) draw the circles to an fbo
2) transfer the fbo to an image
3) use the blur function on the imageinclude "ofApp.h"
void ofApp::setup() {
ofSetVerticalSync(true);
ofEnableSmoothing();back1.set(160); back2.set(80); fbo.allocate(ofGetWidth(), ofGetHeight()); pixels.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_GRAYSCALE); fbo.begin(); ofClear(255); ofSetColor(255); ofSetCircleResolution(64); ofNoFill(); for(int i = 0; i < 200; i++){ ofDrawCircle(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()), ofRandom(10, 40)); } fbo.end(); fbo.readToPixels(pixels); image.setFromPixels(pixels); ofxCv::GaussianBlur(image, 30); image.update();
}
void ofApp::update() {
}void ofApp::draw() {
ofBackgroundGradient(back1, back2, OF_GRADIENT_CIRCULAR);
ofSetColor(255, 170);
image.draw(0, 0);
ofSetColor(255, 30);
fbo.draw(0, 0);}
ok now if I want to keep the thing efficient I might transfer the blurred image back to the fbo and draw as required (note that I'm not doing this in the code above). This seems a bit clunky. Should I draw my circles directly into an image (I've been searching from many hours to work out how to do that and I still don't know), blur them and then transfer to an fbo? OR is there a way to use ofxCv on an fbo?
So the specific answers I would like relate to:
1) can you use ofxCv directly with an fbo and if so how?
2) can you draw shapes into a ofImage and if so how?
3) is there a better way to blur drawn images that I haven't considered?thanks in advance
Peter Mc
Posts: 1
Participants: 1