Hello,
So I am very new to processing (I started doing stuff a couple of weeks ago) and I am trying to work on an art project. It is super simple, really...All I need to do is have the webcam running, and when a key (any key) gets pressed it the camera glitches for about three seconds and then it resumes the regular streaming until pressed again. So far I have the code to activate the webcam, and I found a code online that creates the glitch that I like, but I do not quite understand how to combine both codes. Sorry if this is not the proper way to do it but I really need help.
Thanks!
import processing.video.*; Capture webcam;
void setup() {
size(displayWidth,displayHeight);
webcam = new Capture(this,1280,720);
String[] devices = Capture.list();
println(devices);
webcam.start();
}
void draw() {
if (webcam.available() == true) {
webcam.read();
image(webcam ,0,0);
}
}
void keyPressed() {
switch (key) {
case 'g': ;
case 'c': ;
case 'f': ;
case 'F': ;
}
}
And here's the glitch video
import processing.video.*;
Capture cam;
int N=0;
void setup(){
size (851,315);
background(255);
colorMode(HSB);
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
cam = new Capture(this, cameras[0]);
cam.start();
}
}
void draw(){
Set();
if (cam.available() == true) {
if(frameCount==2||frameCount%150==0){
cam.read();
image(cam, 0, 0);
}
}
int r(int a){
return int(random(a));
}
void mouseReleased (){
N++;
save("glitchCamera"+ (N)+".tif");
}
void Set() {
for (int i=0; i<10; i++) {
int x = r(width);
int y = r(height);
set(x+r(50)-1,y+r(3)-1,get(x,y,r(99),r(30)));
}
}