blur over area.

hello.

I´m doing a project in which I need to blur a specific area over a live video stream. Right now I have black circles moving over the video and I have no idea how to go about transforming those circles into blurs instead. It´s sort of a circular mask that moves over the video, blurring only that which is beneath it.

I apologize if this seems a bit vague, but coming from the world of video, that´s the best way I can explain it. Any help would be very welcome.

Thanks,
Adrian.

I have never done this sort of masking before, but it seems like a perfect candidate for the OpenGL stencil buffer. The process would be something like this for each frame:

  • Clear the colour, depth and stencil buffers
  • Grab your next video frame to a texture
  • Blur your video frame and load it to a texture
  • Render your circles to the stencil buffer
  • Render a screen sized quad (ofRect) with your original video frame as texture.
  • Render a screen sized quad with your blurred video frame, but using the stencil buffer to limit it to the circle areas.

Here are some references for this technique and general stencil buffer usage:

Some notes:

  • To access the stencil buffer you’ll need to tweak the ‘libs/openFrameworks/app/ofAppRunner.cpp’ file and change
  
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA );  

to

  
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL | GLUT_ALPHA );   

  • If you don’t want to use the stencil buffer, you can also try drawing your masks using the blurred image as a texture, but you’d need to draw their vertices directly and convert each vertex screen coordinate to the [0,1] interval to use as a texture coordinate.

Hope this helps,
P.

see if this thread helps you:
http://www.openframeworks.cc/forum/view-…-sc&start=0
and here is an example of that:
http://forum.openframeworks.cc/t/motion-detection-±fbo-ping-pong-for-huge-real-time-blur/888/0

Hope that helps some.

ding

Pangelo: Using the stencil buffer method, is it possible to have multiple blurred circles over the initial image? I tried this method once with pure data / GEM, but could only draw one circle. However, this could have been a result of a very limited openGL programming knowledge on my part…

Interesting links, I’ll look into them, maybe I’ll understand something this time around.

Ding: That FBO code seems useful, i’ll dive into it.

Thankyou both.

[quote author=“adrian”]Pangelo: Using the stencil buffer method, is it possible to have multiple blurred circles over the initial image? I tried this method once with pure data / GEM, but could only draw one circle. However, this could have been a result of a very limited openGL programming knowledge on my part…
[/quote]

It should handle multiple circles or any other arbitrary shape without any problem. Whatever you render into the stencil buffer can be used as the stencil mask in later rendering steps.

P.