Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Copy pixel[] and overlay

$
0
0

Screen Shot 2018-02-05 at 1.16.36 PM

I'm trying to create an effect like the image above which I have done by crudely exporting a frame then loading it and blending it - which isn't very memory/processor efficient. I'm wanting to know what the best way producing this effect would be with the pixel array. ie - how to store the pixels[] of a single frame.

thanks.

import processing.video.*;


PImage test, test2;
float FPS;
int count;
int mod;
int rand;


Capture video;

void setup() {
  size(640, 420, P2D);
  video = new Capture(this, 640, 360, 30);
  video.start();

}

void captureEvent(Capture video) {
  video.read();
}

void draw() {
  FPS = frameRate;
  count = ceil(millis()/1000);
  mod = count % 5;

  background(245, 238, 96);

  image(video, 0, 0, 640, 420);

  loadPixels();
  for (int i = 0; i < pixels.length; i++) {

    float b = brightness(pixels[i]);
    if (b > 97) {
      pixels[i] = color (255);
    } else {
      pixels[i] = color (245, 238, 96);
    }
  }

  updatePixels();
  textSize(16);
  fill(0);
  text(FPS, 50, 50);
  text(count, 50, 75);
  text(mod, 50, 100);
  text(mouseX, 50, 125);


}

Viewing all articles
Browse latest Browse all 2896

Trending Articles