Hi,
i'm trying to do masks on videos, using for this videos in grayscale, with GLGraphics + GSVideo + processing 1.5.1, but it doesn't run as expected. I can't see what is wrong... Any ideas ?
Here is my code:
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import codeanticode.gsvideo.*;
- GSMovie movie, movie2, movie3;
- GLGraphicsOffScreen offscreen;
- GLTextureFilter maskFilter;
- GLTexture maskedTex;
- GLTexture imgMask;
- GLTexture imgTex, tex, tex2;
- void setup() {
- size(1280, 720, GLConstants.GLGRAPHICS);
- movie = new GSMovie(this, "/Volumes/SSD1/video_glitch/17_1_2012_at_16_56_20_GLITCH.avi");
- movie2 = new GSMovie(this, "/Volumes/SSD1/video_raw/mask.avi");
- movie3 = new GSMovie(this, "/Volumes/SSD1/video_raw/17_1_2012_at_17_1_3_PASS.avi");
- frameRate (24);
- imgMask = new GLTexture(this, 1280, 720);
- tex = new GLTexture(this, 1280, 720);
- tex2 = new GLTexture(this, 1280, 720);
- maskedTex = new GLTexture(this, 1280, 720);
- imgTex = new GLTexture(this, 1280, 720);
- maskFilter = new GLTextureFilter(this, "Mask.xml");
- offscreen = new GLGraphicsOffScreen(this, 1280, 720);
- movie.setPixelDest(tex);
- movie2.setPixelDest(imgTex);
- movie3.setPixelDest(tex2);
- movie.loop();
- movie2.loop();
- movie3.loop();
- }
- void movieEvent(GSMovie m) {
- if (m == movie) {
- movie.read();
- }
- if (m == movie2) {
- movie2.read();
- }
- if (m == movie3) {
- movie3.read();
- }
- }
- void draw () {
- background(0);
- offscreen.beginDraw();
- offscreen.clear(0, 0);
- offscreen.fill(0, 255);
- if (imgTex.putPixelsIntoTexture()) {
- offscreen.image(imgTex, 0, 0, 1280, 720);
- }
- offscreen.endDraw();
- imgMask = offscreen.getTexture();
- maskFilter.setParameterValue("mask_factor", 0.0f);
- maskFilter.apply(new GLTexture[] { tex, imgMask} , maskedTex);
- // video 1
- if (tex2.putPixelsIntoTexture()) {
- image(tex2, 0, 0, 1280, 720);
- }
- // video 2 + mask
- if (maskedTex.putPixelsIntoTexture()) {
- image(maskedTex, 0, 0, 1280, 720);
- }
- }
1