Difference between revisions of "Blockman"
(→Documentation) |
(→Code) |
||
Line 15: | Line 15: | ||
==Code== | ==Code== | ||
+ | |||
+ | import hypermedia.video.*; | ||
+ | import java.awt.Rectangle; | ||
+ | |||
+ | |||
+ | OpenCV opencv; | ||
+ | PFont font; | ||
+ | float ball_x; | ||
+ | float ball_y; | ||
+ | float ball_dir = 0; | ||
+ | float ball_size; // Radius | ||
+ | float dy = 0; // Direction | ||
+ | float dx = 0; | ||
+ | int dist_wall = 15; | ||
+ | int i; | ||
+ | |||
+ | //color c1 = color(102, 102, 0); | ||
+ | |||
+ | void setup() { | ||
+ | |||
+ | size(450, 450); | ||
+ | |||
+ | |||
+ | opencv = new OpenCV(this); | ||
+ | opencv.capture( width, height ); | ||
+ | opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load the FRONTALFACE description file | ||
+ | image( opencv.image(), 0, 0 ); // and display image | ||
+ | ellipseMode(RADIUS); | ||
+ | noStroke(); | ||
+ | smooth(); | ||
+ | ball_y = height/2; | ||
+ | ball_x = 1; | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | void draw() { | ||
+ | |||
+ | opencv.read(); | ||
+ | image( opencv.image(), 0, 0 ); | ||
+ | ball_x += dx; | ||
+ | ball_y += dy; | ||
+ | if(ball_x > width+ball_size) { | ||
+ | ball_x = -width/2 - ball_size; | ||
+ | ball_y = random(0, height); | ||
+ | dy = 0; | ||
+ | } | ||
+ | if (ball_x <= ball_size) ball_x=ball_size; | ||
+ | if (ball_x >= width-ball_size) ball_x=width-ball_size; | ||
+ | if (ball_y <= ball_size) ball_y=ball_size; | ||
+ | if (ball_y >= height-ball_size) ball_y=height-ball_size; | ||
+ | |||
+ | |||
+ | |||
+ | // detect anything ressembling a FRONTALFACE | ||
+ | Rectangle[] faces = opencv.detect(); | ||
+ | |||
+ | // draw detected face area(s) | ||
+ | noFill(); | ||
+ | stroke(255,0,0); | ||
+ | for( int i=0; i<faces.length; i++ ) { | ||
+ | rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height ); | ||
+ | ball_x = faces[i].x + (faces[i].width/2); | ||
+ | ball_y = faces[i].y + (faces[i].height/2); | ||
+ | ball_size = (faces[i].width/4) + (faces[i].height/4); | ||
+ | |||
+ | fill(0); | ||
+ | ellipse(ball_x, ball_y, ball_size, ball_size); | ||
+ | font = loadFont("Courier-20.vlw"); | ||
+ | textFont(font); | ||
+ | text("CENSORED: TOO VULGAR", (ball_x-faces[i].height/2), (ball_y-faces[i].width/2)); | ||
+ | fill(0); | ||
+ | |||
+ | } |
Revision as of 12:43, 4 June 2010
Description
- Motivation
I wanted to create an interactive piece that I might actually have a chance at finishing. I was influenced by Camille Utterback's "Text Rain" and wanted to see if I could make objects move within the screen using my body. Unfortunately, I found out last minute that my original code was invalid because I tried incorporating original processing code into an OpenCV code so i had to rethink my final project. In a way, all the work i put into the first idea actually helped me create my final product. I was able to use the face-tracking code to track the face and cover then censor the face for being too vulgar. This is a comment on the FCC's censorship on T.V. and a look into the future and comment on what they could end up censoring.
- Interactive paradigm
This would be in a gallery where people would interact by walking by. As they walk by they see that they are being projected onto the wall in front of them and as they turn to face the camera's the program will censor out their faces. It will read "Censored: Too Vulgar."
- Technical Description
I used processing to create a program that will create a black sphere where the face would be and "censor" it out. I used the face tracking code and basically created a sphere inside the box that the face-tracking code creates. The webcam captures the video images and allows the user to see the footage being displayed with the censored faces.
Documentation
Code
import hypermedia.video.*; import java.awt.Rectangle;
OpenCV opencv;
PFont font;
float ball_x;
float ball_y;
float ball_dir = 0;
float ball_size; // Radius
float dy = 0; // Direction
float dx = 0;
int dist_wall = 15;
int i;
//color c1 = color(102, 102, 0);
void setup() {
size(450, 450); opencv = new OpenCV(this); opencv.capture( width, height ); opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load the FRONTALFACE description file image( opencv.image(), 0, 0 ); // and display image ellipseMode(RADIUS); noStroke(); smooth(); ball_y = height/2; ball_x = 1;
}
void draw() {
opencv.read(); image( opencv.image(), 0, 0 ); ball_x += dx; ball_y += dy; if(ball_x > width+ball_size) { ball_x = -width/2 - ball_size; ball_y = random(0, height); dy = 0; } if (ball_x <= ball_size) ball_x=ball_size; if (ball_x >= width-ball_size) ball_x=width-ball_size; if (ball_y <= ball_size) ball_y=ball_size; if (ball_y >= height-ball_size) ball_y=height-ball_size;
// detect anything ressembling a FRONTALFACE Rectangle[] faces = opencv.detect(); // draw detected face area(s) noFill(); stroke(255,0,0); for( int i=0; i<faces.length; i++ ) { rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height ); ball_x = faces[i].x + (faces[i].width/2); ball_y = faces[i].y + (faces[i].height/2); ball_size = (faces[i].width/4) + (faces[i].height/4);
fill(0);
ellipse(ball_x, ball_y, ball_size, ball_size); font = loadFont("Courier-20.vlw");
textFont(font); text("CENSORED: TOO VULGAR", (ball_x-faces[i].height/2), (ball_y-faces[i].width/2)); fill(0);
}