-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmetMirror.pde
76 lines (56 loc) · 1.69 KB
/
metMirror.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import processing.video.*;
//andy's filter stuff:
int faceSize = 7; //changes the resolution (# of faces drawn)
float speed = 0.03; //changes how fast they wiggle
float rAmount = 16; //changes how much they wiggle
int xDim = 23;
int yDim = 12;
PImage[] faces = new PImage[xDim*yDim];
PImage master;
Pic[] pics = new Pic[xDim*yDim];
int outWidth = faceSize*3;
int outHeight = faceSize*5;
int outXDim = 1280/outWidth;
int outYDim = 800/outHeight;
boolean snap = false;
Capture video;
void setup() {
size(1280, 800);
frameRate(30);
master = loadImage("./data/output_small_2.jpg");
createFaces();
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
}
else {
println("Available videos:");
for (int i = 0; i < cameras.length; i++) {
println(i+": "+ cameras[i]);
}
video = new Capture(this, width, height);
video.start();
background(0);
}
}
void draw() {
if (video.available()) {
video.read();
video.loadPixels();
for (int x=0;x<outXDim;x++) {
for (int y=0;y<outYDim;y++) {
int xPos = x*outWidth;
int yPos = y*outHeight;
int index = xPos+(yPos*width);
color thisColor = video.pixels[index];
int matchIndex = findMatch(thisColor);
float rx = (noise((frameCount*speed)+(index)+((float)index/video.pixels.length))-.5)*rAmount;
float ry = (noise((frameCount*speed)+(index)+((float)index/video.pixels.length)+200)-.5)*rAmount;
//pixels[index] = thisColor;
image(faces[matchIndex], xPos+rx, yPos+ry, outWidth, outHeight);
}
}
updatePixels();
}
}