Saturday, February 21, 2015

Chromakey Software

I just decided to write and post this quickly as I have been using Adobe Premeire for some Video projects and decided that the software was rather expensive for the basic framework of Green screentools. While Green Screen Software is fairly expensive it has nice features like the ability to pick color families, but here is an example that will work, modification will be necessary, I left it open so that you can add multiple colors or just one or add a range. Now this directly captures an image from a camera. I created a color called pink but it simply has a 0 for alpha so that it is transparent. Unless the lighting is excellent create a series of ors(||) until the coloring is perfect or simply make a loop to test all related colors. I left it open because it depends really on the application and what works best. Anywho:

import processing.video.*;
 
color pink = color(255, 102, 204,0);
color black= color(255,255,255);

Capture kam;
 
void  setup  () {
  size (320, 240);

  kam= new Capture(this, 320, 240, 30);
  kam.start();
}
 
void  draw  () {
  background (255);// make this an image
 
   
  if (kam.available ()) {
    kam.read ();
  }
 
  for (int i=0; i < width; i++) {
    for (int j=0; j < height; j++) {
     
      // Read the color value for each pixel from
      color  k = kam. get  (i, j);
       
      stroke (k);
       point (i, j);
      if (k==black) { // list as many colors as you need
   stroke (pink);
       point (i, j);
      }
    }
  }
}

Now it can open from a file, just convert the video to a series of images. I demonstrated how to do this earlier in the Rotoscoping tools post. And then load these images in. This whole thing can be expanded with file menus and the like.

No comments:

Post a Comment