Masking an array of videos

Hi! I go back to the forum for help.

I’m with a project wanting to simulate with each click a different brush stroke, with a different color.

Before helped me to generate the video array but now I want to mask each video so that the black background is transparent and the white line is colored.
So far I have this code, without the mask part it works with the videos with a black background and white stroke.
What am I doing wrong?

What I want is:

  • take that video as image
  • apply the mask
  • color it

Before the videos were seen, with the part of the mask nothing is seen but the code runs without errors.

Thanks


class Pincelada {

  //1. Atributos
  int maxVideos;
  //Array para guardar toos los videos:
  Movie[] misVideos;

  //random var:
  int rand;

  //Duración del video:
  float duracion;

  //estado
  String estado;
  color tinta;
  // PImage imagen;

  //2. Constructor

  Pincelada(PApplet myApplet) {

    maxVideos = 5;
    misVideos = new Movie[maxVideos];

    //No hace nada:
    estado = "espera";

    tinta = color(155, 155, 200);

    for (int i = 0; i < misVideos.length; i++ ) {
      println( "trazo"+nf(i, 2) + ".mov"); 
      misVideos[i] =  new Movie (myApplet, "trazo"+nf(i, 2) + ".mov");      
    }
  }

  //3. Métodos
  void dibujar() {    
    if (videoPlay.size() > 0) {
      for (int i = 0; i < videoPlay.size(); i++ ) {
        videoPlay.get(i).play();
   
   //Mask from the first frame to apply:
        PImage imagen = videoPlay.get(i).get(0, 0, videoPlay.get(i).width, videoPlay.get(i).height);
        imagen.mask(imagen);
        
        pushStyle();
        image(imagen, videoPos.get(i).x, videoPos.get(i).y);
        imageMode(CENTER); 
        tint(tinta);
        println(videoPlay);
        popStyle();
      }
    }
  }

Hi, anyone can help me?
Now i tried to implement an if estructure but still nothing happens.

I want to be able to use a frame of the video as a mask to be able to color the strokes.

I don’t know what I’m doing wrong, I think it has to do with the use of the get () function.

I copy the class tab to see if someone can give me a hand.

Thanks in advance


class Pincelada {

  //1. Atributos
  int maxVideos;
  Movie[] misVideos;

  //random var:
  int rand;

  color tinta;

  //2. Constructor
  Pincelada(PApplet myApplet) {

    maxVideos = 4;
    misVideos = new Movie[maxVideos];

    for (int i = 0; i < misVideos.length; i++ ) {
      println( "trazo"+nf(i, 2) + ".mov"); 
      misVideos[i] =  new Movie (myApplet, "trazo"+nf(i, 2) + ".mov");
      //misVideos[i].loop();
    }
  }

  //3. Métodos
  void dibujar() {   
    if (videoPlay.size() > 0) {
      for (int i = 0; i< videoPlay.size(); i++ ) {
        videoPlay.get(i).read();
        imageMode(CENTER);

        
       // image(videoPlay.get(i), videoPos.get(i).x, videoPos.get(i).y);
        if ( videoPlay.get(i).available() ) {
          videoPlay.get(i).play();
      //I think maybe this is whats its wrong..
          PImage imagen = videoPlay.get(i).get(0, 0, videoPlay.get(i).width, videoPlay.get(i).height);
          imagen.mask(imagen);

          pushStyle();
          tint(random(255), random(255), random(255));
          image(imagen, videoPos.get(i).x, videoPos.get(i).y);
          popStyle();
        }
      }
    }
  }

  void cuandoSueltoElMouse() {
    //randomizar los videos
    rand = int(random(maxVideos)); 
    //guardo la posición:
    videoPos.add(new PVector(mouseX, mouseY));
    // agrego un video a la lista
    videoPlay.add(misVideos[rand]);
  }
}