We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Quicktime movies with alpha channel
Page Index Toggle Pages: 1
Quicktime movies with alpha channel (Read 968 times)
Quicktime movies with alpha channel
Jun 6th, 2007, 10:28am
 
Hello, I'm making a kaleidoscope with Processing, which uses quicktime movies, as well as images, as sources. With Java2D, I can transform and display the clips with their alpha channel (they are small clips with Animation codec and RGB+alpha infomation) but if I use P3D, which works a bit slower but better in terms of image quality, I can't get the alpha channel to work. I can't use the OpenGL renderer since I'm using a PGraphics object in the script to buffer images before displaying them with the kaleidoscopic effect (and I also use "createGraphics"), and I know this is not compatible with OpenGL.
Does anybody know a workaround for this, or there's no other way than using Java2D, which looks worst than P3D?

Thanks for your support!
f
Re: Quicktime movies with alpha channel
Reply #1 - Jun 6th, 2007, 3:13pm
 
the quicktime movie itself has an alpha channel?
Re: Quicktime movies with alpha channel
Reply #2 - Jun 7th, 2007, 10:05am
 
Yes it does.

Sorry I made two posts for different aspects of my project and in the end they converged on topics:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1180829325
I'm very sorry about this!

I somehow solved the problem anyway: I created separate clips from the original clips'alpha converted as luma, loaded them and applied to the original clips as mask. Well, it worked and now I see right in P3D. The strange thing is: even if I shouldn't need anymore an alpha channel in the original clip (because I apply it expressely through the masking), so they could be RGB clip + mask clip, I saw that it doesn't work this way, the image disappears and sometime flickers in. It works only with ARGB clip + mask clip.
Seems strange to me. Anyway having it to work directly with the embedded alpha in the ARGB clip would be faster for sure.
OpenGl shoud be even faster and hopefully have a nice quality (I think I could set up antialiasing and other settings from my videocard setup utility) but I have to find a decent workaround for the PGraphics object

Well, this is the code by now:


import processing.video.*;

//buffer for slicing and then masking
PGraphics pg;

//2 input images
PImage slice1;
PImage slice2;

// input movies + masks
Movie myMovie1;
Movie myMovie2;
Movie myMovie1mask;
Movie myMovie2mask;

//images for creating mask and kaleidoscope
PImage maskImg; // is the mask for the slice (30° of circle) that will be replicated
PImage smallbufferImg;
int outw, outh; //dimensions of the output/scene
int diagfactor; // number used to calculate buffer height
int numImg;

//mouse position from center
int mouseXc, mouseYc;


void setup(){
 outw=800;
 outh=600;
 size(outw,outh);
 background(0);

 // create graphic buffer
 pg = createGraphics(outw,outw, P3D);

 slice1=loadImage("img1.png");
 slice2=loadImage("img2.png");
 blackImg=loadImage("800x600black.jpg");

 diagfactor=int(sqrt((outh*outh)+(outw*outw))/2);
 maskImg = loadImage(str(outw/2)+"x"+str(diagfactor)+"mask.jpg");

 myMovie1 = new Movie(this, "plant3.mov");
 myMovie2 = new Movie(this, "plant2.mov");
 myMovie1mask = new Movie(this, "plant3mask.mov");
 myMovie2mask = new Movie(this, "plant2mask.mov");
 myMovie1.loop();
 myMovie2.loop();
 myMovie1mask.loop();
 myMovie2mask.loop();


}

void movieEvent(Movie myMovie) {
 myMovie.read();
}

void draw(){

 mouseXc=(mouseX-width/2);
 mouseYc=-(mouseY-height/2);


 //TEMPORARY mouse detection to check interactivity/debug
 if(mousePressed) {
   slice1=loadImage("img"+str(1+int(random(4)))+".png");
   slice2=loadImage("img"+str(1+int(random(4)))+".png");
 }



 // Buffering images and content
 pg.beginDraw();
 pg.background(0);  

 
 //IMG1
  pg.image(slice1,width/2-100,height/2*(1+sin(opacity)));
 
 pg.translate(mouseXc+slice2.width,mouseYc+slice2.height);
 pg.rotate(PI*sin(opacity)/6);


 
 //IMG2
 pg.image(slice2,mouseXc,mouseYc);  
 
 pg.image(myMovie1,mouseXc,mouseYc);
 pg.image(myMovie2,mouseYc,mouseXc);
 myMovie1.mask(myMovie1mask);
 myMovie2.mask(myMovie2mask);

 pg.endDraw();

 // cropping/copying buffer to image and masking
 smallbufferImg=pg.get(outw/2,outh/2,outw/2,diagfactor);
 smallbufferImg.mask(maskImg);


 translate(width/2,height/2); //centers the kaleidoscope
 //first slice and reflection

 image(smallbufferImg,0,0);
 pushMatrix();
 scale(-1,1);  //copy and reflects the slice
 image(smallbufferImg,0,0);
 popMatrix();

 //draw the other slices    
 for (int i=1; i<6; i=i+1) {
   rotate(-PI/3);
   image(smallbufferImg,0,0);
   pushMatrix();
   scale(-1,1);
   image(smallbufferImg,0,0);
   popMatrix();

 }


}


don't think about the variable "diagfactor", it's made for the geometry of the kaleidoscope, also mouse detection is just for temporaty test, I'm planning to have cam input and try to detect movement


Thanks!!

f

Page Index Toggle Pages: 1