mercredi 23 novembre 2016

Processing - random video array + webcam (to make security camera-type visuals)

I'm attempting to make the visuals for an art installation I'm working on, and I'm not quite sure how to go about it in Processing. Here's what I would like to do (I'll be using an old CCTV monitor):

  • Divide the screen into four quadrants (as if it were displaying feed from security cameras, but I'd be using videos, for the most part)

  • Have videos load randomly to those quadrants (from a total of 8 videos) and have the videos change after a certain number of seconds (they don't all have to change at once, but whatever's easiest)

  • Have a webcam send its feed into one of the quadrants as if it were another video

(I can always fix the webcam to one of the fourths of the screen and load random videos onto the other 3 available quadrants, if it simplifies things.)

My Processing skills are quite basic; so far I've managed to split the screen in 4 and load 4 videos, but I honestly don't know how to work with a video array, which sounds like the more reasonable way for the program to do what I would like it to.

Here is the basic code:

import processing.video.*;

Movie mov, mov1, mov2, mov3;

    void setup() {
      size(1280, 640);
      frameRate(30);
      mov = new Movie(this,"0.mov");
      mov1 = new Movie(this,"1.mov");
      mov2 = new Movie(this,"2.mov");
      mov3 = new Movie(this,"3.mov");

      mov.play();
      mov1.play();
      mov2.play();
      mov3.play();

      mov.volume(0);
      mov1.volume(0);
      mov2.volume(0);
      mov3.volume(0);
    }

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

    void draw() {
      image(mov, 0, 0, 640, 320);
      image(mov1, 640, 0, 640, 320);
      image(mov2, 0, 320, 640, 320);
      image(mov3, 640, 320, 640, 320);
    }

I started out with the above and then tried working with an array of videos, but only got so far:

import processing.video.*;

Capture cam;

int maxmyMovies = 8;
int myMoviesIndex = 0;
Movie[] myMovies = new Movie[maxmyMovies];

void setup() {

size(640,480);

cam = new Capture(this, 640, 480, 12);
cam.start();
smooth();

   for (int i = 0; i < myMovies.length; i ++ ) {
    myMovies[i] = new Movie(this, i + ".mov");

   }
}

void draw() {
 image(myMovies[myMoviesIndex], 0, 0);

  if (key == 'r') myMoviesIndex = int(random(0,8));

}

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

(The above is just copy/paste from other codes, I don't really want it to randomize when pressing the letter "r" but rather after a set time.) So, you can see I'm at a loss here... I would really appreciate any help.

Thanks!!




Aucun commentaire:

Enregistrer un commentaire