Skip to content

Instantly share code, notes, and snippets.

@villares
Created February 22, 2021 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save villares/00b1100f34d3a389feb443832feccbeb to your computer and use it in GitHub Desktop.
Save villares/00b1100f34d3a389feb443832feccbeb to your computer and use it in GitHub Desktop.
Exemplo de captura baseado no filtro de video do PCD Brasil
// Baseado no código do PCD 2021 Brasil!
// https://github.com/Processing-Brasil/PCD-Brasil-2021-FiltroVideo/blob/main/linhasPCD/linhasPCD.pde
// Obrigado Monica, Guilherme e Carlos.
import processing.video.*;
Capture video;
int vEspaco = 10;
float precisao = 2;
void setup() {
size(800, 600);
video = new Capture(this, width, height);
video.start();
}
void captureEvent(Capture c) {
c.read();
}
void draw() {
background(0);
image(video, 0, 0);
stroke(255);
strokeWeight(2);
video.loadPixels();
float zoom = max((float)width/(float)video.width, (float)height/(float)video.height);
scale(zoom);
background(#e6e6d8);
noFill();
float tempo = (float)frameCount / 10.0;
//ondas
stroke(#ff666c);
for (int y = -vEspaco; y < video.height + vEspaco; y += vEspaco * 2) {
float comprimento = 0;
beginShape();
for (int x = 0; x < video.width; x += 2) {
float y_sin = sin(comprimento + tempo) * vEspaco * 2 + y;
vertex(x, y_sin);
comprimento += 0.1;
}
endShape();
}
//video em frequencias
for (int y = 0; y < video.height; y+=vEspaco) {
float x = 0;
float _y = y;
float fase = noise(y) * TWO_PI;
noFill();
stroke(#004aa3);
beginShape();
while (x < video.width) {
color col = video.get(floor(x), y);
float r = red(col);
float g = green(col);
float b = blue(col);
float intensidade = 1 - ((r + g + b) / 765);
_y = y + sin(fase - intensidade - tempo) * vEspaco / 2 + vEspaco / 2;
vertex(x, _y);
x += precisao / (intensidade + 0.01) / 5;
fase += 0.5;
}
vertex(video.width, _y);
endShape();
}
}
void keyPressed() {
if (key == 'a') {
vEspaco = vEspaco + 5;
}
if ((key == 'z') && (vEspaco > 5)) {
vEspaco = vEspaco - 5;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment