-
Notifications
You must be signed in to change notification settings - Fork 1
/
streak_mirror.pde
125 lines (99 loc) · 3.04 KB
/
streak_mirror.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/////////////////////////////////////////////////////////////////
///SEARCH////////////////////////////////////////////////////////
String searchTerm = "#LFC";
/////////////////////////////////////////////////////////////////
///CHOOSE HOW MANY TWEETS YOU WANT TO SEARCH
int numTweets = 500;
///SET LOCATION BY POINT AND RADIUS
boolean geoSearch = false;
double lat = 51.4;
double lon = 0.13;
double rad = 10;
String radUnit = "km";
/////////////////////////////////////////////////////////////////
///STREAM////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
String[] streamWords = {"#LFC", "#BBC"};
///CHOOSE GEO BOUNDING FOR STREAM
boolean geoStream = false;
double[][] streamLocations = {{51.4, -0.13}, {51.6, -0.11}};
import processing.video.*;
import gab.opencv.*;
import java.awt.*;
// Size of each cell in the grid
int cellSize = 15;
//int cellSize = 5;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;
OpenCV opencv;
int multiplier;
void setup(){
//////////////////establish twitter connection
connectTwitter();
//////////////////establish twitter connection
//size(1080, 1920);
//size(540,960);
size(640,480);
// Define colors
multiplier = 1;
cols = 640 / cellSize;
rows = 480 / cellSize;
colorMode(RGB, 255, 255, 255, 100);
rectMode(CENTER);
//video = new Capture(this, 640/2, 480/2);
//opencv = new OpenCV(this, 640/2, 480/2);
video = new Capture(this, 640, 480);
opencv = new OpenCV(this, 640, 480);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video.start();
background(0);
tweetTable = new Table();
}
void draw(){
if (video.available()) {
video.read();
//video.loadPixels();
//translate(-width/2,0);
//scale(4,4);
//scale(2);
opencv.loadImage(video);
//image(video, 0, 0 );
noFill();
stroke(0, 255, 0);
strokeWeight(0.2);
Rectangle[] faces = opencv.detect();
//println(faces.length);
for (int i = 0; i < faces.length; i++) {
//println(faces[i].x + "," + faces[i].y);
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
// Begin loop for columns
for (int i = 0; i < cols;i++) {
// Begin loop for rows
for (int j = 0; j < rows;j++) {
// Where are we, pixel-wise?
int x = i * cellSize;
int y = j * cellSize;
int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror the image
// Each rect is colored white with a size determined by brightness
color c = video.pixels[loc];
float sz = (brightness(c) / 255.0) * cellSize;
//fill(50);
noFill();
stroke(second()*3, minute()*3,hour()*3);
strokeWeight(0.1);
//noStroke();
//rect(x + cellSize/2, y + cellSize/2, sz, sz);
rect(x + cellSize/2, y + cellSize/2, second(), sz);
}
}
}
if (minute() == 0 && second() == 0){
tweetNewImage();
}
}
void captureEvent(Capture c) {
c.read();
}